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.
orders:writeGrant this scope to your token under Settings → Developer → Personal Access Tokens.
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 FKnullOnDeleteclearedsales_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
- 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.