Skip to main content

Medusa Storefront API (1.0.0)

Download OpenAPI specification:Download

License: MIT

API reference for Medusa's Storefront endpoints. All endpoints are prefixed with /store.

Authentication

To send requests as an authenticated customer, you must use the Cookie Session ID.

Cookie Session ID

Use a cookie session to send authenticated requests.

If you're sending requests through a browser, using JS Client, or using tools like Postman, the cookie session should be automatically set when the customer is logged in.

If you're sending requests using cURL, you must set the Session ID in the cookie manually.

To do that, send a request to authenticate the customer and pass the cURL option -v:

curl -v --location --request POST 'https://medusa-url.com/store/auth' \
--header 'Content-Type: application/json' \
--data-raw '{
  "email": "user@example.com",
  "password": "supersecret"
}'

The headers will be logged in the terminal as well as the response. You should find in the headers a Cookie header similar to this:

Set-Cookie: connect.sid=s%3A2Bu8BkaP9JUfHu9rG59G16Ma0QZf6Gj1.WT549XqX37PN8n0OecqnMCq798eLjZC5IT7yiDCBHPM;

Copy the value after connect.sid (without the ; at the end) and pass it as a cookie in subsequent requests as the following:

curl --location --request GET 'https://medusa-url.com/store/customers/me/orders' \
--header 'Cookie: connect.sid={sid}'

Where {sid} is the value of connect.sid that you copied.

Security Scheme Type: API Key
Cookie parameter name: connect.sid

Expanding Fields

In many endpoints you'll find an expand query parameter that can be passed to the endpoint. You can use the expand query parameter to unpack an entity's relations and return them in the response.

Please note that the relations you pass to expand replace any relations that are expanded by default in the request.

Expanding One Relation

For example, when you retrieve a product, you can retrieve its collection by passing to the expand query parameter the value collection:

curl "http://localhost:9000/store/products/prod_01GDJGP2XPQT2N3JHZQFMH5V45?expand=collection"

Expanding Multiple Relations

You can expand more than one relation by separating the relations in the expand query parameter with a comma.

For example, to retrieve both the variants and the collection of a product, pass to the expand query parameter the value variants,collection:

curl "http://localhost:9000/store/products/prod_01GDJGP2XPQT2N3JHZQFMH5V45?expand=variants,collection"

Prevent Expanding Relations

Some requests expand relations by default. You can prevent that by passing an empty expand value to retrieve an entity without any extra relations.

For example:

curl "http://localhost:9000/store/products/prod_01GDJGP2XPQT2N3JHZQFMH5V45?expand"

This would retrieve the product with only its properties, without any relations like collection.

Selecting Fields

In many endpoints you'll find a fields query parameter that can be passed to the endpoint. You can use the fields query parameter to specify which fields in the entity should be returned in the response.

Please note that if you pass a fields query parameter, only the fields you pass in the value along with the id of the entity will be returned in the response.

Also, the fields query parameter does not affect the expanded relations. You'll have to use the expand parameter instead.

Selecting One Field

For example, when you retrieve a list of products, you can retrieve only the titles of the products by passing title as a value to the fields query parameter:

curl "http://localhost:9000/store/products?fields=title"

As mentioned above, the expanded relations such as variants will still be returned as they're not affected by the fields parameter.

You can ensure that only the title field is returned by passing an empty value to the expand query parameter. For example:

curl "http://localhost:9000/store/products?fields=title&expand"

Selecting Multiple Fields

You can pass more than one field by seperating the field names in the fields query parameter with a comma.

For example, to select the title and handle of a product:

curl "http://localhost:9000/store/products?fields=title,handle"

Retrieve Only the ID

You can pass an empty fields query parameter to return only the ID of an entity. For example:

curl "http://localhost:9000/store/products?fields"

You can also pair with an empty expand query parameter to ensure that the relations aren't retrieved as well. For example:

curl "http://localhost:9000/store/products?fields&expand"

Query Parameter Types

This section covers how to pass some common data types as query parameters. This is useful if you're sending requests to the API endpoints and not using our JS Client. For example, when using cURL or Postman.

Strings

You can pass a string value in the form of <parameter_name>=<value>.

For example:

curl "http://localhost:9000/store/products?title=Shirt"

If the string has any characters other than letters and numbers, you must encode them.

For example, if the string has spaces, you can encode the space with + or %20:

curl "http://localhost:9000/store/products?title=Blue%20Shirt"

You can use tools like this one to learn how a value can be encoded.

Integers

You can pass an integer value in the form of <parameter_name>=<value>.

For example:

curl "http://localhost:9000/store/products?offset=1"

Boolean

You can pass a boolean value in the form of <parameter_name>=<value>.

For example:

curl "http://localhost:9000/store/products?is_giftcard=true"

Date and DateTime

You can pass a date value in the form <parameter_name>=<value>. The date must be in the format YYYY-MM-DD.

For example:

curl -g "http://localhost:9000/store/products?created_at[lt]=2023-02-17"

