Extract structured data from documents
Runs JSON-Schema extraction with per-field citations over one or more files.
Send exactly one of file or files, and at most one output shape:
schema— an inline JSON Schema object, written in the extraction schema dialect.action— a saved action by id or slug. Inline config fields (instructions,unit,judge, …) are merged over the saved action's, so one saved action can be refined per call.- neither — the shape is inferred from the documents themselves. Add
hintsto steer it in prose. The finished run reports what was inferred asconfig.schema, ready to save as an action for the next run.
What you get back. output.value holds the extracted object for a single-document run, output.documents[] one entry per file. Send citations: true to ground the result: output.citations then maps each extracted field to where it came from — fileId plus page and bounding box, or timecodeStart/timecodeEnd for audio, or notFound: true for a value the documents do not contain.
Add ?output=inline to include each source file's parsed markdown and json alongside the extracted value. Signed markdownUrl / jsonUrl fields remain available; when the combined parsed source exceeds 1 MiB, the response falls back to those URLs only.
{
"file": { "url": "https://www.irs.gov/pub/irs-pdf/fw9.pdf" },
"schema": {
"type": "object",
"properties": {
"business_name": { "type": ["string", "null"] },
"tax_classification": { "type": ["string", "null"] }
}
}
}
Waiting for the result
Sync by default: the call holds open until the run finishes, up to ?wait= seconds (default 60, max 120, 0 returns immediately).
| Outcome | Response |
|---|---|
| Finished inside the window | 200 with the full run |
| Still running at the cap | 202 with {object, id, status, statusUrl} |
Note: The
202is a graceful degrade, never an error — poll the run or wait for a webhook. Replaying anidempotency-keyreturns the original run alongside anidempotent-replay: trueresponse header.
Learn more: Extraction guide · Schema dialect
https://api.cloudraker.com/v1/spaces/{spaceId}/extractTry it
Authorization
Path parameters
Query parameters
- waitoptionalinteger
How many seconds to hold the request open waiting for the run to finish.
Finishing inside the window returns
200with the full run; running past it returns202with astatusUrlto poll. Send0to skip waiting entirely and always get the202.maximum: 120 · minimum: 0 · default: 60
Request body JSON required
- schemaoptionalmap ofunknown
The shape to extract, as a JSON Schema object. Send
actioninstead to use a saved shape, or neither to have one inferred.The root must be
{"type": "object"}. The dialect is deliberately narrow — no$ref,$defs,oneOf,anyOf,allOf,constorpattern— with a maximum nesting depth of 5 and a 64 KB size limit. Make primitives nullable ({"type": ["string", "null"]}) so a missing value reads asnullrather than a hallucination. - actionoptionalstring
A saved action to run, by id or slug. An alternative to
schema.The action carries the output shape and any saved settings. Config you send inline on the same call is merged over it, so
actionplusinstructionsrefines a saved action for one run without redefining it.minLength: 1 - hintsoptionalstring
Prose guidance for schema inference — only valid when you send neither
schemanoraction.Say what the documents are and what matters in them ("freight bills of lading; I care about the load number, the shipper and the total") and the shape is inferred from the document itself. Sending
hintsalongsideschemaoractionis a400: the shape is already decided.maxLength: 2000 - citationsoptionalboolean
Whether to ground each extracted value in the source document. Off by default — grounding is an explicit add-on, so send
citations: trueto ask for it.When on,
output.citationsmaps every extracted field to where it came from —fileIdplus page and bounding box for documents, ortimecodeStart/timecodeEndfor audio. A field the documents simply do not contain comes back as an entry withnotFound: trueand no location. - unitoptionalper_documentoracross_documentsorrows_per_document
What one extraction result covers.
per_document: one result object per file (the default).across_documents: one result object for the whole set. The files are read together as one source, in the order you list them, so a recording split into parts reads as one recording. Audio mixed with documents cannot be read as one source: each file is then extracted on its own and the results are merged.rows_per_document: a list of results per file, for documents that hold repeated records.
- judgeoptionalboolean
Run a second review pass that scores each extracted value against the evidence it cites, adding a
confidence(0–5) and leaving the values themselves alone. It is the only pass that scores: grounding cites without grading, so an unjudged run returns citations with noconfidence. Slower and more thorough; worth it on documents where an error is expensive.The judge audits citations, so it needs
citations: true. It scores cited evidence and never re-extracts, so with grounding off there is nothing for it to audit. Sendingjudge: truewithcitations: falseis a400. When you name anaction, the saved config'scitationssetting counts — a judge on a saved action that does not ground does nothing. - webhookoptional
Where to deliver this run's events, given one of two ways.
{ "url": "…" }— a one-off https endpoint for this run only.{ "id": "whe_…" }— a saved endpoint fromPOST /v1/webhooks. Runs hold the reference, so pausing or re-pointing that endpoint applies to this run too.
Deliveries are at-least-once and signed — dedupe on
eventIdand verify againstGET /v1/webhooks/jwks.json. - ttloptionalinteger
How long, in seconds, to keep this run and its files before purging them automatically.
The maximum is 604800 (7 days). The deadline comes back as
expiresAton every read of the run. CallPOST /v1/runs/{id}/keepbefore then to clear the TTL and move the results into a space permanently.E-signature runs are exempt — an envelope waits for its signers however long that takes.
maximum: 604800 · minimum: 1 · default: 86400
Returns
200
The finished run.
- statusqueuedorprocessingorprocessedorfailedorcancelledorexpired+1 morerequired
Where the run is in its life.
Status Meaning queuedAccepted, not started processingWork in flight needs_inputWaiting for an external action, such as an e-signature processedFinished; outputis populatedfailedFinished unsuccessfully cancelledStopped on request expiredTTL elapsed and the data was purged The last four are terminal.
- erroroptionalobject
Why the run failed. Present whenever
statusisfailed, and only then.codeis the stable, snake_case reason (input_unavailable,parse_failed, …);messageis the human-readable detail. Per-file and per-step failures are also reported infiles[].errorand, for a pipeline,steps[].error. - outputoptionalobject
The extracted data. Present once
statusisprocessed.documents[]always has one entry per input file. For a single-document run,value,citationsand any parsed source fields are lifted to the top as aliases ofdocuments[0]so the common case reads without indexing.Parsed source fields are present only when requested with
?output=inline. The signed URLs remain as a fallback;markdownandjsonare omitted when the combined inline source exceeds 1 MiB.
202
Accepted — still running, or awaiting human input.
- statusqueuedorprocessingorprocessedorfailedorcancelledorexpired+1 morerequired
Where the run is in its life.
Status Meaning queuedAccepted, not started processingWork in flight needs_inputWaiting for an external action, such as an e-signature processedFinished; outputis populatedfailedFinished unsuccessfully cancelledStopped on request expiredTTL elapsed and the data was purged The last four are terminal.