Overview
The Cart API enables customers to create shopping carts, add/remove items, apply promotions, and manage shipping information before completing checkout. Base Path:/store/carts
Source: packages/medusa/src/api/store/carts/route.ts
Create Cart
Create a new shopping cart.Request Body
The region where the cart is used. Determines available shipping options and tax rates.
The sales channel for the cart.
Currency code for the cart (e.g., “usd”).
Customer’s email address.
Custom metadata key-value pairs.
Request
Response
The created cart object.
packages/medusa/src/api/store/carts/route.ts:13
If the customer is authenticated, the cart is automatically associated with their account via
req.auth_context.actor_id (see line 22).Get Cart
Retrieve a cart by ID.Path Parameters
The cart’s ID.
Request
Response
packages/medusa/src/api/store/carts/[id]/route.ts
Update Cart
Update cart details such as email or region.Path Parameters
The cart’s ID.
Request Body
Update the customer’s email.
Change the cart’s region.
Change the currency.
Update metadata.
Request
Line Items
Add Line Item
Add a product variant to the cart.Path Parameters
The cart’s ID.
Request Body
The product variant ID to add.
Quantity to add.
Custom metadata for the line item.
Request
Response
packages/medusa/src/api/store/carts/[id]/line-items/route.ts
Update Line Item
Update the quantity of a line item.Path Parameters
The cart’s ID.
The line item’s ID.
Request Body
New quantity for the line item.
Update metadata.
Request
packages/medusa/src/api/store/carts/[id]/line-items/[line_id]/route.ts
Delete Line Item
Remove a line item from the cart.Request
Addresses
Update Shipping Address
Set or update the shipping address.Request Body
First name.
Last name.
Company name.
Address line 1.
Address line 2.
City.
State or province.
Postal or ZIP code.
Two-letter ISO country code.
Phone number.
Request
Update Billing Address
Set or update the billing address.Shipping Methods
Add Shipping Method
Select a shipping method for the cart.Request Body
The shipping option ID.
Additional data required by the shipping provider.
Request
Response
packages/medusa/src/api/store/carts/[id]/shipping-methods/route.ts
Promotions
Apply Promotion Code
Apply a promotion code to the cart.Request Body
Array of promotion codes to apply.
Request
Response
packages/medusa/src/api/store/carts/[id]/promotions/route.ts
Remove Promotion Code
Remove a promotion code from the cart.Request Body
Array of promotion codes to remove.
Customer Association
Update Customer
Associate the cart with a customer.Request Body
The customer ID to associate.
Customer email if not registered.
packages/medusa/src/api/store/carts/[id]/customer/route.ts
Calculate Taxes
Manually trigger tax calculation for the cart.packages/medusa/src/api/store/carts/[id]/taxes/route.ts
Taxes are usually calculated automatically when the shipping address is set or updated.
Next Steps
Checkout
Complete the cart and create an order
Products
Browse products to add to cart