Apply OCR Extraction to Invoice
POST/api/purchase-invoices/:purchaseInvoice/ocr-apply
Apply reviewed OCR extraction results to a purchase invoice. Synchronous — the invoice is updated immediately.
purchase-orders:writeGrant this scope to your token under Settings → Developer → Personal Access Tokens.
Body fields:
extraction_id(integer, optional) — the extraction whose unmatched-line decisions should be saved.header.supplier_invoice_number(string, optional, max 255) andheader.purchase_invoice_date(date, optional) — update the invoice header. Null values are ignored (fields cannot be blanked here).lines(array, required, min 1) — the resulting invoice lines. Each line needsquantity_invoiced(numeric, required, min 0), optionalunit_price(numeric, min 0), and eitherpurchase_order_line_id(existing PO line) orfinancial_line_id(existing cost line).unmatched_lines(array, optional) — snapshot of unmatched document lines; setignored: trueon lines to exclude. Saved onto the extraction for future reads.
Line replacement semantics: entries with purchase_order_line_id fully sync the invoice's product lines — invoice lines whose PO line is not in the payload are deleted, new ones are created, and existing ones are updated. Entries with financial_line_id update the invoice's cost lines, or copy the PO's planned cost line onto the invoice if not present (the PO's own line is never modified).
After applying, the invoice's approval status is re-evaluated: price or quantity variances against the PO (or invoicing more than was received) set pending_approval; otherwise auto_approved.
Archived invoices return 422. Requires the purchase-orders:write token scope.
Request
Responses
- 200
- 401
- 403
- 404
- 422
- 429
OK
Response Headers
Unauthenticated — the bearer token is missing, revoked, expired, or malformed. Never retry automatically; fix the credential. See the Errors guide.
Forbidden — the token lacks a required scope, the endpoint is not available to API tokens, or the user behind the token lacks the permission. A human must adjust the token scopes or user permissions; do not retry.
Not found — no record with the given identifier (or the route does not exist). Verify the ID before retrying.
Unprocessable Entity
Response Headers
Rate limited — platform limit is 1,000 requests/min; individual tokens may carry lower limits. Honor the Retry-After header before retrying. See the Rate Limits guide.