Change a purchase order’s line items

Stable throughout v1

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.

PATCH/purchase-orders/{id}/lines
Base URLhttps://api.meetorderpilot.com/connect/v1
Stable throughout v1

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.
Idempotency-Key requiredRetry with the same key and body to get the original response without repeating the change. The response includes Idempotent-Replayed: true. Responses are saved for 24 hours.

Headers

AuthorizationheaderRequired

Bearer and your key, opk_….

Idempotency-KeyheaderRequired

Up to 100 characters (letters, digits, - _ : .). Kept for 24 hours.

Content-Typeheader

application/json. A body is at most 256 KB.

Parameters

idpath · stringRequired

The purchase order’s id.

Body

JSON
add_linesarray of objectOptional

Order lines and stock lines to add (kind order_line or stock).

category_idstringOptional

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.

category_slugstringOptional

new_product: the category’s slug, from GET /categories.

component_keystringOptional

order_line: an option’s key from the line’s PO components; left out for the product itself.

item_labelstringOptional

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.

kindstringOptional

Any casing. Default order_line.

One of order_line, stock, new_product, template.

pricenumberOptional

Unit cost, at most 2 decimals. Needs “Enter costs and charges”; otherwise an order line takes its own cost and any other line 0.

quantityintegerRequired

Units to buy, a whole number above 0.

retail_pricenumberOptional

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.

save_as_templatebooleanOptional

new_product: also make a product template of it, to quote it again.

selectionsarray of objectOptional

template: the options chosen, each by its field_id from the template’s options in GET /product-templates/{id}.

definition_idstringOptional

The same id as field_id, by its first name. Send one of them.

field_idstringOptional

The option: its field_id from GET /product-templates/{id}. Send this or definition_id.

option_idstringOptional

A dropdown’s value: its option_id from the option’s values.

valuestringOptional

A number or text option’s value.

skustringOptional

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.

source_line_item_idstringOptional

order_line: the order line’s id.

template_idstringOptional

template: an active product template.

titlestringOptional

new_product: the product’s name in Shopify.

variant_idstringOptional

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.

content_versionintegerOptional

The content_version the purchase order was read with, when you don’t send version.

linesarray of objectOptional

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.

idstringRequired
item_labelstring, can be nullOptional

The line’s new Item notes, up to 500 characters; empty or null clears them. Left out: kept.

pricenumberOptional

The line’s new unit cost.

quantityintegerRequired
remove_linesarray of stringOptional

Line ids to take off.

versionstringOptional

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

200

OK: content_version, costs_hidden, id, lines, shipping, subtotal, tax, total_amount, version

202

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.

400

The request isn’t valid (see error.code), or the API version isn’t supported.

401

No valid access token or API key.

402

The store’s subscription isn’t active.

403

Not allowed: the API is off for this store, or the caller lacks the scope or permission.

404

Not found, or not visible to this caller.

405

Wrong method for this path; Allow lists every method the path takes.

408

The request body didn’t arrive in time.

409

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.

413

The request body is too large.

422

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.

426

The app is older than the oldest version still served (error.code CLIENT_TOO_OLD); see error.min_version and error.upgrade_url.

429

Over a rate limit; wait Retry-After seconds.

500

Something went wrong on our side. A write may have partly happened: check the record before retrying it.

503

Busy, switched off, or billing couldn’t be checked; wait Retry-After seconds.

Was this page useful?