Scout · Endpoints

Jobs & webhooks

Enqueue many independent Scout operations, poll until done, and optionally receive a signed completion webhook.

Journey vs jobs
Journey = one flow, shared browser state (login → click → extract). Jobs = many independent requests (often many URLs). See the comparison on Journey.

Create a job

POST/v1/jobsAPI key

Nested types: screenshot | extract | visibility | inspect | performance | journey | crawl. Credits = sum of nested estimates.

NameTypeRequiredDescription
requestsarrayrequiredList of { type, body } operations to run sequentially.
requests[].typestringrequiredscreenshot | extract | visibility | inspect | performance | journey | crawl.
requests[].bodyobjectrequiredSame body shape as the matching POST /v1/… endpoint.
webhook_urlstringoptionalHTTPS URL to notify when the job finishes.
webhook_secretstringoptionalHMAC secret for this job (overrides key/env secret).
bash
curl -X POST https://scout.macrocontent.dev/v1/jobs \
  -H "Authorization: Bearer sk_scout_…" \
  -H "Content-Type: application/json" \
  -d @job.json
json
{
  "webhook_url": "https://hooks.example.com/scout",
  "webhook_secret": "whsec_…",
  "requests": [
    { "type": "screenshot", "body": { "url": "https://example.com", "format": "jpeg" } },
    { "type": "inspect", "body": { "url": "https://example.com", "include": ["meta"] } },
    {
      "type": "journey",
      "body": {
        "debug": { "on_error_only": true },
        "steps": [
          { "type": "navigate", "url": "https://example.com" },
          { "type": "extract", "fields": [{ "name": "h1", "selector": "h1", "type": "text" }] }
        ]
      }
    }
  ]
}

Poll

GET/v1/jobs/:idAPI key

Poll status/results until expires_at (default TTL 1800s). 0 credits.

bash
curl https://scout.macrocontent.dev/v1/jobs/job_… \
  -H "Authorization: Bearer sk_scout_…"

Statuses: queuedrunningcompleted | failed. Results live until expires_at (default ~1800s) — Scout is not a long-term archive. Large jobs (many screenshots / debug journeys) can produce multi‑MB JSON; keep batches modest or omit journey debug in production.

Journey inside a job

Nested journey bodies support the same fields as POST /v1/journey, including debug. Prefer debug only while developing — batch responses get large.

Webhook HMAC

When a secret is available, Scout POSTs the job result and signs it with:

  • X-Scout-Timestamp — unix seconds
  • X-Scout-Signaturesha256=<hex> of HMAC-SHA256(secret, "${timestamp}.${rawBody}")

Secret resolution order: job webhook_secret → key webhook secret → env SCOUT_WEBHOOK_SECRET.

javascript
const crypto = require('crypto');
function verify(secret, timestamp, signatureHeader, rawBody, maxAge = 300) {
  if (Math.abs(Date.now() / 1000 - Number(timestamp)) > maxAge) return false;
  const expected = 'sha256=' + crypto.createHmac('sha256', secret)
    .update(`${timestamp}.${rawBody}`).digest('hex');
  return crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(signatureHeader));
}