You can also pass the time using the format YYYY-MM-DDTHH:MM:SSZ. Please note that the T and Z here are fixed.

For example:

curl -g "http://localhost:9000/store/products?created_at[lt]=2023-02-17T07:22:30Z"

Array

Each array value must be passed as a separate query parameter in the form <parameter_name>[]=<value>. You can also specify the index of each parameter in the brackets <parameter_name>[0]=<value>.

For example:

curl -g "http://localhost:9000/store/products?sales_channel_id[]=sc_01GPGVB42PZ7N3YQEP2WDM7PC7&sales_channel_id[]=sc_234PGVB42PZ7N3YQEP2WDM7PC7"

Note that the -g parameter passed to curl disables errors being thrown for using the brackets. Read more here.

Object

Object parameters must be passed as separate query parameters in the form <parameter_name>[<key>]=<value>.

For example:

curl -g "http://localhost:9000/store/products?created_at[lt]=2023-02-17&created_at[gt]=2022-09-17"

Pagination

Query Parameters

In listing endpoints, such as list customers or list products, you can control the pagination using the query parameters limit and offset.

limit is used to specify the maximum number of items that can be return in the response. offset is used to specify how many items to skip before returning the resulting entities.

You can use the offset query parameter to change between pages. For example, if the limit is 50, at page 1 the offset should be 0; at page 2 the offset should be 50, and so on.

For example, to limit the number of products returned in the List Products endpoint:

curl "http://localhost:9000/store/products?limit=5"

Response Fields

In the response of listing endpoints, aside from the entities retrieved, there are three pagination-related fields returned: count, limit, and offset.

Similar to the query parameters, limit is the maximum number of items that can be returned in the response, and field is the number of items that were skipped before the entities in the result.

count is the total number of available items of this entity. It can be used to determine how many pages are there.

For example, if the count is 100 and the limit is 50, you can divide the count by the limit to get the number of pages: 100/50 = 2 pages.

Sort Order

The order field available on endpoints supporting pagination allows you to sort the retrieved items by an attribute of that item. For example, you can sort products by their created_at attribute by setting order to created_at:

curl "http://localhost:9000/list/products?order=created_at"

By default, the sort direction will be ascending. To change it to descending, pass a dash (-) before the attribute name. For example:

curl "http://localhost:9000/list/products?order=-created_at"

This sorts the products by their created_at attribute in the descending order.

Auth

Auth endpoints that allow authorization of customers and manages their sessions.

Get Current Customer

Gets the currently logged in Customer.

Authorizations:
Cookie Session ID

Responses

Response Schema: application/json
required
object (Customer)

Represents a customer

billing_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The customer's billing address ID

created_at
required
string <date-time>

The date with timezone at which the resource was created.

deleted_at
required
string or null <date-time>

The date with timezone at which the resource was deleted.

email
required
string <email>

The customer's email

first_name
required
string or null
Example: "Arno"

The customer's first name

has_account
required
boolean
Default: false

Whether the customer has an account or not

id
required
string
Example: "cus_01G2SG30J8C85S4A5CHM2S1NS2"

The customer's ID

last_name
required
string or null
Example: "Willms"

The customer's last name

metadata
required
object or null
Example: {"car":"white"}

An optional key-value map with additional details

phone
required
string or null
Example: 16128234334802

The customer's phone number

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

object (Address)

An address.

Array of objects (Address)

Available if the relation shipping_addresses is expanded.

orders
Array of objects

Available if the relation orders is expanded.

Array of objects (Customer Group)

The customer groups the customer belongs to. Available if the relation groups is expanded.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged
medusa.auth.getSession()
.then(({ customer }) => {
  console.log(customer.id);
});

Response samples

Content type
application/json
{
  • "customer": {
    }
}

Customer Login

Logs a Customer in and authorizes them to view their details. Successful authentication will set a session cookie in the Customer's browser.

Request Body schema: application/json
email
required
string

The Customer's email.

password
required
string

The Customer's password.

Responses

Response Schema: application/json
required
object (Customer)

Represents a customer

billing_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The customer's billing address ID

created_at
required
string <date-time>

The date with timezone at which the resource was created.

deleted_at
required
string or null <date-time>

The date with timezone at which the resource was deleted.

email
required
string <email>

The customer's email

first_name
required
string or null
Example: "Arno"

The customer's first name

has_account
required
boolean
Default: false

Whether the customer has an account or not

id
required
string
Example: "cus_01G2SG30J8C85S4A5CHM2S1NS2"

The customer's ID

last_name
required
string or null
Example: "Willms"

The customer's last name

metadata
required
object or null
Example: {"car":"white"}

An optional key-value map with additional details

phone
required
string or null
Example: 16128234334802

The customer's phone number

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

object (Address)

An address.

Array of objects (Address)

Available if the relation shipping_addresses is expanded.

orders
Array of objects

Available if the relation orders is expanded.

Array of objects (Customer Group)

The customer groups the customer belongs to. Available if the relation groups is expanded.

