Skip to main content

Create draft purchase order

POST 

/v1/entities/:entity_id/purchase_orders

Creates a draft purchase order. The merchant reviews it in Bookkeep and places the order from there.

Requires the purchase_orders:write scope.

supplier_name is matched against the store's suppliers by exact name, ignoring case. If no supplier or more than one supplier matches, the request returns 422. You can also leave the supplier out and let the merchant choose one later in the Bookkeep app. Line items are optional on create.

A line sent with only a sku is matched to the one product in your store with exactly that SKU, and the response fills in its variant_id, inventory_item_id, product_id and title. A SKU that matches no product, or more than one, returns 422 naming the SKU. A product added in Shopify in the last few minutes may not be in Bookkeep yet: retry later, or send its variant_id or inventory_item_id instead. Each client_line_id must be unique within the request.

destination_location_name is the location's name as it appears in Shopify, or null if Bookkeep cannot find the name. subtotal, tax_amount and total are calculated from the lines. Each returned line has an id, which PATCH takes to change that line, and a variant_supplier_cost.

Send an Idempotency-Key header to make retries safe. A repeat with the same key and the same purchase_order body returns the purchase order already created, with HTTP 200, instead of creating a second one. "The same body" means the same JSON values; the order of keys does not matter. The repeat returns the original even if your store's products have changed since, so a SKU that would no longer match does not fail the retry. Reusing a key with a different body (any changed value, including metadata, or the same value sent as a different type, such as "10" instead of 10) returns 422; use a new key for a new purchase order. A key first used before this check was added replays as it always has, whatever the body.

Request​

Responses​

The Idempotency-Key was already used with the same body, so the purchase order it created is returned instead of a duplicate.