Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.docex.dev/llms.txt

Use this file to discover all available pages before exploring further.

Runs

The /v1/runs endpoints are the core of the Docex API. Create a run with an upload ID and prompt, poll for completion, and receive a structured envelope.
The legacy /v1/extractions endpoints redirect to /v1/runs automatically for backward compatibility.

Create a run

POST /v1/runs

Headers

x-api-key
string
required
Your Docex API key.
content-type
string
required
Must be application/json.

Body

uploadId
string
required
The upload ID returned from POST /v1/uploads/presign.
prompt
string
required
Plain-English description of the analysis task. Example: "company name, number, expiry".
outputFormat
string
Either json (default) or text.
schemaId
string
Reference to a built-in registry schema. Use instead of inline schema.
schema
object
Inline custom schema with label, expectedFields, and promptScaffold.
workflow
string
Named workflow policy to apply.
metadata
object
Arbitrary key-value pairs attached to the job record.
confirmCost
boolean
Explicitly confirm a job whose estimated cost exceeds the confirmation threshold.
maxCostUsd
number
Abort the job if the estimated cost exceeds this budget.

Response

{
  "jobId": "job_abc123",
  "status": "queued",
  "uploadId": "ul_def456",
  "prompt": "company name, number, expiry",
  "outputFormat": "json",
  "schemaId": null,
  "estimatedCostUsd": 0.0321,
  "metadata": {}
}

Get a run

GET /v1/runs/:jobId
Poll this endpoint until status is completed or failed.

Response (completed)

{
  "status": "completed",
  "schemaId": null,
  "protocolVersion": "0.1.0",
  "requests": 1,
  "outputFormat": "json",
  "result": {
    "legal_name": "ACME LOGISTICS L.L.C",
    "license_no": "1019388",
    "expires_on": "2026-03-13"
  },
  "usage": {
    "requests": 1,
    "billableUnits": 1,
    "costUsd": 0.0321,
    "priceUsd": 0.0642
  },
  "chargedUsd": 0.0642,
  "confidence": 0.95,
  "metadata": {}
}

Response (failed)

{
  "status": "failed",
  "error": {
    "code": "PROVIDER_ERROR",
    "message": "All providers exhausted",
    "status": 502,
    "retryable": true
  }
}

Verify a run

POST /v1/runs/:jobId/verify
Accept or correct an analysis result for feedback and billing adjustment.

Body

accepted
boolean
Mark the result as accepted.
corrections
object
Key-value pairs of corrected fields.

Code examples

import { createDocex } from "docexdev";

const docex = createDocex({ apiKey, baseUrl });
const result = await docex.run({
  file: "./invoice.pdf",
  prompt: "Extract line items, totals, and vendor details",
});