Request samples

Content type
application/json
{
  • "email": "string",
  • "password": "string"
}

Response samples

Content type
application/json
{
  • "customer": {
    }
}

Customer Log out

Destroys a Customer's authenticated session.

Authorizations:
Cookie Session ID

Responses

Request samples

curl --location --request DELETE 'https://medusa-url.com/store/auth' \
--header 'Cookie: connect.sid={sid}'

Response samples

Content type
application/json
Example
{
  • "message": "Discount must be set to dynamic",
  • "type": "not_allowed"
}

Check if email exists

Checks if a Customer with the given email has signed up.

path Parameters
email
required
string <email>

The email to check if exists.

Responses

Response Schema: application/json
exists
required
boolean

Whether email exists or not.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.auth.exists('user@example.com')

Response samples

Content type
application/json
{
  • "exists": true
}

Carts

Cart endpoints that allow handling carts in Medusa.

Create a Cart

Creates a Cart within the given region and with the initial items. If no region_id is provided the cart will be associated with the first Region available. If no items are provided the cart will be empty after creation. If a user is logged in the cart's customer id and email will be set.

Request Body schema: application/json
region_id
string

The ID of the Region to create the Cart in.

sales_channel_id
string

[EXPERIMENTAL] The ID of the Sales channel to create the Cart in.

country_code
string

The 2 character ISO country code to create the Cart in.

Array of objects

An optional array of variant_id, quantity pairs to generate Line Items from.

context
object
Example: {"ip":"::1","user_agent":"Chrome"}

An optional object to provide context to the Cart. The context field is automatically populated with ip and user_agent

Responses

Response Schema: application/json
required
object (Cart)

Represents a user cart

billing_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The billing address's ID

completed_at
required
string or null <date-time>

The date with timezone at which the cart was completed.

context
required
object or null
Example: {"ip":"::1","user_agent":"PostmanRuntime/7.29.2"}

The context of the cart which can include info like IP or user agent.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

customer_id
required
string or null
Example: "cus_01G2SG30J8C85S4A5CHM2S1NS2"

The customer's ID

deleted_at
required
string or null <date-time>

The date with timezone at which the resource was deleted.

email
required
string or null <email>

The email associated with the cart

id
required
string
Example: "cart_01G8ZH853Y6TFXWPG5EYE81X63"

The cart's ID

idempotency_key
required
string or null

Randomly generated key used to continue the completion of a cart in case of failure.

metadata
required
object or null
Example: {"car":"white"}

An optional key-value map with additional details

payment_authorized_at
required
string or null <date-time>

The date with timezone at which the payment was authorized.

payment_id
required
string or null
Example: "pay_01G8ZCC5W42ZNY842124G7P5R9"

The payment's ID if available

payment_session
required
object or null

The selected payment session in the cart.

region_id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The region's ID

shipping_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The shipping address's ID

type
required
string
Default: "default"
Enum: "default" "swap" "draft_order" "payment_link" "claim"

The cart's type.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

object (Address)

An address.

object (Address)

An address.

Array of objects (Line Item)

Available if the relation items is expanded.

object (Region)

Regions hold settings for how Customers in a given geographical location shop. The is, for example, where currencies and tax rates are defined. A Region can consist of multiple countries to accomodate common shopping settings across countries.

Array of objects (Discount)

Available if the relation discounts is expanded.

Array of objects (Gift Card)

Available if the relation gift_cards is expanded.

customer
object or null

A customer object. Available if the relation customer is expanded.

payment_sessions
Array of objects

The payment sessions created on the cart.

payment
object or null

Available if the relation payment is expanded.

Array of objects (Shipping Method)

The shipping methods added to the cart.

sales_channel_id
string or null
Example: null

The sales channel ID the cart is associated with.

object (Sales Channel)

A Sales Channel

shipping_total
integer
Example: 1000

The total of shipping

discount_total
integer
Example: 800

The total of discount rounded

raw_discount_total
integer
Example: 800

The total of discount

item_tax_total
integer
Example: 8000

The total of items with taxes

shipping_tax_total
integer
Example: 1000

The total of shipping with taxes

tax_total
integer
Example: 0

The total of tax

refunded_total
integer
Example: 0

The total amount refunded if the order associated with this cart is returned.

total
integer
Example: 8200

The total amount of the cart

subtotal
integer
Example: 8000

The subtotal of the cart

refundable_amount
integer
Example: 8200

The amount that can be refunded

gift_card_total
integer
Example: 0

The total of gift cards

gift_card_tax_total
integer
Example: 0

The total of gift cards with taxes

Request samples

Content type
application/json
{
  • "region_id": "string",
  • "sales_channel_id": "string",
  • "country_code": "string",
  • "items": [
    ],
  • "context": {
    }
}

Response samples

Content type
application/json
{
  • "cart": {
    }
}

Get a Cart

Retrieves a Cart.

path Parameters
id
required
string

The id of the Cart.

Responses

