Receipt OCR API

Automate your expense tracking and reimbursement workflows with our specialized Receipt OCR API. Built to handle the messy reality of physical receipts—including crumpled paper, faded thermal ink, and complex multi-item retail layouts. Instantly extract the merchant name, date, total amount, taxes, and purchased items. Perfect for expense management apps, loyalty programs, and personal finance tracking.


Endpoint

POSThttps://api.structocr.com/v1/receipt

Request Parameters

Note: Receipts are often long and narrow. Ensure the image captures the top (Merchant) and bottom (Total Amount) clearly. We automatically handle perspective distortion and rotation.

ParameterInRequiredDescription
x-api-keyHeaderRequiredYour unique API key generated from the dashboard.
Content-TypeHeaderRequiredMust be set to application/json.
imgBody (JSON)RequiredThe Base64 encoded string of the receipt image.
  • Supports standard Data URI scheme
  • Supports raw Base64 strings
  • Max file size: 4.5MB
  • Formats: JPG, PNG, WebP, PDF
  • Other decoded formats return 415 UNSUPPORTED_FILE_FORMAT.
  • For best response time, compress to under 300 KB before sending — see compression guide

Response Schema

The API returns a clean, structured JSON object containing the essential details required for expense reporting.

The Receipt API has been upgraded; the endpoint remains unchanged. Call /v1/receipt directly. The legacy response_version=1 response is retired; response_version=2 remains accepted for compatibility.

Accuracy: standard is the default (1 credit). Use ?accuracy=enhanced for small print or dense receipts (2 credits; JPG/PNG/WebP only). Enhanced may take longer and does not guarantee accuracy. Both modes return the same fields; no automatic enhanced retry.

The current response keeps extracted rows with unknown fields: item name, quantity and price can be null; known prices are line-total strings. Total and tax can also be null rather than an invented zero.

It includes response_version, status (complete, partial, invalid) and issues (field, code, severity). Issue paths use public zero-based item indices. Partial results can have is_valid=true. Complete means no server validation warnings, not guaranteed OCR accuracy. See the copyable documentation for details.

Try the upgraded Receipt API: replace the API key and Base64 image below. Add ?accuracy=enhanced to the URL for enhanced mode.

curl -X POST 'https://api.structocr.com/v1/receipt' \
  -H 'x-api-key: YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{"img":"YOUR_BASE64_IMAGE"}'
FieldDescription
Metadata & Validation
response_versionAlways 2 for the supported Receipt response.
statusValidation status: complete, partial, or invalid.
issuesField-level validation issues with field, code, and severity.
is_validBoolean indicating if core data (like total_amount) was successfully found.
confidenceExtraction confidence level. Returns 'high', 'medium', or 'low'.
validation_errorFailure or partial-result details; inspect status and issues before using data automatically.
Receipt Details
merchant_nameName of the store, restaurant, or vendor.
dateTransaction date (formatted as YYYY-MM-DD if recognizable).
timeTransaction time (e.g., '14:30' or '02:30 PM').
currencyISO 4217 currency code when supported by receipt evidence; otherwise null.
total_amountThe final total amount paid (number or null).
tax_amountTotal tax or VAT amount applied (number or null).
Line Items (Array)
items[].nameDescription of the purchased product or service.
items[].quantityNumber of units purchased. Unknown quantities are null and the row is preserved.
items[].priceLine total as a string. Unresolved prices are null and the row is preserved.

Code Examples

Request Implementation

curl -X POST https://api.structocr.com/v1/receipt \
  -H "Content-Type: application/json" \
  -H "x-api-key: YOUR_API_KEY" \
  -d '{
    "img": "data:image/jpeg;base64,/9j/4AAQSkZJRg..."
  }'

Success Response (200 OK)

JSON EXAMPLE
{
  "success": true,
  "data": {
    "response_version": 2,
    "is_valid": true,
    "confidence": "high",
    "merchant_name": "Blue Bottle Coffee",
    "date": "2026-04-22",
    "time": "08:45 AM",
    "currency": "USD",
    "total_amount": 14.5,
    "tax_amount": 1.25,
    "items": [
      {
        "name": "Caffe Latte - Large",
        "quantity": 2,
        "price": "11.00"
      },
      {
        "name": "Butter Croissant",
        "quantity": 1,
        "price": "3.50"
      }
    ],
    "status": "complete",
    "issues": [],
    "validation_error": null
  }
}

Live API Test

Live Demo: Receipt scanner

No registration required. Upload a file to test the extraction.

1
Upload
2
Results
↑

Drop files here or click to browse

JPG · PNG · PDF · TIFF  ·  up to 500 files · max 4.5 MB each

No document handy?

No files selected

Error Responses

400 Bad Request - Invalid Input

Returned when JSON is invalid or image data is missing/corrupt.

{
                 "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 - Insufficient Credits

{
                 "status": 402,
                 "code": "INSUFFICIENT_CREDITS",
                 "message": "Your account balance is insufficient to complete this operation. Top up at https://structocr.com/dashboard/billing",
                 "top_up_url": "https://structocr.com/dashboard/billing"
               }

413 Payload Too Large

The Base64 decoded image size exceeds 4.5MB.

{
                 "error": "FILE_TOO_LARGE"
               }

415 Unsupported Media Type

{
                 "error": "INVALID_CONTENT_TYPE_USE_JSON"
               }

422 Unprocessable Entity - Policy Violation

{
                 "status": 422,
                 "code": "CONTENT_POLICY_VIOLATION",
                 "message": "The document content could not be processed due to safety policies."
               }

500 Internal Server Error

{
                 "status": 500,
                 "code": "PROCESSING_ERROR",
                 "message": "An internal error occurred while processing the document..."
               }

503 Service Unavailable - System Busy

{
                 "status": 503,
                 "code": "SYSTEM_BUSY",
                 "message": "StructOCR is currently processing a high volume of requests..."
               }

Status Code Definitions

CodeError CodeDescription
200SUCCESSRecognition success
400INVALID_REQUEST_FORMATInvalid payload or corrupted Base64. Ensure the image string has no whitespace, newlines, or illegal characters.
402INSUFFICIENT_CREDITSInsufficient credits (standard: 1 credit; enhanced: 2 credits)
413FILE_TOO_LARGEDecoded image exceeds 4.5MB
503SYSTEM_BUSYAPI Rate limit reached or upstream AI provider is busy.