Idempotency
Send an Idempotency-Key with every request that can be charged. If the connection drops or the call times out, send it again with the same value: nothing runs twice and nothing is charged twice.
How to use it
Idempotency-Key is an ID you choose and send as a header. One ID stands for one thing you want done: reuse it to retry that thing, and pick a new one for anything else.
curl https://api.askcrawl.com/v1/answers \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: my-first-job" \
-H "X-Max-Price: 0.02" \
-d '{
"prompts": ["best crm for small business"],
"engines": ["chatgpt.web", "perplexity.web"],
"samples": 3
}'- The ID is 1 to 255 printable ASCII characters with no spaces. A random UUID works, and so does your own order number.
- Generate and store the ID before you send the request. If you only create one after a failure, you have nothing to retry with.
- A resend without an ID is treated as a new request and may be charged again.
What a resend does
| What happened the first time | Sending again with the same ID and parameters |
|---|---|
| The job was created | Returns the original job; no second job is created |
| A data call succeeded | Returns the saved result at no further charge, with meta.replayed set to true |
| A data call is still running | Waits for it. If it takes too long you get call_in_progress; ask again shortly with the same ID |
| A data call returned no data and was not charged | Runs again |
| Same ID, different parameters | Returns idempotency_conflict and runs nothing |
IDs used to submit jobs are remembered for 12 months, and IDs used with data endpoints for 24 hours. After that, the same ID is treated as a new request.
When billing is unknown
On rare occasions you get settlement_unknown: the request may have run, but it is not yet known whether it was charged. charged is null.
Send the request again with the same Idempotency-Key, never a new one. A new ID could mean paying twice.
- When submitting a job, the
next_stepin the response names a job ID. Check whether that job exists first; if it does not, submit again with the same ID. - When calling a data endpoint, send the call again shortly with the same ID. If it already ran, you get the saved result.
Look up an ID
For data endpoints you can check an ID directly. This endpoint is free.
curl -G https://api.askcrawl.com/v1/calls \ --data-urlencode "idempotency_key=my-first-call" \ -H "Authorization: Bearer $API_KEY"
The state in the response says where that ID stands: unused, still running, has a result, definitely failed, free to retry, or expired.
expired means the ID was used, but its 24-hour retention period is over. charged is what that call cost. Sending a request with the same ID runs it again and charges again. To see the original record, look up the returned request_id.
IDs used to submit jobs are not looked up here: submit again with the same ID and parameters and you get the original job back.
Which requests accept it
Only requests that can be charged accept Idempotency-Key: creating a collection job and every data endpoint. Quotes, progress checks, reading answers and reports are free and safe to retry as they are; sending them an Idempotency-Key returns invalid_params.
Over MCP, the idempotency_key argument of the ask and call tools does the same job.