Response Schema: application/json
required
object (Cart)

Represents a user cart

billing_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The billing address's ID

completed_at
required
string or null <date-time>

The date with timezone at which the cart was completed.

context
required
object or null
Example: {"ip":"::1","user_agent":"PostmanRuntime/7.29.2"}

The context of the cart which can include info like IP or user agent.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

customer_id
required
string or null
Example: "cus_01G2SG30J8C85S4A5CHM2S1NS2"

The customer's ID

deleted_at
required
string or null <date-time>

The date with timezone at which the resource was deleted.

email
required
string or null <email>

The email associated with the cart

id
required
string
Example: "cart_01G8ZH853Y6TFXWPG5EYE81X63"

The cart's ID

idempotency_key
required
string or null

Randomly generated key used to continue the completion of a cart in case of failure.

metadata
required
object or null
Example: {"car":"white"}

An optional key-value map with additional details

payment_authorized_at
required
string or null <date-time>

The date with timezone at which the payment was authorized.

payment_id
required
string or null
Example: "pay_01G8ZCC5W42ZNY842124G7P5R9"

The payment's ID if available

payment_session
required
object or null

The selected payment session in the cart.

region_id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The region's ID

shipping_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The shipping address's ID

type
required
string
Default: "default"
Enum: "default" "swap" "draft_order" "payment_link" "claim"

The cart's type.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

object (Address)

An address.

object (Address)

An address.

Array of objects (Line Item)

Available if the relation items is expanded.

object (Region)

Regions hold settings for how Customers in a given geographical location shop. The is, for example, where currencies and tax rates are defined. A Region can consist of multiple countries to accomodate common shopping settings across countries.

Array of objects (Discount)

Available if the relation discounts is expanded.

Array of objects (Gift Card)

Available if the relation gift_cards is expanded.

customer
object or null

A customer object. Available if the relation customer is expanded.

payment_sessions
Array of objects

The payment sessions created on the cart.

payment
object or null

Available if the relation payment is expanded.

Array of objects (Shipping Method)

The shipping methods added to the cart.

sales_channel_id
string or null
Example: null

The sales channel ID the cart is associated with.

object (Sales Channel)

A Sales Channel

shipping_total
integer
Example: 1000

The total of shipping

discount_total
integer
Example: 800

The total of discount rounded

raw_discount_total
integer
Example: 800

The total of discount

item_tax_total
integer
Example: 8000

The total of items with taxes

shipping_tax_total
integer
Example: 1000

The total of shipping with taxes

tax_total
integer
Example: 0

The total of tax

refunded_total
integer
Example: 0

The total amount refunded if the order associated with this cart is returned.

total
integer
Example: 8200

The total amount of the cart

subtotal
integer
Example: 8000

The subtotal of the cart

refundable_amount
integer
Example: 8200

The amount that can be refunded

gift_card_total
integer
Example: 0

The total of gift cards

gift_card_tax_total
integer
Example: 0

The total of gift cards with taxes

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.carts.retrieve(cart_id)
.then(({ cart }) => {
  console.log(cart.id);
});

Response samples

Content type
application/json
{
  • "cart": {
    }
}

Update a Cart

Updates a Cart.

path Parameters
id
required
string

The id of the Cart.

Request Body schema: application/json
region_id
string

The id of the Region to create the Cart in.

country_code
string

The 2 character ISO country code to create the Cart in.

email
string <email>

An email to be used on the Cart.

sales_channel_id
string

The ID of the Sales channel to update the Cart with.

AddressPayload (object) or string

The Address to be used for billing purposes.

AddressPayload (object) or string

The Address to be used for shipping.

Array of objects

An array of Gift Card codes to add to the Cart.

Array of objects

An array of Discount codes to add to the Cart.

customer_id
string

The ID of the Customer to associate the Cart with.

context
object
Example: {"ip":"::1","user_agent":"Chrome"}

An optional object to provide context to the Cart.

Responses

Response Schema: application/json
required
object (Cart)

Represents a user cart

billing_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The billing address's ID

completed_at
required
string or null <date-time>

The date with timezone at which the cart was completed.

context
required
object or null
Example: {"ip":"::1","user_agent":"PostmanRuntime/7.29.2"}

The context of the cart which can include info like IP or user agent.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

customer_id
required
string or null
Example: "cus_01G2SG30J8C85S4A5CHM2S1NS2"

The customer's ID

deleted_at
required
string or null <date-time>

The date with timezone at which the resource was deleted.

email
required
string or null <email>

The email associated with the cart

id
required
string
Example: "cart_01G8ZH853Y6TFXWPG5EYE81X63"

The cart's ID

idempotency_key
required
string or null

Randomly generated key used to continue the completion of a cart in case of failure.

metadata
required
object or null
Example: {"car":"white"}

An optional key-value map with additional details

payment_authorized_at
required
string or null <date-time>

The date with timezone at which the payment was authorized.

payment_id
required
string or null
Example: "pay_01G8ZCC5W42ZNY842124G7P5R9"

