Reclassify Document Type
POST/api/document-inbox/customer_po/:extraction_id/reclassify
Reclassify an inbox extraction as a different document type — the user-facing escape hatch when automatic type detection got it wrong. Copies the original file into the target pipeline, creates a new extraction there, and rejects the source extraction with a back-reference.
Path params:
type(required) — current document type: one ofcustomer_po,supplier_invoice,vendor_credit, orlanded_cost_invoice(regex-constrained at the route level; unknown values return 404)id(required, integer) — extraction ID
Request body:
target_type(required, string, in:customer_po,supplier_invoice,vendor_credit,landed_cost_invoice) — the type to reclassify the document as (returns 422 validation error otherwise)
Behavior:
- Source extraction must be in a reclassifiable status:
pending_review,duplicate_detected, orfailed - Three pairwise conversions are delegated to their existing dedicated flows (which can reuse the stored Azure
raw_responseto avoid a second OCR charge): customer_po → supplier_invoice, supplier_invoice → vendor_credit, and vendor_credit → supplier_invoice - All other source/target pairs use the generic flow: the original file is copied from the source pipeline's storage into the target pipeline's staging directory, a new extraction row is created in the target table, and the target's OCR job is dispatched. When the source already has a stored
raw_responseand the target is supplier_invoice or vendor_credit, the result is parsed synchronously instead of dispatching a job - The source extraction is marked
rejectedwith error_message "Reclassified as {label} (extraction #{id})." inside the same transaction
Response 200:
{
"message": "Document reclassified.",
"data": { "type": "supplier_invoice", "id": 88 }
}
data.type/data.id identify the NEW extraction so the frontend can route straight to the correct OCR review page.
Errors (422, { "error": "..." }):
- "The document is already classified as a {label}." — target_type equals the current type
- "Only extractions pending review can be reclassified." — source status not in pending_review/duplicate_detected/failed
- "Original OCR file is no longer available." — source file_path is empty
- Standard Laravel validation error when
target_typeis missing or not one of the four allowed values
Response 404: route constraint blocks unknown type path values; unknown id returns 404 via findOrFail.
Request
Responses
- 200
- 401
- 403
- 404
- 422
- 429
Successful response
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.
Validation failed — the body is a field → messages map (Laravel shape) or the platform envelope with a stable machine-readable code. Fix the payload and resubmit.
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.