Carts API Routes
A cart is a virtual shopping bag that customers can use to add items they want to purchase.
A cart is then used to checkout and place an order.
These API routes allow customers to create and manage their cart, and place an order.
POST /store/carts#
Create Cart
Create a cart.
Authentication: none.
Header parameters
x-publishable-api-keystringx-medusa-localestringOptionalen-USQuery parameters
fieldsstringOptional+ it will be added to the default fields, using - will remove it from the default fields. without prefix it will replace the entire default fields.localestringOptionalen-USRequest body (application/json)
region_idstringOptionalshipping_addressobjectOptionalThe address's details.
shipping_addressobjectOptionalbilling_addressobjectOptionalThe address's details.
billing_addressobjectOptionalemailstringOptionalcurrency_codestringOptionalusditemsobject[]OptionalThe cart's items.
itemsobject[]Optionalsales_channel_idstringOptionalmetadataobjectOptionaladditional_dataobjectOptionaladditional_data parameter.Request examples
Responses
200 OK
cartobjectThe cart's details.
cartobject400, 401, 404, 409, 422, 500: an error response is returned.
Emitted events
cart.created: Emitted when a cart is created.
GET /store/carts/{id}#
Get a Cart
Retrieve a cart by its ID. You can expand the cart's relations or select the fields that should be returned.
Authentication: none.
Path parameters
idstringHeader parameters
x-publishable-api-keystringx-medusa-localestringOptionalen-USQuery parameters
fieldsstringOptional+ it will be added to the default fields, using - will remove it from the default fields. without prefix it will replace the entire default fields.localestringOptionalen-USRequest examples
Responses
200 OK
cartobjectThe cart's details.
cartobject400, 401, 404, 409, 422, 500: an error response is returned.
POST /store/carts/{id}#
Update a Cart
Update a cart's details. This unsets the payment methods chosen before, and the customer would have to choose them again. Also, if the customer has chosen a shipping method whose option isn't valid for the cart's shipping address anymore, the shipping method will be unset. For example, if the shipping option is valid only in the US geo zone, and the shipping address's country code is DE, the shipping method will be unset.
Authentication: none.
Path parameters
idstringHeader parameters
x-publishable-api-keystringx-medusa-localestringOptionalen-USQuery parameters
fieldsstringOptional+ it will be added to the default fields, using - will remove it from the default fields. without prefix it will replace the entire default fields.localestringOptionalen-USRequest body (application/json)
region_idstringOptionalcustomer_idstringOptionalsales_channel_idstringOptionalemailstringOptionalcurrency_codestringOptionalusdshipping_address_idstringOptionalbilling_address_idstringOptionalbilling_addressobjectOptionalThe address to create.
billing_addressobjectOptionalshipping_addressobjectOptionalThe address to create.
shipping_addressobjectOptionalmetadataobjectOptionaladditional_dataobjectOptionaladditional_data parameter.Request examples
Responses
200 OK
cartobjectThe cart's details.
cartobject400, 401, 404, 409, 422, 500: an error response is returned.
Emitted events
cart.updated: Emitted when a cart's details are updated.cart.region_updated: Emitted when the cart's region is updated. This event is emitted alongside thecart.updatedevent.
POST /store/carts/{id}/complete#
Complete Cart
Complete a cart and place an order.
Authentication: none.
Path parameters
idstringHeader parameters
x-publishable-api-keystringx-medusa-localestringOptionalen-USQuery parameters
fieldsstringOptional+ it will be added to the default fields, using - will remove it from the default fields. without prefix it will replace the entire default fields.localestringOptionalen-USRequest examples
Responses
200 OK
typestringDefault: "order"
orderobjectOptionalThe order's details.
orderobjectOptionalcartobjectOptionalThe cart's details.
cartobjectOptionalerrorobjectOptionalThe error's details.
errorobjectOptional400, 401, 404, 409, 422, 500: an error response is returned.
Emitted events
order.placed: Emitted when an order is placed, or when a draft order is converted to an order.reservation-item.created: Emitted when reservations are created.
POST /store/carts/{id}/customer#
Change Cart's Customer to Logged-in Customer
Change the cart's customer to the currently logged-in customer. This is useful when you create the cart for a guest customer, then they log in with their account.
Authentication: cookie session, JWT bearer token.
Path parameters
idstringHeader parameters
x-publishable-api-keystringx-medusa-localestringOptionalen-USQuery parameters
fieldsstringOptional+ it will be added to the default fields, using - will remove it from the default fields.
without prefix it will replace the entire default fields.localestringOptionalen-USRequest body (application/json)
additional_dataobjectOptionaladditional_data parameter.Request examples
Responses
200 OK
cartobjectThe cart's details.
cartobject400, 401, 404, 409, 422, 500: an error response is returned.
Emitted events
cart.customer_transferred: Emitted when the customer in the cart is transferred.
POST /store/carts/{id}/gift-cards#
Add Gift Card to Cart
Add a Gift Card to a cart
Authentication: none.
Path parameters
idstringHeader parameters
x-publishable-api-keystringx-medusa-localestringOptionalen-USQuery parameters
localestringOptionalen-USRequest body (application/json)
codestringRequest examples
Responses
200 OK
cartobjectThe cart's details.
cartobject400, 401, 404, 409, 422, 500: an error response is returned.
DELETE /store/carts/{id}/gift-cards#
Remove Gift Card from Cart
Remove a Gift Card from a cart.
Authentication: none.
Path parameters
idstringHeader parameters
x-publishable-api-keystringx-medusa-localestringOptionalen-USQuery parameters
localestringOptionalen-USRequest body (application/json)
codestringRequest examples
Responses
200 OK
cartobjectThe cart's details.
cartobject400, 401, 404, 409, 422, 500: an error response is returned.
POST /store/carts/{id}/line-items#
Add Line Item to Cart
Add a product variant as a line item in the cart.
Authentication: none.
Path parameters
idstringHeader parameters
x-publishable-api-keystringx-medusa-localestringOptionalen-USQuery parameters
fieldsstringOptional+ it will be added to the default fields, using - will remove it from the default fields. without prefix it will replace the entire default fields.localestringOptionalen-USRequest body (application/json)
variant_idstringquantitynumbermetadataobjectOptionaladditional_dataobjectOptionaladditional_data parameter.Request examples
Responses
200 OK
cartobjectThe cart's details.
cartobject400, 401, 404, 409, 422, 500: an error response is returned.
Emitted events
cart.updated: Emitted when a cart's details are updated.
POST /store/carts/{id}/line-items/{line_id}#
Update a Line Item in a Cart
Update a line item's details in the cart.
Authentication: none.
Path parameters
idstringline_idstringHeader parameters
x-publishable-api-keystringx-medusa-localestringOptionalen-USQuery parameters
fieldsstringOptional+ it will be added to the default fields, using - will remove it from the default fields. without prefix it will replace the entire default fields.localestringOptionalen-USRequest body (application/json)
quantitynumbermetadataobjectOptionaladditional_dataobjectOptionaladditional_data parameter.Request examples
Responses
200 OK
cartobjectThe cart's details.
cartobject400, 401, 404, 409, 422, 500: an error response is returned.
Emitted events
cart.updated: Emitted when a cart's details are updated.
DELETE /store/carts/{id}/line-items/{line_id}#
Remove Line Item from Cart
Remove a line item from a cart.
Authentication: none.
Path parameters
idstringline_idstringHeader parameters
x-publishable-api-keystringx-medusa-localestringOptionalen-USQuery parameters
fieldsstringOptional+ it will be added to the default fields, using - will remove it from the default fields. without prefix it will replace the entire default fields.localestringOptionalen-USRequest examples
Responses
200 OK
idstringobjectstringDefault: "line-item"
deletedbooleanparentobjectOptionalThe cart's details.
parentobjectOptional400, 401, 404, 409, 422, 500: an error response is returned.
Emitted events
cart.updated: Emitted when a cart's details are updated.
POST /store/carts/{id}/promotions#
Add Promotions to Cart
Add a list of promotions to a cart.
Authentication: none.
Path parameters
idstringHeader parameters
x-publishable-api-keystringx-medusa-localestringOptionalen-USQuery parameters
fieldsstringOptional+ it will be added to the default fields, using - will remove it from the default fields. without prefix it will replace the entire default fields.localestringOptionalen-USRequest body (application/json)
promo_codesstring[]Request examples
Responses
200 OK
cartobjectThe cart's details.
cartobject400, 401, 404, 409, 422, 500: an error response is returned.
DELETE /store/carts/{id}/promotions#
Remove Promotions from Cart
Remove a list of promotions from a cart.
Authentication: none.
Path parameters
idstringHeader parameters
x-publishable-api-keystringx-medusa-localestringOptionalen-USQuery parameters
fieldsstringOptional+ it will be added to the default fields, using - will remove it from the default fields. without prefix it will replace the entire default fields.localestringOptionalen-USRequest body (application/json)
promo_codesstring[]Request examples
Responses
200 OK
cartobjectThe cart's details.
cartobject400, 401, 404, 409, 422, 500: an error response is returned.
POST /store/carts/{id}/shipping-methods#
Add Shipping Method to Cart
Add a shipping method to a cart. Use this API route when the customer chooses their preferred shipping option.
If the chosen shipping option's price_type is calculated, its price is computed by the associated fulfillment provider when it's added to the cart. If the provider fails to calculate the price, this route returns an error.
Authentication: none.
Path parameters
idstringHeader parameters
x-publishable-api-keystringx-medusa-localestringOptionalen-USQuery parameters
localestringOptionalen-USfieldsstringOptional+ it will be added to the default fields, using - will remove it from the default fields. Without prefix it will replace the entire default fields.Request body (application/json)
option_idstringdataobjectOptionaladditional_dataobjectOptionaladditional_data parameter.Request examples
Responses
200 OK
cartobjectThe cart's details.
cartobject400, 401, 404, 409, 422, 500: an error response is returned.
Emitted events
cart.updated: Emitted when a cart's details are updated.
POST /store/carts/{id}/store-credits#
Add Store Credit to Cart
Add a Store Credit to a cart
Authentication: none.
Path parameters
idstringHeader parameters
x-publishable-api-keystringx-medusa-localestringOptionalen-USQuery parameters
localestringOptionalen-USRequest body (application/json)
amountnumberRequest examples
Responses
200 OK
cartobjectThe cart's details.
cartobject400, 401, 404, 409, 422, 500: an error response is returned.
POST /store/carts/{id}/taxes#
Calculate Cart Taxes
Calculate the cart's tax lines and amounts.
Medusa recalculates a cart's tax lines automatically on cart changes when the cart's region has automatic_taxes enabled, so you typically don't need to use this route. Use this route to force a recalculation, such as when automatic_taxes is disabled, which also triggers a fresh calculation from your third-party tax provider, if you use one.
Authentication: none.
Path parameters
idstringHeader parameters
x-publishable-api-keystringx-medusa-localestringOptionalen-USQuery parameters
localestringOptionalen-USfieldsstringOptional+ it will be added to the default fields, using - will remove it from the default fields. Without prefix it will replace the entire default fields.Request examples
Responses
200 OK
cartobjectThe cart's details.
cartobject400, 401, 404, 409, 422, 500: an error response is returned.