The payment's ID if available

payment_session
required
object or null

The selected payment session in the cart.

region_id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The region's ID

shipping_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The shipping address's ID

type
required
string
Default: "default"
Enum: "default" "swap" "draft_order" "payment_link" "claim"

The cart's type.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

object (Address)

An address.

object (Address)

An address.

Array of objects (Line Item)

Available if the relation items is expanded.

object (Region)

Regions hold settings for how Customers in a given geographical location shop. The is, for example, where currencies and tax rates are defined. A Region can consist of multiple countries to accomodate common shopping settings across countries.

Array of objects (Discount)

Available if the relation discounts is expanded.

Array of objects (Gift Card)

Available if the relation gift_cards is expanded.

customer
object or null

A customer object. Available if the relation customer is expanded.

payment_sessions
Array of objects

The payment sessions created on the cart.

payment
object or null

Available if the relation payment is expanded.

Array of objects (Shipping Method)

The shipping methods added to the cart.

sales_channel_id
string or null
Example: null

The sales channel ID the cart is associated with.

object (Sales Channel)

A Sales Channel

shipping_total
integer
Example: 1000

The total of shipping

discount_total
integer
Example: 800

The total of discount rounded

raw_discount_total
integer
Example: 800

The total of discount

item_tax_total
integer
Example: 8000

The total of items with taxes

shipping_tax_total
integer
Example: 1000

The total of shipping with taxes

tax_total
integer
Example: 0

The total of tax

refunded_total
integer
Example: 0

The total amount refunded if the order associated with this cart is returned.

total
integer
Example: 8200

The total amount of the cart

subtotal
integer
Example: 8000

The subtotal of the cart

refundable_amount
integer
Example: 8200

The amount that can be refunded

gift_card_total
integer
Example: 0

The total of gift cards

gift_card_tax_total
integer
Example: 0

The total of gift cards with taxes

Request samples

Content type
application/json
{
  • "region_id": "string",
  • "country_code": "string",
  • "email": "user@example.com",
  • "sales_channel_id": "string",
  • "billing_address": {
    },
  • "shipping_address": {
    },
  • "gift_cards": [
    ],
  • "discounts": [
    ],
  • "customer_id": "string",
  • "context": {
    }
}

Response samples

Content type
application/json
{
  • "cart": {
    }
}

Complete a Cart

Completes a cart. The following steps will be performed. Payment authorization is attempted and if more work is required, we simply return the cart for further updates. If payment is authorized and order is not yet created, we make sure to do so. The completion of a cart can be performed idempotently with a provided header Idempotency-Key. If not provided, we will generate one for the request.

path Parameters
id
required
string

The Cart id.

Responses

Response Schema: application/json
type
required
string
Enum: "order" "cart" "swap"

The type of the data property.

required
Order (object) or Cart (object) or Swap (object)

The data of the result object. Its type depends on the type field.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.carts.complete(cart_id)
.then(({ cart }) => {
  console.log(cart.id);
});

Response samples

Content type
application/json
{
  • "type": "order",
  • "data": {
    }
}

Remove Discount

Removes a Discount from a Cart.

path Parameters
id
required
string

The id of the Cart.

code
required
string

The unique Discount code.

Responses

Response Schema: application/json
required
object (Cart)

Represents a user cart

billing_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The billing address's ID

completed_at
required
string or null <date-time>

The date with timezone at which the cart was completed.

context
required
object or null
Example: {"ip":"::1","user_agent":"PostmanRuntime/7.29.2"}

The context of the cart which can include info like IP or user agent.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

customer_id
required
string or null
Example: "cus_01G2SG30J8C85S4A5CHM2S1NS2"

The customer's ID

deleted_at
required
string or null <date-time>

The date with timezone at which the resource was deleted.

email
required
string or null <email>

The email associated with the cart

id
required
string
Example: "cart_01G8ZH853Y6TFXWPG5EYE81X63"

The cart's ID

idempotency_key
required
string or null

Randomly generated key used to continue the completion of a cart in case of failure.

metadata
required
object or null
Example: {"car":"white"}

An optional key-value map with additional details

payment_authorized_at
required
string or null <date-time>

The date with timezone at which the payment was authorized.

payment_id
required
string or null
Example: "pay_01G8ZCC5W42ZNY842124G7P5R9"

The payment's ID if available

payment_session
required
object or null

The selected payment session in the cart.

region_id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The region's ID

shipping_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The shipping address's ID

type
required
string
Default: "default"
Enum: "default" "swap" "draft_order" "payment_link" "claim"

The cart's type.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

object (Address)

An address.

object (Address)

An address.

Array of objects (Line Item)

Available if the relation items is expanded.

object (Region)

Regions hold settings for how Customers in a given geographical location shop. The is, for example, where currencies and tax rates are defined. A Region can consist of multiple countries to accomodate common shopping settings across countries.

Array of objects (Discount)

Available if the relation discounts is expanded.

Array of objects (Gift Card)

