Trace by Sales Orders
GET/api/manufacturing/lot-genealogy/by-sales-orders
Recall (reverse) — backward "made-from" forest for one or more sales orders. For every finished-good batch shipped on each order, traces upstream to the raw-ingredient lots (and their vendors) that went into it. Drives the genealogy page's "trace by sales order(s)" mode and the Sales Orders list view's "Trace Genealogy (Backward)" bulk action. Authentication: requires a Bearer token (PAT).
manufacturing:readGrant this scope to your token under Settings → Developer → Personal Access Tokens.
Accepts sales_order_ids as a comma-separated string or an array. Orders with no shipped finished goods are silently skipped.
Returns:
data.roots— one synthetic sales-order root node per traced order (entity_typesales_order, carryingreference,customer_name, andlink_parent_id). Each root'schildrenare the backward traces of the finished-good batches that order shipped; each finished-good node'sconsumed_quantityis the qty of that batch shipped on the order, and its descendants are the component lots withsupplier_nameon purchased raw-ingredient layers.summary—order_count(ids supplied),traced_order_count(roots returned),finished_good_count(finished-good batches traced).
Errors:
422when no ids are supplied, or more than 500 are.404when none of the supplied orders have shipped finished goods to trace.
The response also embeds affected_lots (rows + summary) — the deduplicated implicated-lots/suppliers list — computed from the same forest build so the UI needn't fetch/rebuild it separately.
requested_orders lists every selected order (traced or not) with its number, so the UI can label each selected-order chip — the SO list endpoint can't resolve multiple ids.
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
Response Headers
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.