Update draft purchase order line items
PATCH/v1/entities/:entity_id/purchase_orders/:uuid
Adds, updates, or removes line items on a draft purchase order, and sets its lifecycle dates.
Requires the purchase_orders:write scope.
The only keys accepted under purchase_order are line_items_attributes,
order_placed_date, order_shipped_date and order_cancelled_date. Any other key,
including currency, destination_location_id, supplier_name, metadata, note and
tags, returns 422; the merchant changes those in the Bookkeep app. PATCH works only while
status is draft. Once the merchant marks the purchase order as ordered, PATCH returns
422.
Include id on a line to update it, omit id to add a new line, and set _destroy: true on
a line to remove it. The id comes from the line items of an earlier response, including
include=line_items on the read endpoints. An id that is not a line of this purchase
order returns 422. A line sent without id but carrying a client_line_id that already
exists on this purchase order updates that existing line rather than adding one, so reuse a
client_line_id only when you mean to update. Two lines in one request with the same
client_line_id return 422. A new line sent with only a sku is matched to a product the
same way as on create, and a SKU that matches no product, or more than one, returns 422.
Removing a line whose stock has already been received is refused with 422.
When lines change, subtotal, tax_amount and total are calculated again from the
lines.
Request
Responses
- 200
- 400
- 401
- 403
- 404
- 413
- 422
- 429
- 504
Purchase order updated.
changed_by is missing or malformed, the body isn't valid JSON, or it has no purchase_order object at the top level.
The Authorization header is missing, is not HTTP Basic, or does not carry a valid API key. Create and manage keys under Settings → API keys in the Bookkeep section of the Bookkeep app.
The key does not hold purchase_orders:write, or the key's store is not linked to {entity_id}.
No purchase order with that uuid for the key's store, or it has been deleted.
Request body exceeds the 1 MB limit.
Returned when the purchase order isn't in draft status, a forbidden top-level key was sent, a line id is not on this purchase order, two lines share a client_line_id, a sku matches no product or several, or a line item failed validation. The status check returns a single error string; the other failures return an errors array. Handle both shapes.
Rate limit reached. The inventory endpoints share one limit of 60 requests per minute per source IP address, counted across Purchase Orders, Suppliers, Receipts and Bills. The count resets at the start of each minute. No Retry-After header is sent. The body is JSON only when the request sends Accept: application/json; otherwise it is an HTML page.
The service did not respond in time. The update may or may not have been applied. Fetch the purchase order before you retry.