Available if the relation gift_cards is expanded.

customer
object or null

A customer object. Available if the relation customer is expanded.

payment_sessions
Array of objects

The payment sessions created on the cart.

payment
object or null

Available if the relation payment is expanded.

Array of objects (Shipping Method)

The shipping methods added to the cart.

sales_channel_id
string or null
Example: null

The sales channel ID the cart is associated with.

object (Sales Channel)

A Sales Channel

shipping_total
integer
Example: 1000

The total of shipping

discount_total
integer
Example: 800

The total of discount rounded

raw_discount_total
integer
Example: 800

The total of discount

item_tax_total
integer
Example: 8000

The total of items with taxes

shipping_tax_total
integer
Example: 1000

The total of shipping with taxes

tax_total
integer
Example: 0

The total of tax

refunded_total
integer
Example: 0

The total amount refunded if the order associated with this cart is returned.

total
integer
Example: 8200

The total amount of the cart

subtotal
integer
Example: 8000

The subtotal of the cart

refundable_amount
integer
Example: 8200

The amount that can be refunded

gift_card_total
integer
Example: 0

The total of gift cards

gift_card_tax_total
integer
Example: 0

The total of gift cards with taxes

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.carts.deleteDiscount(cart_id, code)
.then(({ cart }) => {
  console.log(cart.id);
});

Response samples

Content type
application/json
{
  • "cart": {
    }
}

Add a Line Item

Generates a Line Item with a given Product Variant and adds it to the Cart

path Parameters
id
required
string

The id of the Cart to add the Line Item to.

Request Body schema: application/json
variant_id
required
string

The id of the Product Variant to generate the Line Item from.

quantity
required
number

The quantity of the Product Variant to add to the Line Item.

metadata
object

An optional key-value map with additional details about the Line Item.

Responses

Response Schema: application/json
required
object (Cart)

Represents a user cart

billing_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The billing address's ID

completed_at
required
string or null <date-time>

The date with timezone at which the cart was completed.

context
required
object or null
Example: {"ip":"::1","user_agent":"PostmanRuntime/7.29.2"}

The context of the cart which can include info like IP or user agent.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

customer_id
required
string or null
Example: "cus_01G2SG30J8C85S4A5CHM2S1NS2"

The customer's ID

deleted_at
required
string or null <date-time>

The date with timezone at which the resource was deleted.

email
required
string or null <email>

The email associated with the cart

id
required
string
Example: "cart_01G8ZH853Y6TFXWPG5EYE81X63"

The cart's ID

idempotency_key
required
string or null

Randomly generated key used to continue the completion of a cart in case of failure.

metadata
required
object or null
Example: {"car":"white"}

An optional key-value map with additional details

payment_authorized_at
required
string or null <date-time>

The date with timezone at which the payment was authorized.

payment_id
required
string or null
Example: "pay_01G8ZCC5W42ZNY842124G7P5R9"

The payment's ID if available

payment_session
required
object or null

The selected payment session in the cart.

region_id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The region's ID

shipping_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The shipping address's ID

type
required
string
Default: "default"
Enum: "default" "swap" "draft_order" "payment_link" "claim"

The cart's type.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

object (Address)

An address.

object (Address)

An address.

Array of objects (Line Item)

Available if the relation items is expanded.

object (Region)

Regions hold settings for how Customers in a given geographical location shop. The is, for example, where currencies and tax rates are defined. A Region can consist of multiple countries to accomodate common shopping settings across countries.

Array of objects (Discount)

Available if the relation discounts is expanded.

Array of objects (Gift Card)

Available if the relation gift_cards is expanded.

customer
object or null

A customer object. Available if the relation customer is expanded.

payment_sessions
Array of objects

The payment sessions created on the cart.

payment
object or null

Available if the relation payment is expanded.

Array of objects (Shipping Method)

The shipping methods added to the cart.

sales_channel_id
string or null
Example: null

The sales channel ID the cart is associated with.

object (Sales Channel)

A Sales Channel

shipping_total
integer
Example: 1000

The total of shipping

discount_total
integer
Example: 800

The total of discount rounded

raw_discount_total
integer
Example: 800

The total of discount

item_tax_total
integer
Example: 8000

The total of items with taxes

shipping_tax_total
integer
Example: 1000

The total of shipping with taxes

tax_total
integer
Example: 0

The total of tax

refunded_total
integer
Example: 0

The total amount refunded if the order associated with this cart is returned.

total
integer
Example: 8200

The total amount of the cart

subtotal
integer
Example: 8000

The subtotal of the cart

refundable_amount
integer
Example: 8200

The amount that can be refunded

gift_card_total
integer
Example: 0

The total of gift cards

gift_card_tax_total
integer
Example: 0

The total of gift cards with taxes

Request samples

Content type
application/json
{
  • "variant_id": "string",
  • "quantity": 0,
  • "metadata": { }
}

Response samples

Content type
application/json
{
  • "cart": {
    }
}

Update a Line Item

Updates a Line Item if the desired quantity can be fulfilled.

