Create a purchase order

Stable throughout v1

Creates a draft purchase order for one vendor from customer order lines or for stock, using Shopify products by SKU, template configurations or new products, which are created in Shopify when the purchase order is created (lines[].kind). Stock orders require store_location_id. API keys cannot enter costs: order lines use their recorded costs and other lines use 0. Send the purchase order with POST /purchase-orders/{id}/send.

POST/purchase-orders
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.

Body

JSON
delivery_addressstringOptional

Where it is delivered, as printed on the purchase order: to a location, its address from GET /locations; to a warehouse, its address from GET /warehouses; to the customer, their address. Left out on a store delivery: the warehouse’s address (warehouse_id), else the location’s (store_location_id). Required for a customer or dropship delivery.

delivery_typestringOptional

Left out: store.

One of store, customer, dropship.

hide_pricingbooleanOptional

Leave prices off the copy the vendor gets.

internal_notesstringOptional
linesarray of objectRequired

At most 300 lines, each a thing to buy (kind) and a quantity; an order line no more than it still needs.

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.

notesstringOptional
requested_delivery_datestring (date-time)Optional
shippingnumberOptional

Needs “Enter costs and charges”; otherwise 0.

side_labelstringOptional
store_location_idstringOptional

The Shopify location that receives the stock: an id from GET /locations (one of the caller’s). Required for a stock purchase order (and to take a store delivery’s address from it), unless the caller can use only one location: then that one.

taxnumberOptional

Needs “Enter costs and charges”; otherwise 0.

vendorstringOptional

The vendor by its name (its display_name in GET /vendors; case and spacing don’t matter), instead of vendor_id. A name two vendors answer to is refused, naming both (error.matches); none is 404.

vendor_idstringOptional

Every line’s vendor must be this one: an id from GET /vendors. Send this or vendor.

vendor_notesstringOptional
warehouse_idstringOptional

A store delivery to a warehouse: an id from GET /warehouses. Left out: delivered to the location itself.

Returns

201

Created: content_version, costs_hidden, delivery_address, delivery_type, id, lines, number, shipping, status, store_location_id and more

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?