All docs

Webhooks and waiting for results

Instead of polling a job, give us a URL and we POST a signed job.completed event to it when the job ends. For platforms that answer in seconds, you can also hold the submit request open until the job is done. Both are free.

Get notified when a job ends

Add webhook_url to the body of POST /v1/answers. The MCP ask tool takes the same field.

curl https://api.askcrawl.com/v1/answers \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "X-Max-Price: 0.02" \
  -d '{"prompts": ["best crm for small business"], "engines": ["chatgpt.web", "perplexity.web"], "samples": 3, "webhook_url": "https://example.com/askcrawl/webhook"}'

The job ends when every answer has an outcome: answered, no answer, refused or failed. The event is usually sent within about a minute of that, because a scheduled task picks it up once a minute. There is one event per job.

  • The URL has to be https on port 443, with a public host name: no IP address, no username or password, no internal host names.
  • When we send, we look the host name up again and refuse to connect if any address is private, loopback, link-local or a cloud metadata address. Redirects are not followed.
  • A different webhook_url with the same Idempotency-Key is a different request and returns idempotency_conflict.
  • POST /v1/answers/quote checks the URL the same way, so a quote that passes means the submission will not be refused for it.

What we send

A small JSON body: the job as GET /v1/jobs/{id} would return it at that moment, and links to read it. The answers themselves are not in it; fetch them with your key.

{
  "id": "6f1c2a9e-4b7d-4e0a-9c55-1d2e3f4a5b6c",
  "type": "job.completed",
  "created_at": "2026-12-02T10:01:12.000Z",
  "data": {
    "job": {
      "id": "2f6c1c0e-5b7a-4d1e-9a53-0c8e4f7b21a6",
      "status": "completed",
      "total": 6,
      "counts": { "answered": 6, "no_answer": 0, "refused": 0, "failed": 0, "pending": 0 },
      "max_charge": "0.015",
      "held": "0",
      "charged": "0.015",
      "completed_at": "2026-12-02T10:00:31.000Z",
      "retry_after_seconds": null
    },
    "links": {
      "job": "https://api.askcrawl.com/v1/jobs/2f6c1c0e-5b7a-4d1e-9a53-0c8e4f7b21a6",
      "answers": "https://api.askcrawl.com/v1/answers?job_id=2f6c1c0e-5b7a-4d1e-9a53-0c8e4f7b21a6"
    }
  }
}

data.job.status is completed (nothing failed), partial (some answers failed) or failed (all failed). Failed answers are not charged.

HeaderWhat it holds
webhook-idThe event ID, the same as id in the body. It stays the same on every retry
webhook-timestampWhen this attempt was sent, in Unix seconds
webhook-signaturev1, followed by the signature. There may be several, separated by spaces

Check the signature

The signature follows the Standard Webhooks scheme, so its libraries work too. By hand: take the signing secret whsec_…, drop the prefix and base64-decode the rest; compute HMAC-SHA256 over webhook-id, a dot, webhook-timestamp, a dot and the raw body; base64-encode the result and compare it with each v1, entry. Then:

  • Use the raw body exactly as received. Parsing and re-serialising the JSON changes the bytes and breaks the signature.
  • Refuse a timestamp more than 300 seconds away from your clock, so an old delivery cannot be replayed.
  • Keep the event IDs you have handled and ignore repeats: a retry can arrive after a delivery you already processed.
  • Reply with any 2xx quickly, then do the work. Our Python and Node.js clients include verify_webhook and verifyWebhook.
import base64, hashlib, hmac, json, os, time

SECRET = os.environ["ASKCRAWL_WEBHOOK_SECRET"]  # whsec_…

def verify(headers, raw_body: bytes):
    """headers: a dict with lower-case names. Returns the event, or raises ValueError."""
    msg_id, stamp, signatures = headers["webhook-id"], headers["webhook-timestamp"], headers["webhook-signature"]
    if abs(time.time() - int(stamp)) > 300:
        raise ValueError("too old")
    key = base64.b64decode(SECRET.removeprefix("whsec_"))
    digest = hmac.new(key, f"{msg_id}.{stamp}.".encode() + raw_body, hashlib.sha256).digest()
    expected = "v1," + base64.b64encode(digest).decode()
    if not any(hmac.compare_digest(expected, each) for each in signatures.split()):
        raise ValueError("bad signature")
    return json.loads(raw_body)

Retries

Anything but a 2xx within 10 seconds counts as a failure: another status code, a redirect, a timeout or a refused connection. A failed delivery is sent again after 1 min, 10 min, 1 h, 6 h, 16 h: at most 6 attempts in all, the last one about 23 hours after the first. Every attempt carries the same event ID and is signed again, with the secret in effect at that moment. If an attempt was cut off on our side and we cannot tell whether it reached you, one extra attempt is added (once per event). After the last attempt no more are made; the job and its answers are still there to read.

The console shows the latest deliveries and the result of each, under Settings.

The signing secret

Each account has one signing secret. Create it in the console under Settings, in the Webhooks section, and store it where your server reads it. It is shown only once: we cannot show it again, only replace it.

  • If you never created one, one is created when your first event is sent. Rotate it to get a secret you can see.
  • Rotating replaces the secret at once. Deliveries already sent with the old one will not verify against the new one; their retries are signed with the new one, so update your server and they go through.
  • API keys cannot read or rotate the secret; only a signed-in person in the console can.

Wait for the result

Some platforms answer within seconds. For them, add wait to the body: the number of seconds, up to 50, to hold the reply until the job ends.

curl https://api.askcrawl.com/v1/answers \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "X-Max-Price: 0.01" \
  -d '{"prompts": ["best crm for small business"], "engines": ["deepseek.api"], "wait": 30}'
  • If the job ends in time, the reply (still 202) is the finished job: status is completed, partial or failed, counts.pending is 0 and retry_after_seconds is null. Read the answers with GET /v1/answers?job_id=.
  • If it has not ended, the reply is the usual one and you check later as you normally would. Nothing is charged for waiting, and the job keeps running either way.
  • Platforms that usually answer within 30 seconds: perplexity.api, claude.api, deepseek.api, bing.copilot_search, perplexity.web, xiaohongshu.diandian. Others work too, but most will not finish in time.
  • Set your HTTP client's timeout above wait, for example wait plus 15 seconds. MCP clients often stop waiting after 60 seconds, which is why the limit is 50.
  • Quotes ignore wait. It can be combined with webhook_url.