path Parameters
id
required
string

The id of the Cart.

line_id
required
string

The id of the Line Item.

Request Body schema: application/json
quantity
required
number

The quantity to set the Line Item to.

Responses

Response Schema: application/json
required
object (Cart)

Represents a user cart

billing_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The billing address's ID

completed_at
required
string or null <date-time>

The date with timezone at which the cart was completed.

context
required
object or null
Example: {"ip":"::1","user_agent":"PostmanRuntime/7.29.2"}

The context of the cart which can include info like IP or user agent.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

customer_id
required
string or null
Example: "cus_01G2SG30J8C85S4A5CHM2S1NS2"

The customer's ID

deleted_at
required
string or null <date-time>

The date with timezone at which the resource was deleted.

email
required
string or null <email>

The email associated with the cart

id
required
string
Example: "cart_01G8ZH853Y6TFXWPG5EYE81X63"

The cart's ID

idempotency_key
required
string or null

Randomly generated key used to continue the completion of a cart in case of failure.

metadata
required
object or null
Example: {"car":"white"}

An optional key-value map with additional details

payment_authorized_at
required
string or null <date-time>

The date with timezone at which the payment was authorized.

payment_id
required
string or null
Example: "pay_01G8ZCC5W42ZNY842124G7P5R9"

The payment's ID if available

payment_session
required
object or null

The selected payment session in the cart.

region_id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The region's ID

shipping_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The shipping address's ID

type
required
string
Default: "default"
Enum: "default" "swap" "draft_order" "payment_link" "claim"

The cart's type.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

object (Address)

An address.

object (Address)

An address.

Array of objects (Line Item)

Available if the relation items is expanded.

object (Region)

Regions hold settings for how Customers in a given geographical location shop. The is, for example, where currencies and tax rates are defined. A Region can consist of multiple countries to accomodate common shopping settings across countries.

Array of objects (Discount)

Available if the relation discounts is expanded.

Array of objects (Gift Card)

Available if the relation gift_cards is expanded.

customer
object or null

A customer object. Available if the relation customer is expanded.

payment_sessions
Array of objects

The payment sessions created on the cart.

payment
object or null

Available if the relation payment is expanded.

Array of objects (Shipping Method)

The shipping methods added to the cart.

sales_channel_id
string or null
Example: null

The sales channel ID the cart is associated with.

object (Sales Channel)

A Sales Channel

shipping_total
integer
Example: 1000

The total of shipping

discount_total
integer
Example: 800

The total of discount rounded

raw_discount_total
integer
Example: 800

The total of discount

item_tax_total
integer
Example: 8000

The total of items with taxes

shipping_tax_total
integer
Example: 1000

The total of shipping with taxes

tax_total
integer
Example: 0

The total of tax

refunded_total
integer
Example: 0

The total amount refunded if the order associated with this cart is returned.

total
integer
Example: 8200

The total amount of the cart

subtotal
integer
Example: 8000

The subtotal of the cart

refundable_amount
integer
Example: 8200

The amount that can be refunded

gift_card_total
integer
Example: 0

The total of gift cards

gift_card_tax_total
integer
Example: 0

The total of gift cards with taxes

Request samples

Content type
application/json
{
  • "quantity": 0
}

Response samples

Content type
application/json
{
  • "cart": {
    }
}

Delete a Line Item

Removes a Line Item from a Cart.

path Parameters
id
required
string

The id of the Cart.

line_id
required
string

The id of the Line Item.

Responses

Response Schema: application/json
required
object (Cart)

Represents a user cart

billing_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The billing address's ID

completed_at
required
string or null <date-time>

The date with timezone at which the cart was completed.

context
required
object or null
Example: {"ip":"::1","user_agent":"PostmanRuntime/7.29.2"}

The context of the cart which can include info like IP or user agent.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

customer_id
required
string or null
Example: "cus_01G2SG30J8C85S4A5CHM2S1NS2"

The customer's ID

deleted_at
required
string or null <date-time>

The date with timezone at which the resource was deleted.

email
required
string or null <email>

The email associated with the cart

id
required
string
Example: "cart_01G8ZH853Y6TFXWPG5EYE81X63"

The cart's ID

idempotency_key
required
string or null

Randomly generated key used to continue the completion of a cart in case of failure.

metadata
required
object or null
Example: {"car":"white"}

An optional key-value map with additional details

payment_authorized_at
required
string or null <date-time>

The date with timezone at which the payment was authorized.

payment_id
required
string or null
Example: "pay_01G8ZCC5W42ZNY842124G7P5R9"

The payment's ID if available

payment_session
required
object or null

The selected payment session in the cart.

region_id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The region's ID

shipping_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The shipping address's ID

type
required
string
Default: "default"
Enum: "default" "swap" "draft_order" "payment_link" "claim"

The cart's type.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

object (Address)

An address.

object (Address)

An address.

Array of objects (Line Item)

Available if the relation items is expanded.

object (Region)

