Change a purchase order’s line items
Updates quantities with lines, removes items with remove_lines and adds order or stock items with add_lines, using kind from POST /purchase-orders. Send the last-read content_version; later changes return 409 PURCHASE_ORDER_STALE. Received, rejected and finalized purchase orders cannot be edited; a line with receipts cannot be removed or reduced below the received quantity. API keys cannot enter costs: existing prices stay, new order lines use their recorded costs and other new lines use 0.
Required access
- API key
- Manage purchase orderspermission
- Request limit
- Counts as 5 requests. Each key has a capacity of 15, restored at 0.6 a second.
Idempotent-Replayed: true. Responses are saved for 24 hours.Headers
Bearer and your key, opk_….
Up to 100 characters (letters, digits, - _ : .). Kept for 24 hours.
application/json. A body is at most 256 KB.
Parameters
The purchase order’s id.
Body
JSONOrder lines and stock lines to add (kind order_line or stock).
new_product: the category’s id, from GET /categories or POST /categories; its name becomes the Shopify product’s type. Send this or category_slug, not both. Left out, the product has no type, and the line can’t be given one later.
new_product: the category’s slug, from GET /categories.
order_line: an option’s key from the line’s PO components; left out for the product itself.
The line’s Item notes, as the workbench and the edit page take them, shown with the line on the purchase order’s page. Up to 500 characters.
Any casing. Default order_line.
One of order_line, stock, new_product, template.
Unit cost, at most 2 decimals. Needs “Enter costs and charges”; otherwise an order line takes its own cost and any other line 0.
Units to buy, a whole number above 0.
new_product: its selling price. Needs Edit catalog prices. Left out, the product is made at 0 and the line can’t change it later: set it in Shopify, or send a products import draft (POST /imports) for the merchant to sign off.
new_product: also make a product template of it, to quote it again.
template: the options chosen, each by its field_id from the template’s options in GET /product-templates/{id}.
The same id as field_id, by its first name. Send one of them.
The option: its field_id from GET /product-templates/{id}. Send this or definition_id.
A dropdown’s value: its option_id from the option’s values.
A number or text option’s value.
stock: the SKU of the Shopify variant (exact, any case); send this, variant_id, or both. new_product, template: the new item’s SKU. A new_product SKU that a Shopify product has already is 409 SKU_EXISTS: send a stock line with it.
order_line: the order line’s id.
template: an active product template.
new_product: the product’s name in Shopify.
stock: the Shopify variant (an id or gid, from GET /products/{id}): alone for a product with no SKU, or with sku to pick one when several have it.
The content_version the purchase order was read with, when you don’t send version.
Lines that change: { id, quantity, price?, item_label? }, the id from its lines. price (the unit cost, at most 2 decimals) needs “Enter costs and charges” (a key: Enter and correct costs) and is ignored without it. A New product line’s name, SKU, category and retail price aren’t changed here, nor on the admin’s edit page.
The line’s new Item notes, up to 500 characters; empty or null clears them. Left out: kept.
The line’s new unit cost.
Line ids to take off.
The version of the last answer about this record (its read, its list row, its costs or the last change), sent back exactly as it is: no read needed first. A change made since is refused (409) with the current version and what changed. Send this or content_version.
Returns
OK: content_version, costs_hidden, id, lines, shipping, subtotal, tax, total_amount, version
Accepted: the write is done, but its record couldn’t be read back. Don’t send it again: read it with `read`.: charge_id, content_version, done, id, message, number, payment_id, read, refund, reopened and more
Errors
Errors use { "error": { "code", "message" } }. Use code to handle the error. View all error codes.
The request isn’t valid (see error.code), or the API version isn’t supported.
No valid access token or API key.
The store’s subscription isn’t active.
Not allowed: the API is off for this store, or the caller lacks the scope or permission.
Not found, or not visible to this caller.
Wrong method for this path; Allow lists every method the path takes.
The request body didn’t arrive in time.
The same Idempotency-Key is still being processed (REQUEST_IN_PROGRESS), its outcome is unknown (OUTCOME_UNKNOWN: check the record), or the record changed since it was read.
The request body is too large.
The request is valid JSON but can’t be done (a rule of the store refuses it), or the Idempotency-Key was used with a different body.
The app is older than the oldest version still served (error.code CLIENT_TOO_OLD); see error.min_version and error.upgrade_url.
Over a rate limit; wait Retry-After seconds.
Something went wrong on our side. A write may have partly happened: check the record before retrying it.
Busy, switched off, or billing couldn’t be checked; wait Retry-After seconds.