Cart API reference

The Cart API is used to interact with a cart during a customer's session. This guide shows how to use the Cart API to update cart line items, add cart attributes and notes, and generate shipping rates.

POST /cart/add.js

Use the POST /cart/add.js endpoint to add one or multiple variants to the cart.

In the following example, quantity is the amount of the variant that you want to add and id is the variant ID of that variant. You can add multiple variants to the cart by appending more objects in the items array.

To send a serialized Add to Cart form, specify the following post data:

You can also add to the cart with line item properties, not just a quantity and ID:

Add line item properties

You can add a variant to the cart with line item properties with an accompanying properties object.

View response

Add a selling plan

You can add a variant with a selling plan to the cart with an accompanying selling_plan parameter.

View response

The response object has a selling_plan_allocation property.

Example API calls

Below is a simplified POST using the fetch API