Regions hold settings for how Customers in a given geographical location shop. The is, for example, where currencies and tax rates are defined. A Region can consist of multiple countries to accomodate common shopping settings across countries.

Array of objects (Discount)

Available if the relation discounts is expanded.

Array of objects (Gift Card)

Available if the relation gift_cards is expanded.

customer
object or null

A customer object. Available if the relation customer is expanded.

payment_sessions
Array of objects

The payment sessions created on the cart.

payment
object or null

Available if the relation payment is expanded.

Array of objects (Shipping Method)

The shipping methods added to the cart.

sales_channel_id
string or null
Example: null

The sales channel ID the cart is associated with.

object (Sales Channel)

A Sales Channel

shipping_total
integer
Example: 1000

The total of shipping

discount_total
integer
Example: 800

The total of discount rounded

raw_discount_total
integer
Example: 800

The total of discount

item_tax_total
integer
Example: 8000

The total of items with taxes

shipping_tax_total
integer
Example: 1000

The total of shipping with taxes

tax_total
integer
Example: 0

The total of tax

refunded_total
integer
Example: 0

The total amount refunded if the order associated with this cart is returned.

total
integer
Example: 8200

The total amount of the cart

subtotal
integer
Example: 8000

The subtotal of the cart

refundable_amount
integer
Example: 8200

The amount that can be refunded

gift_card_total
integer
Example: 0

The total of gift cards

gift_card_tax_total
integer
Example: 0

The total of gift cards with taxes

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.carts.lineItems.delete(cart_id, line_id)
.then(({ cart }) => {
  console.log(cart.id);
});

Response samples

Content type
application/json
{
  • "cart": {
    }
}

Select a Payment Session

Selects a Payment Session as the session intended to be used towards the completion of the Cart.

path Parameters
id
required
string

The ID of the Cart.

Request Body schema: application/json
provider_id
required
string

The ID of the Payment Provider.

Responses

Response Schema: application/json
required
object (Cart)

Represents a user cart

billing_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The billing address's ID

completed_at
required
string or null <date-time>

The date with timezone at which the cart was completed.

context
required
object or null
Example: {"ip":"::1","user_agent":"PostmanRuntime/7.29.2"}

The context of the cart which can include info like IP or user agent.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

customer_id
required
string or null
Example: "cus_01G2SG30J8C85S4A5CHM2S1NS2"

The customer's ID

deleted_at
required
string or null <date-time>

The date with timezone at which the resource was deleted.

email
required
string or null <email>

The email associated with the cart

id
required
string
Example: "cart_01G8ZH853Y6TFXWPG5EYE81X63"

The cart's ID

idempotency_key
required
string or null

Randomly generated key used to continue the completion of a cart in case of failure.

metadata
required
object or null
Example: {"car":"white"}

An optional key-value map with additional details

payment_authorized_at
required
string or null <date-time>

The date with timezone at which the payment was authorized.

payment_id
required
string or null
Example: "pay_01G8ZCC5W42ZNY842124G7P5R9"

The payment's ID if available

payment_session
required
object or null

The selected payment session in the cart.

region_id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The region's ID

shipping_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The shipping address's ID

type
required
string
Default: "default"
Enum: "default" "swap" "draft_order" "payment_link" "claim"

The cart's type.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

object (Address)

An address.

object (Address)

An address.

Array of objects (Line Item)

Available if the relation items is expanded.

object (Region)

Regions hold settings for how Customers in a given geographical location shop. The is, for example, where currencies and tax rates are defined. A Region can consist of multiple countries to accomodate common shopping settings across countries.

Array of objects (Discount)

Available if the relation discounts is expanded.

Array of objects (Gift Card)

Available if the relation gift_cards is expanded.

customer
object or null

A customer object. Available if the relation customer is expanded.

payment_sessions
Array of objects

The payment sessions created on the cart.

payment
object or null

Available if the relation payment is expanded.

Array of objects (Shipping Method)

The shipping methods added to the cart.

sales_channel_id
string or null
Example: null

The sales channel ID the cart is associated with.

object (Sales Channel)

A Sales Channel

shipping_total
integer
Example: 1000

The total of shipping

discount_total
integer
Example: 800

The total of discount rounded

raw_discount_total
integer
Example: 800

The total of discount

item_tax_total
integer
Example: 8000

The total of items with taxes

shipping_tax_total
integer
Example: 1000

The total of shipping with taxes

tax_total
integer
Example: 0

The total of tax

refunded_total
integer
Example: 0

The total amount refunded if the order associated with this cart is returned.

total
integer
Example: 8200

The total amount of the cart

subtotal
integer
Example: 8000

The subtotal of the cart

refundable_amount
integer
Example: 8200

The amount that can be refunded

gift_card_total
integer
Example: 0

The total of gift cards

gift_card_tax_total
integer
Example: 0

The total of gift cards with taxes

Request samples

Content type
application/json
{
  • "provider_id": "string"
}

Response samples

Content type
application/json
{
  • "cart": {