Reclassify as Vendor Credit
POST/api/purchase-invoices/ocr/:purchase_extraction_id/reclassify-as-credit
Reclassify a Supplier Invoice OCR extraction as a Vendor Credit. Used when a document landed in the supplier-invoice queue but is actually a credit memo — the inverse of POST /api/vendor-credits/ocr/{id}/reclassify-as-invoice.
orders:writeGrant this scope to your token under Settings → Developer → Personal Access Tokens.
Behavior:
- Copies the PDF to a new S3 key under ocr/vendor-credits/ (the original file is left in place for the rejected record's audit trail)
- Creates a new VendorCreditOcrExtraction carrying over supplier_id, source, source email metadata (source_email_from, source_email_forwarded_from, source_email_subject, source_email_recipient, source_message_id), and the stored Azure raw_response
- Marks the original PurchaseInvoiceOcrExtraction as 'rejected' with an error_message referencing the new extraction ID
- If a stored Azure raw_response exists, the vendor credit pipeline re-processes it synchronously (no new Azure call, no extra cost). Otherwise a Scan Credit Memo job is dispatched to re-analyze the PDF.
Only extractions in pending_review, duplicate_detected, or failed status can be reclassified.
Errors:
- 422 if the extraction is in 'confirmed' status
- 422 if the extraction status is not reclassifiable, or the original file is no longer available
The frontend should direct the user to the vendor credit OCR review page for the returned vendor_credit_extraction_id.
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.