Clone Lines from Sales Order
POST/api/sales-orders/ocr/:extraction_id/clone-from
Clone confirmed lines from a prior sales order into this extraction's lines_data.
Used when the extraction's customer history (or LLM analysis on email-body extractions) suggests this PO is a repeat order — the reviewer can pull lines from a previous confirmed sales order in one click instead of editing line by line.
Request body:
sales_order_id(required, integer) — the source sales order to clone from. Must belong to the same customer as the extraction (when extraction has a customer_id set).
Behavior:
- Replaces (or merges with)
lines_dataon the extraction with one entry per source order line. - Each cloned line records the matched product (sku, name, average cost) and a unit price computed as
amount / quantity. - Lines whose product is archived or missing are still copied but flagged
match_status: unmatchedso the reviewer must reassign. - Sets
clone_of_sales_order_idon the extraction so the UI can show the "cloned from" banner.
Returns the updated SalesOrderOcrExtraction resource (with cloneOfSalesOrder eager-loaded).
Errors:
- 422 — Confirmed extractions cannot be modified (only when the extraction is locked:
status='confirmed'ANDsales_order_idis non-null. Orphaned confirmed extractions — where the linked sales order was deleted and the FKnullOnDelete()clearedsales_order_id— are treated as unlocked and can be re-cloned). - 422 — Source order belongs to a different customer than the extraction.
- 404 — Source sales order not found.
- 422 — Validation:
sales_order_idis required and must exist insales_orders.
Request
Responses
- 200
Successful response