curl --request POST \
--url https://api.usepatchwork.co/v1/extract \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"document": {
"media_type": "application/pdf",
"content": "<base64>"
}
}
'{
"status": "success",
"data": {
"result": "extracted",
"document": {
"media_type": "<string>",
"pages": 123
},
"template": "<string>",
"match": {
"name": "<string>",
"confidence": "high",
"alternatives": [
{
"template": "<string>",
"name": "<string>",
"confidence": "high"
}
]
},
"fields": {},
"missing": [
"<string>"
],
"extracted_at": "2023-11-07T05:31:56Z"
}
}{
"status": "success",
"data": {
"id": "<string>",
"product": "<string>",
"state": "pending"
}
}{
"status": "error",
"error": {
"message": "<string>",
"code": "<string>",
"details": "<unknown>"
}
}{
"status": "error",
"error": {
"message": "<string>",
"code": "<string>",
"details": "<unknown>"
}
}{
"status": "error",
"error": {
"message": "<string>",
"code": "<string>",
"details": "<unknown>"
}
}{
"status": "error",
"error": {
"message": "<string>",
"code": "<string>",
"details": "<unknown>"
}
}Extract structured data from a document
Send a document and a schema; get typed fields back. Asynchronous: returns 202 with a request id by default. Pass ?wait to hold for a quick result.
Don’t know the document type? Send template: "auto" and we match it against the schema types in your workspace, then fill the one that fits.
Charged per page: 4 credits a page to extract, plus 1 credit a page when you use auto. An auto call that matches nothing is charged the 1 credit a page for the read. Unreadable or encrypted documents and the 202 accept are not billed.
curl --request POST \
--url https://api.usepatchwork.co/v1/extract \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"document": {
"media_type": "application/pdf",
"content": "<base64>"
}
}
'{
"status": "success",
"data": {
"result": "extracted",
"document": {
"media_type": "<string>",
"pages": 123
},
"template": "<string>",
"match": {
"name": "<string>",
"confidence": "high",
"alternatives": [
{
"template": "<string>",
"name": "<string>",
"confidence": "high"
}
]
},
"fields": {},
"missing": [
"<string>"
],
"extracted_at": "2023-11-07T05:31:56Z"
}
}{
"status": "success",
"data": {
"id": "<string>",
"product": "<string>",
"state": "pending"
}
}{
"status": "error",
"error": {
"message": "<string>",
"code": "<string>",
"details": "<unknown>"
}
}{
"status": "error",
"error": {
"message": "<string>",
"code": "<string>",
"details": "<unknown>"
}
}{
"status": "error",
"error": {
"message": "<string>",
"code": "<string>",
"details": "<unknown>"
}
}{
"status": "error",
"error": {
"message": "<string>",
"code": "<string>",
"details": "<unknown>"
}
}Authorizations
Identify accepts a workspace API key (sk_…). Loom accepts either a short-lived session token (direct) or a workspace API key (relay).
Headers
Makes this POST safe to retry. The first call does the work and its response is stored; a retry with the same key returns that stored response with Idempotency-Replayed: true, without charging again. Same key with a different body is rejected. Keys expire after 24 hours.
255Query Parameters
Omit for an immediate 202. true/1 holds until done or the 25s deadline; a number holds min(n, 25s). Finished within the hold → 200 with the result; otherwise 202.
Body
Pass template, schema, or both — an inline schema overlays the type.
Show child attributes
Show child attributes
A saved schema type id (sch_…) to fill against, or auto to let us pick. With auto we read the document, match it against the schema types in your workspace, fill the one that fits, and return the match and our confidence. Nothing fits → result is unmatched.
An inline restricted JSON Schema. Sent alone, or as an overlay merged onto template.