Concepts
Requests, states and results
The asynchronous request lifecycle: the 202 acceptance record, status versus phase, when a stored result can actually be read, idempotent replays and how to recover from each terminal state.
One lifecycle for every operation
POST /v1/requests validates the operation input, checks availability and permission, then queues work. mode defaults to async, so the answer is 202 with a Location header and the same request record the status route returns: request_id, status, phase, progress, absolute status_url and result_url, a result object that states whether the stored result can be read now, and a webhook object that says whether a completion notification is attached.
mode=sync exists for short operations and answers in the same connection. It has no request record to poll, so use async when you need history, retention or a webhook.
Status: where the request stands
| State | Meaning | What to do |
|---|---|---|
| queued | Accepted and visible, no worker has claimed it | Poll with backoff or wait for the completion webhook |
| running | A worker claimed it; phase says which step | Continue polling or rely on the webhook |
| succeeded | A result was stored; result.available says it can still be read | Read result_url while result.available is true |
| failed / timed_out | Terminal failure or runtime limit; error carries the code | Read error.code, fix the input or retry deliberately |
| canceled | Work was canceled before completion | Submit a new request if the work is still needed |
Phase: the step the worker entered
| Phase | Meaning | Reported as |
|---|---|---|
| queued | No worker has started the work | status queued |
| executing | The source is being called for this request | status running |
| ingesting | Rows are arriving and being normalized | status running |
| finalizing | The result and its retention deadline are being written | status running |
| completed | The result is stored and result.expires_at is set | status succeeded |
| failed | The work stopped on an error before a result existed | status failed or timed_out |
Reading the payload without guessing
- status is the coarse state and only changes when the transition really happened; phase names the step the worker actually entered. Neither is derived from elapsed time.
- progress is a percentage the worker measured, or null. No source reports a measurement today, so expect null and read it as unknown — never as zero percent. status and phase carry the real information.
- result.available answers one question: would GET result_url succeed right now. result.expired says the retention window has closed, and result.expires_at with result.retention_hours (24) bound it.
- webhook.configured says a completion notification is attached to this request. The signing secret appears only in the 202 response that created the endpoint, never in later status reads.
- error holds a code and message for a failed or timed_out request. An empty successful result is not an error, and a failure is never rendered as empty data.
Idempotency, replays and retention
- The key alone identifies the submission: a retry that reuses Idempotency-Key resolves to the request that key already created instead of queueing duplicate work, so always pair one key with one body.
- A replay never re-returns a webhook signing secret, and it is rejected with 409 idempotency_key_conflict when its webhook block disagrees with what the original attached — a different URL, or no webhook block at all. Repeat the identical body, webhook included, or use a new key.
- A 409 result_not_ready means the request is still queued or running; it is not a server failure.
- A 410 result_expired means the retained result is gone. Re-run the operation if the data is still needed.
- List requests with limit and the opaque before cursor. Keep filters stable between pages.
Accepted request that reports back by webhook
{
"operation": "social.instagram.profile.read",
"input": { "handle": "example" },
"webhook": { "url": "https://example.com/hooks/datapi", "event_types": ["request.completed"] }
}
// 202 Accepted
// Location: /v1/requests/9c50c1ab-8ca2-4e94-a44c-c67374b9d607
{
"data": {
"request_id": "9c50c1ab-8ca2-4e94-a44c-c67374b9d607",
"operation": "social.instagram.profile.read",
"status": "queued",
"phase": "queued",
"progress": null,
"status_url": "https://api.datapi.ir/v1/requests/9c50c1ab-8ca2-4e94-a44c-c67374b9d607",
"result_url": "https://api.datapi.ir/v1/requests/9c50c1ab-8ca2-4e94-a44c-c67374b9d607/result",
"result": {
"available": false,
"expired": false,
"url": "https://api.datapi.ir/v1/requests/9c50c1ab-8ca2-4e94-a44c-c67374b9d607/result",
"expires_at": "2026-10-28T10:00:00+00:00",
"retention_hours": 24
},
"webhook": {
"configured": true,
"endpoint_id": "e03e46d3-e66b-490c-aee1-e8900c3e3699",
"event_type": "request.completed",
"signing_secret": "dapi_whsec_example",
"signature_headers": ["X-DataPI-Signature", "X-DataPI-Timestamp", "X-DataPI-Event-Id", "X-DataPI-Delivery-Attempt"]
},
"error": null
},
"meta": { "request_id": "req_example" }
}The request-scoped webhook is created in the same call that accepts the work, and its signing secret is returned only in this 202 response. Store it before leaving the call.
Canonical status record
{
"data": {
"request_id": "9c50c1ab-8ca2-4e94-a44c-c67374b9d607",
"tracker_id": null,
"operation": "social.instagram.profile.read",
"status": "succeeded",
"phase": "completed",
"progress": null,
"created_at": "2026-10-27T10:00:00+00:00",
"started_at": "2026-10-27T10:00:01+00:00",
"finished_at": "2026-10-27T10:00:04+00:00",
"status_url": "https://api.datapi.ir/v1/requests/9c50c1ab-8ca2-4e94-a44c-c67374b9d607",
"result_url": "https://api.datapi.ir/v1/requests/9c50c1ab-8ca2-4e94-a44c-c67374b9d607/result",
"result": {
"available": true,
"expired": false,
"url": "https://api.datapi.ir/v1/requests/9c50c1ab-8ca2-4e94-a44c-c67374b9d607/result",
"expires_at": "2026-10-28T10:00:04+00:00",
"retention_hours": 24
},
"webhook": { "configured": true, "endpoint_id": "e03e46d3-e66b-490c-aee1-e8900c3e3699", "event_type": "request.completed" },
"selection": null,
"error": null
},
"meta": { "request_id": "req_example" }
}status_url, result_url and result.url are absolute on the public API origin. The completion webhook repeats these fields with the same values, except that it carries result_url only when the result is available.
Related pages
- Quickstart: from token to verified resultCreate a workspace token, inspect an operation, submit an asynchronous request and read the result.
- Completion webhooks and signaturesRegister an HTTPS destination, verify the HMAC-SHA256 signature over the raw body, deduplicate events and recover from failures.
- Error envelope and status codesEvery error has one shape, a stable code and a request ID for support without leaking provider details.