Create or update order
PUT/api/v1/stores/{store_id}/orders/{order_id}
Creates the order with the store's ID, or updates it – send the order again when it changes (paid, refunded, cancelled).
The order is sent in full: the customer, the total amount and all lines. The customer is created or updated with it, and the lines replace the previous ones. campaign_id, financial_status, currency, processed_at and the partial amounts keep their values if you omit them.
Only paid orders (paid) count as purchases in the distribution lists' conditions and as revenue for the campaign in campaign_id. Partially refunded: send the order again with the new total amount.
Responds 201 when the order was created and 200 when it was updated.
Scope
ecommerce:writeEdit e-commerce – the person behind the key must be editor or higher.
Path parameters
store_idstringrequired- The store's ID, which you choose.
order_idstringrequired- The order's ID in your shop.
Body
JSON, Content-Type: application/json. Unknown fields return 422.
customerobjectrequired- The customer. Created or updated with the order (same rules as PUT /customers/{customer_id}).
customer.idstringrequired- The customer's ID in your shop.
customer.emailstringrequired- The customer's email address.at most 254 characters
customer.first_namestring | null- First name.at most 100 characters
customer.last_namestring | null- Last name.at most 100 characters
customer.companystring | null- Company.at most 200 characters
campaign_idstring | null- The campaign the customer came from: the value of qn_cid on the link they clicked. Only counts for the workspace's own campaigns; an unknown ID is not saved (but the order is).
financial_statusstring- paid: paid – counts as a purchase · pending: awaiting payment · refunded: refunded · cancelled: cancelled. Default when the order is created: paid.
pendingpaidrefundedcancelled currencystring- Default: the store's currency.
order_totalnumberrequired- The order's total amount, including VAT and shipping.at least 0 · at most 999999999999.99
tax_totalnumber | null- Of which VAT.at least 0 · at most 999999999999.99
shipping_totalnumber | null- Of which shipping.at least 0 · at most 999999999999.99
discount_totalnumber | null- Discount.at least 0 · at most 999999999999.99
processed_atstring- When the order was placed in the shop (ISO 8601). Default when the order is created: now. Send it when importing old orders.
linesarray<object>required- The order's lines (at most 500). Replaces all lines. The products do not need to have been submitted.at least 1 · at most 500
lines[].idstringrequired- The line's ID in your shop.
lines[].product_idstringrequired- The product's ID in your shop.
lines[].variant_idstring | null- The variant's ID in your shop.
lines[].titlestring | null- What was bought, as it appeared on the order.at most 255 characters
lines[].quantityintegerrequired- Quantity.at least 1 · at most 1000000
lines[].pricenumberrequired- Price per unit.at least 0 · at most 999999999999.99
lines[].discountnumber | null- Discount on the line.at least 0 · at most 999999999999.99
Retrying a request
PUT creates or updates using the shop's own ID: the same call twice gives the same result, so it can always be repeated. Batch and idempotency
Response
200 The order (201 if it was created).
idstringrequiredcustomerobject | nullrequired- null when the customer has been erased: the order still counts towards the campaign's revenue.
customer.idstringrequiredcustomer.emailstringrequiredcampaign_idstring | nullrequiredfinancial_statusstringrequiredpendingpaidrefundedcancelledcurrencystringrequiredorder_totalnumberrequiredtax_totalnumber | nullrequiredshipping_totalnumber | nullrequireddiscount_totalnumber | nullrequiredprocessed_atstring (time, ISO 8601)required- When the order was placed.
linesarray<object>requiredlines[].idstringrequiredlines[].product_idstringrequiredlines[].variant_idstring | nullrequiredlines[].titlestring | nullrequiredlines[].quantityintegerrequiredlines[].pricenumberrequiredlines[].discountnumber | nullrequiredcreated_atstring (time, ISO 8601)required- When the order was first sent in.
updated_atstring (time, ISO 8601)required- When the order was last changed.
Errors
- 400
- bad_request
- 404
- not_found
- 429
- rate_limited