Skip to main content

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.

Required scope: orders:write

Grant 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

OK

Response Headers
    Content-Type