Update a purchase order
const url = 'https://apibase.ecomweb.app/api/v1/stores/example/purchase-orders/1';const options = { method: 'PUT', headers: {'x-api-key': '<x-api-key>', 'Content-Type': 'application/json'}, body: '{"supplier_id":1,"location_id":1,"reference_number":"example","supplier_note":"example","payment_terms":"none","expected_arrival_at":"example","carrier":"example","tracking_number":"example","tags":["example"],"shipping_cost":"example","other_costs":"example","lines":[{"id":1,"variant_id":1,"supplier_sku":"example","qty_ordered":1,"unit_cost":"example","tax_rate":"0"}]}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request PUT \ --url https://apibase.ecomweb.app/api/v1/stores/example/purchase-orders/1 \ --header 'Content-Type: application/json' \ --header 'x-api-key: <x-api-key>' \ --data '{ "supplier_id": 1, "location_id": 1, "reference_number": "example", "supplier_note": "example", "payment_terms": "none", "expected_arrival_at": "example", "carrier": "example", "tracking_number": "example", "tags": [ "example" ], "shipping_cost": "example", "other_costs": "example", "lines": [ { "id": 1, "variant_id": 1, "supplier_sku": "example", "qty_ordered": 1, "unit_cost": "example", "tax_rate": "0" } ] }'Changes the fields you send and returns the order. When you send lines, they replace the order’s line set: include an existing line’s id to keep it, and omit a line to remove it. Once an order is received, closed or cancelled, only supplier_note and tags can change. The destination location cannot change after the order is placed, and a line quantity cannot drop below the units already received or rejected; these cases answer 409 with the code PURCHASE_ORDER_READ_ONLY, PURCHASE_ORDER_DESTINATION_LOCKED or PURCHASE_ORDER_QUANTITY_BELOW_SETTLED.
Required scopes: write:purchase_orders
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”The purchase order ID.
The store’s ref, as returned by GET /stores.
Request Bodyrequired
Section titled “Request Bodyrequired”object
ID of the supplier. Required before the order can be placed.
ID of the inventory location that receives the goods. Required before the order can be placed.
Your own reference number for the order.
A note shown to the supplier on the order.
Payment terms agreed with the supplier.
When the delivery is expected, as an ISO 8601 timestamp.
Carrier delivering the order.
Carrier tracking number.
Tags for the order, up to 40 of at most 40 characters each.
Shipping cost charged by the supplier, as a decimal with at most 2 decimals.
Other costs, such as customs or handling, as a decimal with at most 2 decimals.
The lines of the order, up to 500. On an update, the lines you send replace the existing ones.
object
Existing line id. Omit to add a line
Required on a new line. Omit it on an existing line (with id) to keep that line’s variant and snapshot, which is the only way to edit a purchase order carrying a deleted variant
The supplier’s own SKU for the item.
Units to order, from 1 to 1,000,000.
Cost per unit, before tax, as a decimal with at most 4 decimals
Percent, 0 to 100, with at most 2 decimals
Responses
Section titled “Responses”object
Status: draft, ordered, partially_received, received, closed or cancelled.
The supplier, or null while none is chosen.
object
Supplier ID.
Supplier name.
Supplier email address, or null.
True when the supplier has been archived.
The inventory location the order delivers to, or null while none is chosen.
object
Location ID.
Location name.
Payment terms agreed with the supplier.
The lines of the order.
object
Line ID.
ID of the ordered variant, or null once the variant was deleted.
ID of the ordered product, or null once the product was deleted.
Product name as it was when the line was added. Kept after the product is deleted.
Variant title as it was when the line was added, or null.
SKU as it was when the line was added, or null.
Current image URL of the product, or null when it has none or the variant was deleted.
The supplier’s own SKU for the item, or null.
Units ordered.
Units received and accepted into stock.
Units received and rejected. They never enter stock.
Units still expected: ordered minus accepted minus rejected.
Cost per unit, before tax, in the purchase order currency.
Tax rate as a percent, from 0 to 100.
Line cost before tax.
Tax on the line.
Deliveries recorded against the order, oldest first.
object
Who recorded the receipt.
object
ID of the user or API key creator that recorded the receipt, or null.
Display name, or null when it cannot be resolved.
Units accepted and rejected per line.
object
ID of the purchase order line.
Units accepted into stock.
Units rejected.
Receipt ID.
Note recorded with the receipt, or null.
When the receipt was recorded, as an ISO 8601 timestamp.
Purchase order ID.
Sequence number of the purchase order within the store, starting at 1.
Purchase order code, such as PO1042.
Your own reference number, or null.
Note shown to the supplier, or null.
When payment is due, as an ISO 8601 timestamp. Null for terms without a due date and for an order not yet placed.
Currency code of every amount on the order.
When the delivery is expected, as an ISO 8601 timestamp, or null.
Carrier delivering the order, or null.
Carrier tracking number, or null.
Tags on the order.
Sum of the line costs before tax.
Sum of the line taxes.
Shipping cost charged by the supplier.
Other costs, such as customs or handling.
Grand total: subtotal, tax, shipping and other costs.
Total units ordered across all lines.
When the order was placed, as an ISO 8601 timestamp, or null for a draft.
When the order reached a final status (received, closed or cancelled), as an ISO 8601 timestamp, or null.
When the order was last emailed to the supplier, as an ISO 8601 timestamp, or null if it never was.
When the order was created, as an ISO 8601 timestamp.
When the order was last updated, as an ISO 8601 timestamp.
Example
{ "status": "draft", "payment_terms": "none"}The request is malformed or failed validation.
object
The HTTP status code.
What went wrong; validation failures list one message per problem.
The HTTP status text, such as Bad Request.
object
A stable, machine-readable error code.
A human-readable explanation.
Extra context about the error, when there is any.
object
When the error happened, as an ISO 8601 timestamp.
Example generated
{ "statusCode": 1, "message": [ "example" ], "error": "example"}The key is missing, invalid, revoked or expired.
object
The HTTP status code.
What went wrong; validation failures list one message per problem.
The HTTP status text, such as Bad Request.
object
A stable, machine-readable error code.
A human-readable explanation.
Extra context about the error, when there is any.
object
When the error happened, as an ISO 8601 timestamp.
Example generated
{ "statusCode": 1, "message": [ "example" ], "error": "example"}The key may not do this: a missing scope, a readonly key, a publishable key on a Store API route, or a disallowed origin.
object
The HTTP status code.
What went wrong; validation failures list one message per problem.
The HTTP status text, such as Bad Request.
object
A stable, machine-readable error code.
A human-readable explanation.
Extra context about the error, when there is any.
object
When the error happened, as an ISO 8601 timestamp.
Example generated
{ "statusCode": 1, "message": [ "example" ], "error": "example"}The resource does not exist in this store.
object
The HTTP status code.
What went wrong; validation failures list one message per problem.
The HTTP status text, such as Bad Request.
object
A stable, machine-readable error code.
A human-readable explanation.
Extra context about the error, when there is any.
object
When the error happened, as an ISO 8601 timestamp.
Example generated
{ "statusCode": 1, "message": [ "example" ], "error": "example"}The request conflicts with the resource’s current state.
object
The HTTP status code.
What went wrong; validation failures list one message per problem.
The HTTP status text, such as Bad Request.
object
A stable, machine-readable error code.
A human-readable explanation.
Extra context about the error, when there is any.
object
When the error happened, as an ISO 8601 timestamp.
Example generated
{ "statusCode": 1, "message": [ "example" ], "error": "example"}