Docsfra
API Documentation
v1

Polling

GET /v1/jobs/{id} is the only endpoint — it returns both the job status and (once complete) the result in the same response; there is no separate "get result" endpoint. Even if webhook delivery fails or never arrives, the client can always rely on this endpoint: polling is the reliable fallback for webhooks.

State machine

queued -> processing -> parsing -> indexing -> completed / failed
StateMeaning
queuedDocument received, waiting in queue.
processingJob started; the document is being split into pages (the first step of the page-by-page resilient pipeline).
parsingPages are being extracted one by one. Even if a page temporarily fails, the job does not get stuck — automatic retry and last-resort fallback are in effect; the client doesn't need to do anything.
indexingAll pages are merged in page_no order to produce the final markdown/JSON (the full-text search index is also written at this step).
completedThe result is ready; the result field is populated.
failedThe job has permanently failed; the error field is populated, result is always null.

The result field is only populated when status: "completed". The error field is only populated when status: "failed".

Once a document becomes completed, it automatically enters AI-indexing (chunk -> embed -> vector) as well as AI-representation production (memory, entities, reasoning, layout — see Extraction & Artifacts); this proceeds in the background, independently of completed. Indexed documents become queryable via Semantic Search and Q&A.

Progress of this background phase is exposed via the additive ai_status field on this same response (see below) — a job can read status: "completed" while ai_status is still chunking or embedding.

GET /v1/jobs/{id} — status and result in the same response

{
  "id": "d_9c1a...",
  "batch_id": "b_5f2a...",
  "external_item_ref": "INV-001",
  "external_batch_ref": "PO-2026-001",
  "status": "completed",
  "page_count": 12,
  "partial": false,
  "file_size_bytes": 245678,
  "source": {
    "filename": "invoice-001.pdf",
    "content_type": "application/pdf",
    "size_bytes": 245678,
    "url": "https://media-cdn.../signed?exp=..."
  },
  "result": {
    "markdown_url": "https://markdown-cdn.../result.md?signed&exp=...",
    "json_url": "https://markdown-cdn.../result.json?signed&exp=...",
    "structured_url": "https://markdown-cdn.../result.structured.md?signed&exp=..."
  },
  "error": null,
  "created_at": "2026-07-01T09:00:00Z",
  "updated_at": "2026-07-01T09:02:15Z",
  "completed_at": "2026-07-01T09:02:15Z",
  "ai_status": "ready",
  "cost": "16.6893"
}
  • ai_status — additive field tracking the background AI-representation pipeline for this document, independent of status. One of none (not yet started, or briefly right after completed), chunking, embedding, ready (all requested AI artifacts finished), partial (some artifacts failed to produce — the rest are still usable), or failed. Poll GET /v1/documents/{id}/artifacts (see Extraction & Artifacts) to see exactly which artifacts are available.

  • source.url — the download link for the originally uploaded file. If the raw file is deleted from media-cdn after the retention period ends, url returns null (the file no longer exists, but the record and result are unaffected).

  • result.markdown_url, result.json_url — time-limited signed links, freshly generated on every GET call (lazy signing). Do not cache the link, it expires.

  • result.structured_url — optional; the raw markdown reorganized (structured) according to a fixed template. Only present when it can be generated — it's a best-effort enrichment, not a core deliverable; if it cannot be generated, the field is entirely absent from the response.

  • result.no_text — optional, only ever true: set when none of the read pages contains a letter or digit (e.g. an unreadable dark photo; the output holds only an image link). In that case partial: true is returned and neither the structured output (structured_url) nor the memory layer is produced. Absent for documents with text.

  • Stamp, seal, signature and logo notes: OCR doesn't read these images as text; instead of the image link, the markdown carries a note from the vision model on our own infrastructure: [kaşe: ABC Lojistik A.Ş. ...] (company stamp), [mühür: T.C. ...] (official emblem or seal of a public body), [imza] (signature), [kaşe + imza: ...], [logo: ...]. The text inside a note is made of the words that appear in at least two of three separate readings of the same image; if the readings don't agree it says okunamadı (unreadable). Images without text or signature (such as QR codes), images larger than a quarter of the page and pages made of images only are not annotated (the image link stays, and the no_text signal is unchanged). A note is the model's reading; verify values such as tax numbers against the source.

  • result.rescued_pages — optional; numbers of the pages whose text was read by the fallback vision model (same numbering as pages[].page, e.g. [2, 5]). The text on these pages is a model reading; verify critical values such as amounts, dates and ID numbers against the source. Absent when no fallback reading happened.

  • result.selection_marks — optional; when the document contains checkboxes or radio buttons, every box in page order: page, state (selected / unselected), confidence (0–1), bbox ([x0, y0, x1, y1], in the same coordinate space as page_size), label_text (the label to the right of the box; null if it couldn't be linked) and page_size ([width, height]). In the markdown each box is written as ☑ / ☐ right in front of its own label; a handwritten X counts as ticked. Absent for documents without boxes. Faintly printed boxes, boxes with broken borders and handwritten marks that spill outside the box can be missed; a missed box is left out of the list, never added with the wrong state. Box reading applies to documents read after 30 November 2026; documents processed earlier keep their old output.

    "selection_marks": [
      { "page": 1, "state": "unselected", "confidence": 0.97, "bbox": [96, 418, 110, 432],
        "label_text": "Vesaik İbrazında Ödemeli / Sight L/C", "page_size": [1191, 1684] },
      { "page": 1, "state": "selected", "confidence": 0.99, "bbox": [412, 418, 426, 432],
        "label_text": "Vadeli Ödemeli / Deferred Payment L/C", "page_size": [1191, 1684] }
    ]
    

Error: 404 not_found — the id doesn't exist or belongs to another tenant (the resource's existence is never leaked via 403).

