Create Draft PO from Order Document
POST/api/purchase-orders/from-document/:id/create-purchase-order
A vendor's order sheet, a photo of it, or a trade-show market-app export becomes a reviewed DRAFT purchase order.
purchase-orders:writeGrant this scope to your token under Settings → Developer → Personal Access Tokens.
Authentication: Requires Bearer token. Permission: purchase_orders.create. Token scope: purchase-orders:write.
Creates a DRAFT purchase order (origin: document) from the reviewed lines and marks the extraction confirmed. The vendor's order number is recorded in the PO's internal notes. With remember_vendor_skus (default true), each kept line's vendor SKU is saved on the supplier product when it has none and no other product of the supplier holds it, so the next sheet matches on SKU. A second create from the same document is refused with 422.
Body:
- supplier_id (required)
- destination_warehouse_id (optional; defaults to the upload's, then the purchasing default warehouse)
- currency_code (optional; defaults to the document's, then the supplier's pricing-tier currency)
- vendor_order_number, purchase_order_date, estimated_delivery_date (optional)
- remember_vendor_skus (optional, boolean)
- lines (required, 1–2000): product_id (required), quantity (> 0), unit_cost (>= 0), line_id (the extracted line it came from), description (optional)
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 — no record with the given identifier (or the route does not exist). Verify the ID before retrying.
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.