DataPI.

What would you like to understand?

Preparing search…
    All results and search filters →

    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

    StateMeaningWhat to do
    queuedAccepted and visible, no worker has claimed itPoll with backoff or wait for the completion webhook
    runningA worker claimed it; phase says which stepContinue polling or rely on the webhook
    succeededA result was stored; result.available says it can still be readRead result_url while result.available is true
    failed / timed_outTerminal failure or runtime limit; error carries the codeRead error.code, fix the input or retry deliberately
    canceledWork was canceled before completionSubmit a new request if the work is still needed

    Phase: the step the worker entered

    PhaseMeaningReported as
    queuedNo worker has started the workstatus queued
    executingThe source is being called for this requeststatus running
    ingestingRows are arriving and being normalizedstatus running
    finalizingThe result and its retention deadline are being writtenstatus running
    completedThe result is stored and result.expires_at is setstatus succeeded
    failedThe work stopped on an error before a result existedstatus 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

    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

    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

    Runtime contract snapshot: DataPI API v1.0.0 · 75 HTTP operations documented of 265 runtime operations · 40 catalog operations · 11 available at capture. Captured: . Source: https://api.datapi.ir/v1/contracts.