Invoice OCR
Automate your Accounts Payable (AP) and expense workflows with our intelligent Invoice OCR API. Unlike traditional templates, our AI understands the semantic structure of documents, allowing it to extract line items, tax breakdowns, and vendor details from any invoice layout. Perfect for ERP integrations, bookkeeping software, and receipt scanning apps.
Endpoint
POSThttps://api.structocr.com/v1/invoiceRequest Parameters
Note: Currently supports image inputs (JPG, PNG). For multi-page PDFs, we recommend converting the first page to an image before sending.
| Parameter | In | Required | Description |
|---|---|---|---|
| x-api-key | Header | Required | Your unique API key generated from the dashboard. |
| Content-Type | Header | Required | Must be set to application/json. |
| img | Body (JSON) | Required | The Base64 encoded string of the invoice/receipt image.
|
Response Schema
The API returns a nested JSON object designed for accounting systems. Fields are grouped by context (`merchant`, `customer`, `financials`, `line_items`).
| Field | Description |
|---|---|
| Root Metadata | |
| type | Document type, typically returns 'invoice' or 'receipt'. |
| invoice_number | Unique identifier/reference number of the document. |
| date | Invoice issue date (YYYY-MM-DD). |
| due_date | Payment due date (YYYY-MM-DD), helpful for cash flow management. |
| currency | ISO 4217 currency code (e.g., 'USD', 'EUR'). |
| Merchant (Vendor) | |
| merchant.name | Name of the supplier or vendor. |
| merchant.tax_id | Tax registration number (VAT, GST, EIN, ABN). |
| merchant.iban | International Bank Account Number (Critical for EU/UK invoices). |
| Financials | |
| financials.total_amount | The final total amount due (including tax). |
| financials.tax_amount | Total tax amount extracted from the summary. |
| financials.subtotal | Net amount before tax. |
| Line Items (Array) | |
| line_items[].description | Description of the product or service. |
| line_items[].quantity | Count or hours. |
| line_items[].unit_price | Price per unit. |
| line_items[].amount | Line total (Quantity * Unit Price). |
Code Examples
Request Implementation
curl -X POST https://api.structocr.com/v1/invoice \
-H "Content-Type: application/json" \
-H "x-api-key: YOUR_API_KEY" \
-d '{
"img": "data:image/jpeg;base64,/9j/4AAQSkZJRg..."
}'Success Response (200 OK)
{
"success": true,
"data": {
"type": "invoice",
"invoice_number": "INV-2026-001",
"date": "2026-01-15",
"due_date": "2026-02-15",
"currency": "USD",
"merchant": {
"name": "AWS Web Services",
"address": "410 Terry Ave N, Seattle, WA",
"tax_id": "EIN-12-3456789",
"iban": null
},
"customer": {
"name": "Acme Corp Inc.",
"tax_id": "987654321"
},
"financials": {
"subtotal": 100,
"tax_amount": 10,
"total_amount": 110
},
"line_items": [
{
"description": "EC2 Instance Usage",
"quantity": 1,
"unit_price": 80,
"amount": 80
},
{
"description": "S3 Storage",
"quantity": 1,
"unit_price": 20,
"amount": 20
}
]
}
}Error Responses
400 Bad Request
{
"status": 400,
"code": "INVALID_REQUEST_FORMAT",
// or "INVALID_JSON", "INVALID_BASE64_FORMAT"
"message":"The image data in 'img' field is malformed. Please check for illegal characters (spaces, newlines) or incorrect Base64 encoding."
}402 Payment Required
Each successful invoice extraction costs 3 credits.
{
"success": false,
"error": "INSUFFICIENT_CREDITS",
"message": "Your account balance is insufficient to complete this operation."
}422 Unprocessable Entity
Returned if the AI safety filter blocks the content.
{
"success": false,
"error": "CONTENT_POLICY_VIOLATION",
"message": "The document content could not be processed due to safety policies."
}503 Service Unavailable
{
"success": false,
"error": "SYSTEM_BUSY",
"message": "StructOCR is currently processing a high volume of requests..."
}Status Code Definitions
| Code | Error Code | Description |
|---|---|---|
| 200 | SUCCESS | Recognition success |
| 400 | INVALID_REQUEST_FORMAT | Invalid payload or corrupted Base64. Ensure the image string has no whitespace, newlines, or illegal characters. |
| 402 | INSUFFICIENT_CREDITS | Insufficient credits (Cost: 3/req) |
| 413 | FILE_TOO_LARGE | Decoded image exceeds 4.5MB |
| 422 | CONTENT_POLICY_VIOLATION | AI safety/policy block |
| 503 | SYSTEM_BUSY | API Rate limit reached |