Authentication
All requests are authenticated with a bearer token. Pass your API key in the Authorization header. Request a key from the contact form.
Authorization: Bearer YOUR_API_KEY
Extract endpoint
Send a PDF as multipart form data along with a fields object describing what you want back.
curl https://api.ocrengine.io/v1/extract \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "file=@invoice.pdf" \
-F 'fields={
"invoice_number": "string",
"total_amount": "number",
"due_date": "date",
"line_items": "array"
}'
Defining parameters
The fields object is where you describe the data you want. Each key is the name you'll get back in the response; each value is the expected type. The engine finds and returns only those fields.
| Parameter | Type | Required | Description |
|---|---|---|---|
file | file (PDF) | required | The PDF to read. Native or scanned, up to 50 MB. |
fields | object | required | Map of field name → expected type. |
language | string | optional | Hint such as en or auto (default). |
confidence | boolean | optional | Include a confidence score per field. Default true. |
webhook_url | string | optional | Process asynchronously and POST the result here. |
Field types
Use these values inside the fields object to describe each parameter.
| Type | Returns | Example |
|---|---|---|
string | Text value | "INV-0425" |
number | Numeric value | 1840.00 |
date | ISO-8601 date | "2026-07-15" |
boolean | true / false | true |
array | List of values or rows | [ … ] |
object | Nested key/value group | { … } |
Response
You get back a JSON object containing exactly the parameters you defined. When confidence is enabled, each field is paired with a score between 0 and 1.
{
"status": "completed",
"data": {
"invoice_number": "INV-0425",
"total_amount": 1840.00,
"due_date": "2026-07-15",
"line_items": [
{ "description": "Design retainer", "amount": 1500.00 },
{ "description": "Hosting", "amount": 340.00 }
]
},
"confidence": {
"invoice_number": 0.99,
"total_amount": 0.97,
"due_date": 0.95
}
}
Errors
The API uses conventional HTTP status codes. Error responses include a machine-readable code and a human-readable message.
| Status | Code | Meaning |
|---|---|---|
400 | invalid_request | Malformed fields object or missing file. |
401 | unauthorized | Missing or invalid API key. |
413 | file_too_large | PDF exceeds the 50 MB limit. |
422 | extraction_failed | Document could not be read. |
429 | rate_limited | Too many requests — slow down or contact us. |
Need something not covered here? Reach out and we'll help.