Receive units on a purchase order
const url = 'https://apibase.ecomweb.app/api/v1/stores/example/purchase-orders/1/receipts';const options = { method: 'POST', headers: {'x-api-key': '<x-api-key>', 'Content-Type': 'application/json'}, body: '{"lines":[{"line_id":1,"accepted":1,"rejected":1}],"note":"example","idempotency_key":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://apibase.ecomweb.app/api/v1/stores/example/purchase-orders/1/receipts \ --header 'Content-Type: application/json' \ --header 'x-api-key: <x-api-key>' \ --data '{ "lines": [ { "line_id": 1, "accepted": 1, "rejected": 1 } ], "note": "example", "idempotency_key": "example" }'Records a delivery against an ordered or partially_received order. For each line, send the units accepted into stock and the units rejected; accepted units are added to inventory at the destination location. The order becomes partially_received, or received once every line is settled. Receiving more than a line still has outstanding answers 409 with the code PURCHASE_ORDER_OVER_RECEIPT. Send an idempotency_key to make a retry safe: repeating a key returns the order unchanged. Returns the updated order with status 201.
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
The units received per line. At least one line must accept or reject one unit.
object
ID of the purchase order line the units arrived for.
Units accepted into stock.
Units rejected, for example because they arrived damaged. They do not enter stock.
A note recorded with the receipt.
Repeating a key returns the purchase order unchanged
Example generated
{ "lines": [ { "line_id": 1, "accepted": 1, "rejected": 1 } ], "note": "example", "idempotency_key": "example"}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"}