# 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.

| Header | What it holds |
| --- | --- |
| `webhook-id` | The event ID, the same as `id` in the body. It stays the same on every retry |
| `webhook-timestamp` | When this attempt was sent, in Unix seconds |
| `webhook-signature` | `v1,` followed by the signature. There may be several, separated by spaces |

## Check the signature

The signature follows the [Standard Webhooks](https://www.standardwebhooks.com/) 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](https://github.com/askcrawlhq) 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)
```

```
import { createHmac, timingSafeEqual } from "node:crypto";
import { createServer } from "node:http";

const secret = Buffer.from(process.env.ASKCRAWL_WEBHOOK_SECRET.replace(/^whsec_/, ""), "base64");

function verify(headers, raw) {
  const [id, stamp, signatures] = [headers["webhook-id"], headers["webhook-timestamp"], headers["webhook-signature"]];
  if (!id || !stamp || !signatures || Math.abs(Date.now() / 1000 - Number(stamp)) > 300) throw new Error("too old");
  const expected = Buffer.from(`v1,${createHmac("sha256", secret).update(`${id}.${stamp}.`).update(raw).digest("base64")}`);
  const ok = signatures.split(" ").some((each) => each.length === expected.length && timingSafeEqual(Buffer.from(each), expected));
  if (!ok) throw new Error("bad signature");
  return JSON.parse(raw.toString("utf8"));
}

createServer((request, response) => {
  const chunks = [];
  request.on("data", (chunk) => chunks.push(chunk));
  request.on("end", () => {
    try {
      const event = verify(request.headers, Buffer.concat(chunks));
      response.writeHead(204).end();
      // Then: skip event.id if already handled; read the answers from event.data.links.answers with your key.
    } catch {
      response.writeHead(400).end();
    }
  });
}).listen(8080);
```

## 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](https://www.askcrawl.com/console/settings/).

## The signing secret

Each account has one signing secret. Create it in the console under [Settings](https://www.askcrawl.com/console/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` .

Up

[Docs](https://www.askcrawl.com/docs/)

Related

[Brand reports and comparisons](https://www.askcrawl.com/docs/reports/)

[Errors and charges](https://www.askcrawl.com/docs/errors/)

Basis

[Methodology](https://www.askcrawl.com/methodology/)

[Pricing and billing rules](https://www.askcrawl.com/pricing/)

Next

[API reference](https://www.askcrawl.com/docs/api/)

[All AI platforms](https://www.askcrawl.com/engines/)

> Page: https://www.askcrawl.com/docs/webhooks/ · Content date: 2026-12-02