Result content: markdown, JSON, and page citations

The two (optional third) links in the result field download different bodies:

  • markdown_url — plain-text markdown with all pages merged together.

  • json_url — the DIP canonical, versioned wrapper schema. Per-page citations (pages[]) are inside this body — not in the job status response:

    {
      "schema_version": "1.0",
      "source": {
        "engine": "mineru-api",
        "engine_version": "per-page",
        "backend": "vlm-page",
        "engines": { "mineru-api": 11, "mineru-api+vlm-rescue": 1 }
      },
      "document": {
        "page_count": 12,
        "pages": [
          { "page": 1, "markdown": "...", "blocks": [], "engine": "mineru-api" },
          { "page": 2, "markdown": "...", "blocks": [], "engine": "mineru-api+vlm-rescue" }
        ],
        "metadata": { "rescued_pages": [2] }
      },
      "markdown": "...",
      "extracted_at": "2026-07-01T09:02:15Z"
    }
    

    Each pages[] element carries which page it came from (page) and that page's markdown — use this body for page-level citation/source display.

    Engine information:

    • source.engine — the engine that read the majority of pages (on a tie, the first one seen in page order); vlm if no page carries engine information. engine_version and backend are unchanged.
    • source.engines — page count per engine.
    • pages[].engine — the engine that read that page (e.g. mineru-api, email-adapter); null if unknown.
    • mineru-api+vlm-rescue — this page was read by the fallback vision model; its text is a model reading, verify critical values against the source. The same pages are listed in metadata.rescued_pages and in the job response's result.rescued_pages.
    • pages[].selection_marks — the boxes on that page (same format as result.selection_marks); present only on pages with boxes.
    • metadata.no_text: true — same condition as result.no_text. These two metadata fields appear only when their condition holds; otherwise metadata is {}.

    result.json is written once when the document is processed; bodies of documents processed before these fields were added keep the old shape.

  • structured_url (if present) — the same content reorganized according to a fixed template (Parties / Main Table / Total / Other); it is not a summary, no data from the source is dropped.

partial — partial success

In the page-by-page resilient pipeline, a temporary issue on a single page does not make the whole document failed: failed pages are automatically retried, falling back to an alternative engine as a last resort. However, if a page is exhausted across all engines:

  • The document still becomes completed (the other pages are never lost).
  • partial: true is returned — indicating that at least one page in the result is missing/a placeholder (that page's markdown in pages[] is empty).
  • partial: false means a complete result.

In flows requiring high accuracy, treat results with partial: true as "may be incomplete" and check which page is affected via pages[].

Failed job (failed)

  • error is populated, result is always null.
  • On transient errors (e.g., a storage write failure), the job is automatically retried a limited number of times in the background; the status only moves to failed once retries are exhausted.
  • failed is permanent — retrying on the client side means re-uploading the document (POST /v1/documents).

GET /v1/batches?page=&limit= — batch list

Lists your tenant's batches, most recent first. page (default 1) and limit (default 20, capped at 100) are optional query parameters.

{
  "results": [
    {
      "id": "b_5f2a...",
      "external_batch_ref": "PO-2026-001",
      "created_at": "2026-07-01T09:00:00Z",
      "document_count": 12,
      "status_counts": {
        "queued": 0,
        "processing": 2,
        "completed": 9,
        "failed": 1
      },
      "ai_ready_count": 9,
      "total_cost": "42.1150"
    }
  ],
  "page": 1,
  "limit": 20,
  "total": 3
}
  • Batch itself has no status column — the summary above is always derived from its documents[]: status_counts breaks the batch down into the same four states used by GET /v1/jobs/{id} (queued, processing, completed, failed), where processing is every intermediate state (processing/parsing/indexing) collapsed into one bucket.
  • ai_ready_count — number of documents in the batch whose ai_status (see above) is ready.
  • total_cost — sum of all cost so far across the batch's documents; null if nothing has been billed yet.
  • This is the list counterpart of GET /v1/batches/{id} below (which returns one batch's full detail, including its documents[]); both require only a valid API key (no extract entitlement check on the GET).

GET /v1/batches/{id} — batch status

Returns the status of a batch and all documents within it. Batch status is a derived field: if all documents are completed/failed, the batch is completed/failed; if at least one is still processing, it's processing. Each document is listed with the same short representation as GET /v1/jobs/{id} (id, external_item_ref, status); for the full result, GET /v1/jobs/{id} must still be called with the relevant document.id.

Recommended polling strategy

  • Initially check every 2-3 seconds, repeating until you reach a terminal status such as completed/failed.
  • If you get 429, honor the Retry-After header and apply exponential backoff (see the rate limit section in Getting Started & Auth). The status-query endpoint's limit is much more generous than uploads, but still avoid tight-loop polling.
  • If you're receiving Webhooks, use polling only for verification/fallback — both channels will converge to the same final state; if webhook delivery is exhausted (exhausted), the client should already be falling back to this endpoint.