Skip to content

Reference / Carts

Create or update cart

PUT/api/v1/stores/{store_id}/carts/{cart_id}

Creates the cart with the shop's ID, or updates it. The lines replace the previous ones.

A cart always belongs to a customer, who is created or updated with it. Delete the cart once it has become an order.

Guide: e-commerce →

Scope

  • ecommerce:write Edit e-commerce – the person behind the key must be editor or higher.

Path parameters

store_idstringrequired
The store's ID, which you choose.
cart_idstringrequired
The cart'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).
checkout_urlstring | null
The URL where the customer can complete the purchase.at most 2048 characters
currencystring
Default: the store's currency.
order_totalnumberrequired
The cart's total amount.at least 0 · at most 999999999999.99
tax_totalnumber | null
Of which VAT.at least 0 · at most 999999999999.99
linesarray<object>required
The cart's lines. Replaces all lines.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

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 cart (201 if it was created).

idstringrequired
customerobjectrequired
customer.idstringrequired
customer.emailstringrequired
campaign_idstring | nullrequired
checkout_urlstring | nullrequired
currencystringrequired
order_totalnumberrequired
tax_totalnumber | nullrequired
linesarray<object>required
lines[].idstringrequired
lines[].product_idstringrequired
lines[].variant_idstring | nullrequired
lines[].titlestring | nullrequired
lines[].quantityintegerrequired
lines[].pricenumberrequired
created_atstring (time, ISO 8601)required
When the cart was first sent in.
updated_atstring (time, ISO 8601)required
When the cart was last changed.

Errors