Skip to main content

Medusa Admin API (1.0.0)

Download OpenAPI specification:Download

License: MIT

API reference for Medusa's Admin endpoints. All endpoints are prefixed with /admin.

Authentication

There are two ways to send authenticated requests to the Medusa server: Using a user's API token, or using a Cookie Session ID.

API Token

Use a user's API Token to send authenticated requests.

How to Add API Token to a User

At the moment, there's no direct way of adding an API Token for a user. The only way it can be done is through directly editing the database.

If you're using a PostgreSQL database, you can run the following commands in your command line to add API token:

psql -d <DB_NAME> -U <DB_USER>
UPDATE public.user SET api_token='<API_TOKEN>' WHERE email='<USER_EMAIL>';

Where:

  • <DB_NAME> is the name of the database schema you use for the Medusa server.
  • <DB_USER> is the name of the user that has privileges over the database schema.
  • <API_TOKEN> is the API token you want to associate with the user. You can use this tool to generate a random token.
  • <USER_EMAIL> is the email address of the admin user you want to have this API token.

How to Use the API Token

The API token can be used for Bearer Authentication. It's passed in the Authorization header as the following:

Authorization: Bearer {api_token}

In this API reference, you'll find in the cURL request samples the use of {api_token}. This is where you must pass the API token.

If you're following along with the JS Client request samples, you must provide the apiKey option when creating the Medusa client:

const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3, apiKey: '{api_token}' })

If you're using Medusa React, you can pass the apiKey prop to MedusaProvider:

<MedusaProvider
  apiKey='api_token}'
  //...
>
Security Scheme Type: HTTP
HTTP Authorization Scheme: bearer

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 admin user 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 user and pass the cURL option -v:

curl -v --location --request POST 'https://medusa-url.com/admin/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/admin/products' \
--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 products, you can retrieve their collection by passing to the expand query parameter the value collection:

curl "http://localhost:9000/admin/products?expand=collection" \
-H 'Authorization: Bearer {api_token}'

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 products, pass to the expand query parameter the value variants,collection:

curl "http://localhost:9000/admin/products?expand=variants,collection" \
-H 'Authorization: Bearer {api_token}'

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/admin/products?expand" \
-H 'Authorization: Bearer {api_token}'

This would retrieve each 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/admin/products?fields=title" \
-H 'Authorization: Bearer {api_token}'

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/admin/products?fields=title&expand" \
-H 'Authorization: Bearer {api_token}'

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 products:

curl "http://localhost:9000/admin/products?fields=title,handle" \
-H 'Authorization: Bearer {api_token}'

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/admin/products?fields" \
-H 'Authorization: Bearer {api_token}'

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/admin/products?fields&expand" \
-H 'Authorization: Bearer {api_token}'

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/admin/products?title=Shirt" \
-H 'Authorization: Bearer {api_token}'

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/admin/products?title=Blue%20Shirt" \
-H 'Authorization: Bearer {api_token}'

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/admin/products?offset=1" \
-H 'Authorization: Bearer {api_token}'

Boolean

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

For example:

curl "http://localhost:9000/admin/products?is_giftcard=true" \
-H 'Authorization: Bearer {api_token}'

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/admin/products?created_at[lt]=2023-02-17" \
-H 'Authorization: Bearer {api_token}'

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/admin/products?created_at[lt]=2023-02-17T07:22:30Z" \
-H 'Authorization: Bearer {api_token}'

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/admin/products?sales_channel_id[]=sc_01GPGVB42PZ7N3YQEP2WDM7PC7&sales_channel_id[]=sc_234PGVB42PZ7N3YQEP2WDM7PC7" \
-H 'Authorization: Bearer {api_token}'

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/admin/products?created_at[lt]=2023-02-17&created_at[gt]=2022-09-17" \
-H 'Authorization: Bearer {api_token}'

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/admin/products?limit=5" \
-H 'Authorization: Bearer {api_token}'

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/admin/products?order=created_at" \
-H 'Authorization: Bearer {api_token}'

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/admin/products?order=-created_at" \
-H 'Authorization: Bearer {api_token}'

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

Apps Oauth

Some plugins may require to authenticate with third-party services and store authentication details, such as the authentication token. To do that, they can create an Oauth provider within the plugin that handles the authentication. The Apps Oauth endpoints allows admins to manage and generate token for an app using its oauth provider.

List Applications

Retrieve a list of applications registered in the Medusa backend.

Authorizations:
API TokenCookie Session ID

Responses

Response Schema: application/json
required
Array of objects (OAuth)

An array of app details.

Array
application_name
required
string
Example: "example"

The app's name

data
required
object or null
Example: {}

Any data necessary to the app.

display_name
required
string
Example: "Example app"

The app's display name

id
required
string
Example: "example_app"

The app's ID

install_url
required
string or null <uri>

The URL to install the app

uninstall_url
required
string or null <uri>

The URL to uninstall the app

Request samples

curl 'https://medusa-url.com/admin/apps' \
-H 'Authorization: Bearer {api_token}'

Response samples

Content type
application/json
{}

Generate Token for App

Use an app's Oauth provider to generate and store a new token for authentication.

Authorizations:
API TokenCookie Session ID
Request Body schema: application/json
application_name
required
string

Name of the application for to generate the token for.

state
required
string

State of the application.

code
required
string

The code for the generated token.

Responses

Response Schema: application/json
required
object (OAuth)

An Oauth app is typically created by a plugin to handle authentication to third-party services.

application_name
required
string
Example: "example"

The app's name

data
required
object or null
Example: {}

Any data necessary to the app.

display_name
required
string
Example: "Example app"

The app's display name

id
required
string
Example: "example_app"

The app's ID

install_url
required
string or null <uri>

The URL to install the app

uninstall_url
required
string or null <uri>

The URL to uninstall the app

Request samples

Content type
application/json
{
  • "application_name": "string",
  • "state": "string",
  • "code": "string"
}

Response samples

Content type
application/json
{}

Auth

Authentication endpoints allow admin users to manage their session, such as login or log out. When an admin user is logged in, the cookie header is set indicating the admin's login session.

Get Current User

Get the currently logged in user's details.

Authorizations:
API TokenCookie Session ID

Responses

Response Schema: application/json
required
object (User)

A User is an administrator who can manage store settings and data.

api_token
required
string or null
Example: null

An API token associated with the user.

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 email of the User

first_name
required
string or null
Example: "Levi"

The first name of the User

id
required
string
Example: "usr_01G1G5V26F5TB3GPAPNJ8X1S3V"

The user's ID

last_name
required
string or null
Example: "Bogan"

The last name of the User

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

An optional key-value map with additional details

role
required
string
Default: "member"
Enum: "admin" "member" "developer"

The user's role. These roles don't provide any different privileges.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

Request samples

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

Response samples

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

User Login

Log a User in and includes the Cookie session in the response header. The cookie session can be used in subsequent requests to authorize the user to perform admin functionalities. When using Medusa's JS or Medusa React clients, the cookie is automatically attached to subsequent requests.

Request Body schema: application/json
email
required
string <email>

The user's email.

password
required
string <password>

The user's password.

Responses

Response Schema: application/json
required
object (User)

A User is an administrator who can manage store settings and data.

api_token
required
string or null
Example: null

An API token associated with the user.

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 email of the User

first_name
required
string or null
Example: "Levi"

The first name of the User

id
required
string
Example: "usr_01G1G5V26F5TB3GPAPNJ8X1S3V"

The user's ID

last_name
required
string or null
Example: "Bogan"

The last name of the User

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

An optional key-value map with additional details

role
required
string
Default: "member"
Enum: "admin" "member" "developer"

The user's role. These roles don't provide any different privileges.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

Request samples

Content type
application/json
{
  • "email": "user@example.com",
  • "password": "pa$$word"
}

Response samples

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

User Logout

Delete the current session for the logged in user. This will only work if you're using Cookie session for authentication. If the API token is still passed in the header, the user is still authorized to perform admin functionalities in other endpoints.

Authorizations:
API TokenCookie Session ID

Responses

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in
medusa.admin.auth.deleteSession()

Response samples

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

Batch Jobs

A batch job is a task that is performed by the Medusa backend asynchronusly. For example, the Import Product feature is implemented using batch jobs. Batch Job endpoints allows admins to manage the batch jobs and their state.

List Batch Jobs

Retrieve a list of Batch Jobs. The batch jobs can be filtered by fields such as type or confirmed_at. The batch jobs can also be sorted or paginated.

Authorizations:
API TokenCookie Session ID
query Parameters
limit
integer
Default: 10

Limit the number of batch jobs returned.

offset
integer
Default: 0

The number of batch jobs to skip when retrieving the batch jobs.

string or Array of strings

Filter by the batch ID

type
Array of strings

Filter by the batch type

object

Filter by a confirmation date range.

object

Filter by a pre-processing date range.

object

Filter by a completion date range.

object

Filter by a failure date range.

object

Filter by a cancelation date range.

order
string

A batch-job field to sort-order the retrieved batch jobs by.

expand
string

Comma-separated relations that should be expanded in the returned batch jobs.

fields
string

Comma-separated fields that should be included in the returned batch jobs.

object

Filter by a creation date range.

object

Filter by an update date range.

Responses

Response Schema: application/json
required
Array of objects (Batch Job)

An array of batch job details.

count
required
integer

The total number of items available

offset
required
integer

The number of batch jobs skipped when retrieving the batch jobs.

limit
required
integer

The number of items per page

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.batchJobs.list()
.then(({ batch_jobs, limit, offset, count }) => {
  console.log(batch_jobs.length)
})

Response samples

Content type
application/json
{
  • "batch_jobs": [
    ],
  • "count": 0,
  • "offset": 0,
  • "limit": 0
}

Create a Batch Job

Create a Batch Job to be executed asynchronously in the Medusa backend. If dry_run is set to true, the batch job will not be executed until the it is confirmed, which can be done using the Confirm Batch Job endpoint.

Authorizations:
API TokenCookie Session ID
Request Body schema: application/json
type
required
string
Example: "product-export"

The type of batch job to start, which is defined by the batchType property of the associated batch job strategy.

context
required
object
Example: {"shape":{"prices":[{"region":null,"currency_code":"eur"}],"dynamicImageColumnCount":4,"dynamicOptionColumnCount":2},"list_config":{"skip":0,"take":50,"order":{"created_at":"DESC"},"relations":["variants","variant.prices","images"]}}

Additional infomration regarding the batch to be used for processing.

dry_run
boolean
Default: false

Set a batch job in dry_run mode, which would delay executing the batch job until it's confirmed.

Responses

Request samples

Content type
application/json
{
  • "type": "product-export",
  • "context": {
    },
  • "dry_run": false
}

Response samples

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

Get a Batch Job

Retrieve the details of a batch job.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Batch Job

Responses

Response Schema: application/json
required
object (Batch Job)

A Batch Job indicates an asynchronus task stored in the Medusa backend. Its status determines whether it has been executed or not.

canceled_at
required
string or null <date-time>

The date of the concellation.

completed_at
required
string or null <date-time>

The date of the completion.

confirmed_at
required
string or null <date-time>

The date when the confirmation has been done.

context
required
object or null
Example: {"shape":{"prices":[{"region":null,"currency_code":"eur"}],"dynamicImageColumnCount":4,"dynamicOptionColumnCount":2},"list_config":{"skip":0,"take":50,"order":{"created_at":"DESC"},"relations":["variants","variant.prices","images"]}}

The context of the batch job, the type of the batch job determines what the context should contain.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

created_by
required
string or null
Example: "usr_01G1G5V26F5TB3GPAPNJ8X1S3V"

The unique identifier of the user that created the batch job.

deleted_at
required
string or null <date-time>

The date with timezone at which the resource was deleted.

dry_run
required
boolean
Default: false

Specify if the job must apply the modifications or not.

failed_at
required
string or null <date-time>

The date when the job failed.

id
required
string
Example: "batch_01G8T782965PYFG0751G0Z38B4"

The unique identifier for the batch job.

pre_processed_at
required
string or null <date-time>

The date from which the job has been pre-processed.

processing_at
required
string or null <date-time>

The date the job is processing at.

required
object or null
Example: {}

The result of the batch job.

status
required
string
Default: "created"
Enum: "created" "pre_processed" "confirmed" "processing" "completed" "canceled" "failed"

The status of the batch job.

type
required
string
Enum: "product-import" "product-export"

The type of batch job.

updated_at
required
string <date-time>

The date with timezone at which the resource was last updated.

object (User)

A User is an administrator who can manage store settings and data.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.batchJobs.retrieve(batchJobId)
.then(({ batch_job }) => {
  console.log(batch_job.id);
});

Response samples

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

Cancel a Batch Job

Mark a batch job as canceled. When a batch job is canceled, the processing of the batch job doesn’t automatically stop.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the batch job.

Responses

Response Schema: application/json
required
object (Batch Job)

A Batch Job indicates an asynchronus task stored in the Medusa backend. Its status determines whether it has been executed or not.

canceled_at
required
string or null <date-time>

The date of the concellation.

completed_at
required
string or null <date-time>

The date of the completion.

confirmed_at
required
string or null <date-time>

The date when the confirmation has been done.

context
required
object or null
Example: {"shape":{"prices":[{"region":null,"currency_code":"eur"}],"dynamicImageColumnCount":4,"dynamicOptionColumnCount":2},"list_config":{"skip":0,"take":50,"order":{"created_at":"DESC"},"relations":["variants","variant.prices","images"]}}

The context of the batch job, the type of the batch job determines what the context should contain.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

created_by
required
string or null
Example: "usr_01G1G5V26F5TB3GPAPNJ8X1S3V"

The unique identifier of the user that created the batch job.

deleted_at
required
string or null <date-time>

The date with timezone at which the resource was deleted.

dry_run
required
boolean
Default: false

Specify if the job must apply the modifications or not.

failed_at
required
string or null <date-time>

The date when the job failed.

id
required
string
Example: "batch_01G8T782965PYFG0751G0Z38B4"

The unique identifier for the batch job.

pre_processed_at
required
string or null <date-time>

The date from which the job has been pre-processed.

processing_at
required
string or null <date-time>

The date the job is processing at.

required
object or null
Example: {}

The result of the batch job.

status
required
string
Default: "created"
Enum: "created" "pre_processed" "confirmed" "processing" "completed" "canceled" "failed"

The status of the batch job.

type
required
string
Enum: "product-import" "product-export"

The type of batch job.

updated_at
required
string <date-time>

The date with timezone at which the resource was last updated.

object (User)

A User is an administrator who can manage store settings and data.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.batchJobs.cancel(batchJobId)
.then(({ batch_job }) => {
  console.log(batch_job.id);
});

Response samples

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

Confirm a Batch Job

When a batch job is created, it is not executed automatically if dry_run is set to true. This endpoint confirms that the batch job should be executed.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the batch job.

Responses

Response Schema: application/json
required
object (Batch Job)

A Batch Job indicates an asynchronus task stored in the Medusa backend. Its status determines whether it has been executed or not.

canceled_at
required
string or null <date-time>

The date of the concellation.

completed_at
required
string or null <date-time>

The date of the completion.

confirmed_at
required
string or null <date-time>

The date when the confirmation has been done.

context
required
object or null
Example: {"shape":{"prices":[{"region":null,"currency_code":"eur"}],"dynamicImageColumnCount":4,"dynamicOptionColumnCount":2},"list_config":{"skip":0,"take":50,"order":{"created_at":"DESC"},"relations":["variants","variant.prices","images"]}}

The context of the batch job, the type of the batch job determines what the context should contain.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

created_by
required
string or null
Example: "usr_01G1G5V26F5TB3GPAPNJ8X1S3V"

The unique identifier of the user that created the batch job.

deleted_at
required
string or null <date-time>

The date with timezone at which the resource was deleted.

dry_run
required
boolean
Default: false

Specify if the job must apply the modifications or not.

failed_at
required
string or null <date-time>

The date when the job failed.

id
required
string
Example: "batch_01G8T782965PYFG0751G0Z38B4"

The unique identifier for the batch job.

pre_processed_at
required
string or null <date-time>

The date from which the job has been pre-processed.

processing_at
required
string or null <date-time>

The date the job is processing at.

required
object or null
Example: {}

The result of the batch job.

status
required
string
Default: "created"
Enum: "created" "pre_processed" "confirmed" "processing" "completed" "canceled" "failed"

The status of the batch job.

type
required
string
Enum: "product-import" "product-export"

The type of batch job.

updated_at
required
string <date-time>

The date with timezone at which the resource was last updated.

object (User)

A User is an administrator who can manage store settings and data.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.batchJobs.confirm(batchJobId)
.then(({ batch_job }) => {
  console.log(batch_job.id);
});

Response samples

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

Currencies

A store can use unlimited currencies, and each region must be associated with at least one currency. Currencies are defined within the Medusa backend. Currency endpoints allow admins to list and update currencies.

List Currency

Retrieve a list of currencies. The currencies can be filtered by fields such as code. The currencies can also be sorted or paginated.

query Parameters
code
string

filter by currency code.

includes_tax
boolean

filter currencies by whether they include taxes or not.

order
string

A field to sort order the retrieved currencies by.

offset
number
Default: "0"

The number of currencies to skip when retrieving the currencies.

limit
number
Default: "20"

The number of currencies to return.

Responses

Response Schema: application/json
required
Array of objects (Currency)

An array of currency details.

count
required
integer

The total number of items available

offset
required
integer

The number of currencies skipped when retrieving the currencies.

limit
required
integer

The number of items per page

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.currencies.list()
.then(({ currencies, count, offset, limit }) => {
  console.log(currencies.length);
});

Response samples

Content type
application/json
{
  • "currencies": [
    ],
  • "count": 0,
  • "offset": 0,
  • "limit": 0
}

Update a Currency

Update a Currency's details.

path Parameters
code
required
string

The code of the Currency.

Request Body schema: application/json
includes_tax
boolean

Tax included in prices of currency.

Responses

Response Schema: application/json
required
object (Currency)

Currency

code
required
string
Example: "usd"

The 3 character ISO code for the currency.

name
required
string
Example: "US Dollar"

The written name of the currency

symbol
required
string
Example: "$"

The symbol used to indicate the currency.

symbol_native
required
string
Example: "$"

The native symbol used to indicate the currency.

includes_tax
boolean
Default: false

Whether the currency prices include tax

Request samples

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

Response samples

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

Customer Groups

Customer Groups can be used to organize customers that share similar data or attributes into dedicated groups. This can be useful for different purposes such as setting a different price for a specific customer group.

List Customer Groups

Retrieve a list of customer groups. The customer groups can be filtered by fields such as name or `id. The customer groups can also be sorted or paginated.

Authorizations:
API TokenCookie Session ID
query Parameters
q
string

term to search customer groups by name.

offset
integer
Default: 0

The number of customer groups to skip when retrieving the customer groups.

order
string

A field to sort order the retrieved customer groups by.

discount_condition_id
string

Filter by discount condition ID.

string or Array of strings or object

Filter by the customer group ID

name
Array of strings

Filter by the customer group name

object

Filter by a creation date range.

object

Filter by an update date range.

limit
integer
Default: 10

The number of customer groups to return.

expand
string

Comma-separated relations that should be expanded in the returned customer groups.

Responses

Response Schema: application/json
required
Array of objects (Customer Group)

An array of customer group details.

count
required
integer

The total number of items available

offset
required
integer

The number of customer groups skipped when retrieving the customer groups.

limit
required
integer

The number of items per page

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.customerGroups.list()
.then(({ customer_groups, limit, offset, count }) => {
  console.log(customer_groups.length);
});

Response samples

Content type
application/json
{
  • "customer_groups": [
    ],
  • "count": 0,
  • "offset": 0,
  • "limit": 0
}

Create a Customer Group

Creates a Customer Group.

Authorizations:
API TokenCookie Session ID
Request Body schema: application/json
name
required
string

Name of the customer group

metadata

Responses

Response Schema: application/json
required
object (Customer Group)

A customer group that can be used to organize customers into groups of similar traits.

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.

id
required
string
Example: "cgrp_01G8ZH853Y6TFXWPG5EYE81X63"

The customer group's ID

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

An optional key-value map with additional details

name
required
string
Example: "VIP"

The name of the customer group

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

customers
Array of objects

The details of the customers that belong to the customer group.

price_lists
Array of objects

The price lists that are associated with the customer group.

Request samples

Content type
application/json
{
  • "name": "string",
  • "metadata": { }
}

Response samples

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

Get a Customer Group

Retrieve a Customer Group by its ID. You can expand the customer group's relations or select the fields that should be returned.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Customer Group.

query Parameters
expand
string

Comma-separated relations that should be expanded in the returned customer group.

fields
string

Comma-separated fields that should be included in the returned customer group.

Responses

Response Schema: application/json
required
object (Customer Group)

A customer group that can be used to organize customers into groups of similar traits.

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.

id
required
string
Example: "cgrp_01G8ZH853Y6TFXWPG5EYE81X63"

The customer group's ID

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

An optional key-value map with additional details

name
required
string
Example: "VIP"

The name of the customer group

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

customers
Array of objects

The details of the customers that belong to the customer group.

price_lists
Array of objects

The price lists that are associated with the customer group.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.customerGroups.retrieve(customerGroupId)
.then(({ customer_group }) => {
  console.log(customer_group.id);
});

Response samples

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

Update a Customer Group

Update a Customer Group's details.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the customer group.

Request Body schema: application/json
name
string

Name of the customer group

metadata

Responses

Response Schema: application/json
required
object (Customer Group)

A customer group that can be used to organize customers into groups of similar traits.

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.

id
required
string
Example: "cgrp_01G8ZH853Y6TFXWPG5EYE81X63"

The customer group's ID

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

An optional key-value map with additional details

name
required
string
Example: "VIP"

The name of the customer group

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

customers
Array of objects

The details of the customers that belong to the customer group.

price_lists
Array of objects

The price lists that are associated with the customer group.

Request samples

Content type
application/json
{
  • "name": "string",
  • "metadata": { }
}

Response samples

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

Delete a Customer Group

Delete a customer group. This doesn't delete the customers associated with the customer group.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Customer Group

Responses

Response Schema: application/json
id
required
string

The ID of the deleted customer group.

object
required
string
Default: "customer_group"

The type of the object that was deleted.

deleted
required
boolean
Default: true

Whether the customer group was deleted successfully or not.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.customerGroups.delete(customerGroupId)
.then(({ id, object, deleted }) => {
  console.log(id);
});

Response samples

Content type
application/json
{
  • "id": "string",
  • "object": "customer_group",
  • "deleted": true
}

List Customers

Retrieve a list of customers in a customer group. The customers can be filtered by the q field. The customers can also be paginated.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the customer group.

query Parameters
limit
integer
Default: 50

The number of customers to return.

offset
integer
Default: 0

The number of customers to skip when retrieving the customers.

expand
string

Comma-separated relations that should be expanded in the returned customers.

q
string

a term to search customers by email, first_name, and last_name.

Responses

Response Schema: application/json
required
Array of objects (Customer)

An array of customer details.

count
required
integer

The total number of items available

offset
required
integer

The number of customers skipped when retrieving the customers.

limit
required
integer

The number of items per page

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.customerGroups.listCustomers(customerGroupId)
.then(({ customers }) => {
  console.log(customers.length);
});

Response samples

Content type
application/json
{
  • "customers": [
    ],
  • "count": 0,
  • "offset": 0,
  • "limit": 0
}

Add Customers to Group

Add a list of customers to a customer group.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the customer group.

Request Body schema: application/json
required
Array of objects

The ids of the customers to add

Array
id
required
string

ID of the customer

Responses

Response Schema: application/json
required
object (Customer Group)

A customer group that can be used to organize customers into groups of similar traits.

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.

id
required
string
Example: "cgrp_01G8ZH853Y6TFXWPG5EYE81X63"

The customer group's ID

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

An optional key-value map with additional details

name
required
string
Example: "VIP"

The name of the customer group

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

customers
Array of objects

The details of the customers that belong to the customer group.

price_lists
Array of objects

The price lists that are associated with the customer group.

Request samples

Content type
application/json
{
  • "customer_ids": [
    ]
}

Response samples

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

Remove Customers from Group

Remove a list of customers from a customer group. This doesn't delete the customer, only the association between the customer and the customer group.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the customer group.

Request Body schema: application/json
required
Array of objects

The ids of the customers to remove

Array
id
required
string

ID of the customer

Responses

Response Schema: application/json
required
object (Customer Group)

A customer group that can be used to organize customers into groups of similar traits.

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.

id
required
string
Example: "cgrp_01G8ZH853Y6TFXWPG5EYE81X63"

The customer group's ID

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

An optional key-value map with additional details

name
required
string
Example: "VIP"

The name of the customer group

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

customers
Array of objects

The details of the customers that belong to the customer group.

price_lists
Array of objects

The price lists that are associated with the customer group.

Request samples

Content type
application/json
{
  • "customer_ids": [
    ]
}

Response samples

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

Customers

Customers can either be created when they register through the Store APIs, or created by the admin using the Admin APIs.

List Customers

Retrieve a list of Customers. The customers can be filtered by fields such as q or groups. The customers can also be paginated.

Authorizations:
API TokenCookie Session ID
query Parameters
limit
integer
Default: 50

The number of customers to return.

offset
integer
Default: 0

The number of customers to skip when retrieving the customers.

expand
string

Comma-separated relations that should be expanded in the returned customer.

q
string

term to search customers' email, first_name, and last_name fields.

groups
Array of strings

Filter by customer group IDs.

Responses

Response Schema: application/json
required
Array of objects (Customer)

An array of customer details.

count
required
integer

The total number of items available

offset
required
integer

The number of customers skipped when retrieving the customers.

limit
required
integer

The number of items per page

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.customers.list()
.then(({ customers, limit, offset, count }) => {
  console.log(customers.length);
});

Response samples

Content type
application/json
{
  • "customers": [
    ],
  • "count": 0,
  • "offset": 0,
  • "limit": 0
}

Create a Customer

Allow admins to create a customer.

Authorizations:
API TokenCookie Session ID
Request Body schema: application/json
email
required
string <email>

The customer's email.

first_name
required
string

The customer's first name.

last_name
required
string

The customer's last name.

password
required
string <password>

The customer's password.

phone
string

The customer's phone number.

metadata
object

An optional set of key-value pairs to hold additional information.

Responses

Request samples

Content type
application/json
{
  • "email": "user@example.com",
  • "first_name": "string",
  • "last_name": "string",
  • "password": "pa$$word",
  • "phone": "string",
  • "metadata": { }
}

Response samples

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

Get a Customer

Retrieve the details of a customer.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Customer.

query Parameters
expand
string

Comma-separated relations that should be expanded in the returned customer.

fields
string

Comma-separated fields that should be included in the returned customer.

Responses

Response Schema: application/json
required
object (Customer)

A customer can make purchases in your store and manage their profile.

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 is used across the Medusa backend within other schemas and object types. For example, a customer's billing and shipping addresses both use the Address entity.

Array of objects (Address)

The details of the shipping addresses associated with the customer.

orders
Array of objects

The details of the orders this customer placed.

Array of objects (Customer Group)

The customer groups the customer belongs to.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.customers.retrieve(customerId)
.then(({ customer }) => {
  console.log(customer.id);
});

Response samples

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

Update a Customer

Update a Customer's details.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Customer.

query Parameters
expand
string

Comma-separated relations that should be expanded in the returned customer.

fields
string

Comma-separated fields that should be retrieved in the returned customer.

Request Body schema: application/json
email
string <email>

The Customer's email.

first_name
string

The Customer's first name.

last_name
string

The Customer's last name.

phone
string

The Customer's phone number.

password
string <password>

The Customer's password.

Array of objects

A list of customer groups to which the customer belongs.

metadata
object

An optional set of key-value pairs to hold additional information.

Responses

Response Schema: application/json
required
object (Customer)

A customer can make purchases in your store and manage their profile.

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 is used across the Medusa backend within other schemas and object types. For example, a customer's billing and shipping addresses both use the Address entity.

Array of objects (Address)

The details of the shipping addresses associated with the customer.

orders
Array of objects

The details of the orders this customer placed.

Array of objects (Customer Group)

The customer groups the customer belongs to.

Request samples

Content type
application/json
{
  • "email": "user@example.com",
  • "first_name": "string",
  • "last_name": "string",
  • "phone": "string",
  • "password": "pa$$word",
  • "groups": [
    ],
  • "metadata": { }
}

Response samples

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

Discounts

Admins can create discounts with conditions and rules, providing them with advanced settings for variety of cases. The Discount endpoints can be used to manage discounts, their conditions, resources, and more.

List Discounts

Retrieve a list of Discounts. The discounts can be filtered by fields such as rule or is_dynamic. The discounts can also be paginated.

Authorizations:
API TokenCookie Session ID
query Parameters
q
string

term to search discounts' code field.

object

Filter discounts by rule fields.

is_dynamic
boolean

Filter discounts by whether they're dynamic or not.

is_disabled
boolean

Filter discounts by whether they're disabled or not.

limit
number
Default: "20"

The number of discounts to return

offset
number
Default: "0"

The number of discounts to skip when retrieving the discounts.

expand
string

Comma-separated relations that should be expanded in each returned discount.

Responses

Response Schema: application/json
required
Array of objects (Discount)
count
required
integer

The total number of items available

offset
required
integer

The number of discounts skipped when retrieving the discounts.

limit
required
integer

The number of items per page

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.discounts.list()
.then(({ discounts, limit, offset, count }) => {
  console.log(discounts.id);
});

Response samples

Content type
application/json
{
  • "discounts": [
    ],
  • "count": 0,
  • "offset": 0,
  • "limit": 0
}

Create a Discount

Create a Discount with a given set of rules that defines how the Discount is applied.

Authorizations:
API TokenCookie Session ID
query Parameters
expand
string

Comma-separated relations that should be expanded in the returned discount.

fields
string

Comma-separated fields that should be retrieved in the returned discount.

Request Body schema: application/json
code
required
string

A unique code that will be used to redeem the discount

required
object

The discount rule that defines how discounts are calculated

regions
required
Array of strings

A list of region IDs representing the Regions in which the Discount can be used.

is_dynamic
boolean
Default: false

Whether the discount should have multiple instances of itself, each with a different code. This can be useful for automatically generated discount codes that all have to follow a common set of rules.

is_disabled
boolean
Default: false

Whether the discount code is disabled on creation. If set to true, it will not be available for customers.

starts_at
string <date-time>

The date and time at which the discount should be available.

ends_at
string <date-time>

The date and time at which the discount should no longer be available.

valid_duration
string
Example: "P3Y6M4DT12H30M5S"

The duration the discount runs between

usage_limit
number

Maximum number of times the discount can be used

metadata
object

An optional set of key-value pairs to hold additional information.

Responses

Response Schema: application/json
required
object (Discount)

A discount can be applied to a cart for promotional purposes.

code
required
string
Example: "10DISC"

A unique code for the discount - this will be used by the customer to apply the discount

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.

ends_at
required
string or null <date-time>

The time at which the discount can no longer be used.

id
required
string
Example: "disc_01F0YESMW10MGHWJKZSDDMN0VN"

The discount's ID

is_disabled
required
boolean
Example: false

Whether the Discount has been disabled. Disabled discounts cannot be applied to carts

is_dynamic
required
boolean
Example: false

A flag to indicate if multiple instances of the discount can be generated. I.e. for newsletter discounts

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

An optional key-value map with additional details

parent_discount_id
required
string or null
Example: "disc_01G8ZH853YPY9B94857DY91YGW"

The Discount that the discount was created from. This will always be a dynamic discount

rule_id
required
string or null
Example: "dru_01F0YESMVK96HVX7N419E3CJ7C"

The ID of the discount rule that defines how the discount will be applied to a cart.

starts_at
required
string <date-time>

The time at which the discount can be used.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

usage_count
required
integer
Default: 0
Example: 50

The number of times a discount has been used.

usage_limit
required
integer or null
Example: 100

The maximum number of times that a discount can be used.

valid_duration
required
string or null
Example: "P3Y6M4DT12H30M5S"

Duration the discount runs between

object (Discount Rule)

A discount rule defines how a Discount is calculated when applied to a Cart.

parent_discount
object or null

The details of the parent discount that this discount was created from.

Array of objects (Region)

The details of the regions in which the Discount can be used.

Request samples

Content type
application/json
{
  • "code": "string",
  • "is_dynamic": false,
  • "rule": {
    },
  • "is_disabled": false,
  • "starts_at": "2019-08-24T14:15:22Z",
  • "ends_at": "2019-08-24T14:15:22Z",
  • "valid_duration": "P3Y6M4DT12H30M5S",
  • "regions": [
    ],
  • "usage_limit": 0,
  • "metadata": { }
}

Response samples

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

Get Discount by Code

Retrieve a Discount's details by its discount code

Authorizations:
API TokenCookie Session ID
path Parameters
code
required
string

The code of the Discount

query Parameters
expand
string

Comma-separated relations that should be expanded in the returned discount.

fields
string

Comma-separated fields that should be included in the returned discount.

Responses

Response Schema: application/json
required
object (Discount)

A discount can be applied to a cart for promotional purposes.

code
required
string
Example: "10DISC"

A unique code for the discount - this will be used by the customer to apply the discount

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.

ends_at
required
string or null <date-time>

The time at which the discount can no longer be used.

id
required
string
Example: "disc_01F0YESMW10MGHWJKZSDDMN0VN"

The discount's ID

is_disabled
required
boolean
Example: false

Whether the Discount has been disabled. Disabled discounts cannot be applied to carts

is_dynamic
required
boolean
Example: false

A flag to indicate if multiple instances of the discount can be generated. I.e. for newsletter discounts

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

An optional key-value map with additional details

parent_discount_id
required
string or null
Example: "disc_01G8ZH853YPY9B94857DY91YGW"

The Discount that the discount was created from. This will always be a dynamic discount

rule_id
required
string or null
Example: "dru_01F0YESMVK96HVX7N419E3CJ7C"

The ID of the discount rule that defines how the discount will be applied to a cart.

starts_at
required
string <date-time>

The time at which the discount can be used.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

usage_count
required
integer
Default: 0
Example: 50

The number of times a discount has been used.

usage_limit
required
integer or null
Example: 100

The maximum number of times that a discount can be used.

valid_duration
required
string or null
Example: "P3Y6M4DT12H30M5S"

Duration the discount runs between

object (Discount Rule)

A discount rule defines how a Discount is calculated when applied to a Cart.

parent_discount
object or null

The details of the parent discount that this discount was created from.

Array of objects (Region)

The details of the regions in which the Discount can be used.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.discounts.retrieveByCode(code)
.then(({ discount }) => {
  console.log(discount.id);
});

Response samples

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

Create a Condition

Create a Discount Condition. Only one of products, product_types, product_collections, product_tags, and customer_groups should be provided, based on the type of discount condition. For example, if the discount condition's type is products, the products field should be provided in the request body.

Authorizations:
API TokenCookie Session ID
path Parameters
discount_id
required
string

The ID of the discount.

query Parameters
expand
string

Comma-separated relations that should be expanded in the returned discount.

fields
string

Comma-separated fields that should be included in the returned discount.

Request Body schema: application/json
operator
required
string
Enum: "in" "not_in"

Operator of the condition. in indicates that discountable resources are within the specified resources. not_in indicates that discountable resources are everything but the specified resources.

products
Array of strings

list of product IDs if the condition's type is products.

product_types
Array of strings

list of product type IDs if the condition's type is product_types.

product_collections
Array of strings

list of product collection IDs if the condition's type is product_collections.

product_tags
Array of strings

list of product tag IDs if the condition's type is product_tags.

customer_groups
Array of strings

list of customer group IDs if the condition's type is customer_groups.

Responses

Response Schema: application/json
required
object (Discount)

A discount can be applied to a cart for promotional purposes.

code
required
string
Example: "10DISC"

A unique code for the discount - this will be used by the customer to apply the discount

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.

ends_at
required
string or null <date-time>

The time at which the discount can no longer be used.

id
required
string
Example: "disc_01F0YESMW10MGHWJKZSDDMN0VN"

The discount's ID

is_disabled
required
boolean
Example: false

Whether the Discount has been disabled. Disabled discounts cannot be applied to carts

is_dynamic
required
boolean
Example: false

A flag to indicate if multiple instances of the discount can be generated. I.e. for newsletter discounts

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

An optional key-value map with additional details

parent_discount_id
required
string or null
Example: "disc_01G8ZH853YPY9B94857DY91YGW"

The Discount that the discount was created from. This will always be a dynamic discount

rule_id
required
string or null
Example: "dru_01F0YESMVK96HVX7N419E3CJ7C"

The ID of the discount rule that defines how the discount will be applied to a cart.

starts_at
required
string <date-time>

The time at which the discount can be used.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

usage_count
required
integer
Default: 0
Example: 50

The number of times a discount has been used.

usage_limit
required
integer or null
Example: 100

The maximum number of times that a discount can be used.

valid_duration
required
string or null
Example: "P3Y6M4DT12H30M5S"

Duration the discount runs between

object (Discount Rule)

A discount rule defines how a Discount is calculated when applied to a Cart.

parent_discount
object or null

The details of the parent discount that this discount was created from.

Array of objects (Region)

The details of the regions in which the Discount can be used.

Request samples

Content type
application/json
{
  • "operator": "in",
  • "products": [
    ],
  • "product_types": [
    ],
  • "product_collections": [
    ],
  • "product_tags": [
    ],
  • "customer_groups": [
    ]
}

Response samples

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

Get a Condition

Retrieve a Discount Condition's details.

Authorizations:
API TokenCookie Session ID
path Parameters
discount_id
required
string

The ID of the Discount.

condition_id
required
string

The ID of the Discount Condition.

query Parameters
expand
string

Comma-separated relations that should be expanded in the returned discount condition.

fields
string

Comma-separated fields that should be included in the returned discount condition.

Responses

Response Schema: application/json
required
object (Discount Condition)

Holds rule conditions for when a discount is applicable

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.

discount_rule_id
required
string
Example: "dru_01F0YESMVK96HVX7N419E3CJ7C"

The ID of the discount rule associated with the condition

id
required
string
Example: "discon_01G8X9A7ESKAJXG2H0E6F1MW7A"

The discount condition's ID

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

An optional key-value map with additional details

operator
required
string
Enum: "in" "not_in"

The operator of the condition. in indicates that discountable resources are within the specified resources. not_in indicates that discountable resources are everything but the specified resources.

type
required
string
Enum: "products" "product_types" "product_collections" "product_tags" "customer_groups"

The type of the condition. The type affects the available resources associated with the condition. For example, if the type is products, that means the products relation will hold the products associated with this condition and other relations will be empty.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

object (Discount Rule)

A discount rule defines how a Discount is calculated when applied to a Cart.

Array of objects (Product)

products associated with this condition if type is products.

Array of objects (Product Type)

Product types associated with this condition if type is product_types.

Array of objects (Product Tag)

Product tags associated with this condition if type is product_tags.

Array of objects (Product Collection)

Product collections associated with this condition if type is product_collections.

Array of objects (Customer Group)

Customer groups associated with this condition if type is customer_groups.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.discounts.getCondition(discountId, conditionId)
.then(({ discount_condition }) => {
  console.log(discount_condition.id);
});

Response samples

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

Update a Condition

Update a Discount Condition. Only one of products, product_types, product_collections, product_tags, and customer_groups should be provided, based on the type of discount condition. For example, if the discount condition's type is products, the products field should be provided in the request body.

Authorizations:
API TokenCookie Session ID
path Parameters
discount_id
required
string

The ID of the Discount.

condition_id
required
string

The ID of the Discount Condition.

query Parameters
expand
string

Comma-separated relations that should be expanded in the returned discount.

fields
string

Comma-separated fields that should be included in the returned discount.

Request Body schema: application/json
products
Array of strings

list of product IDs if the condition's type is products.

product_types
Array of strings

list of product type IDs if the condition's type is product_types.

product_collections
Array of strings

list of product collection IDs if the condition's type is product_collections.

product_tags
Array of strings

list of product tag IDs if the condition's type is product_tags

customer_groups
Array of strings

list of customer group IDs if the condition's type is customer_groups.

Responses

Response Schema: application/json
required
object (Discount)

A discount can be applied to a cart for promotional purposes.

code
required
string
Example: "10DISC"

A unique code for the discount - this will be used by the customer to apply the discount

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.

ends_at
required
string or null <date-time>

The time at which the discount can no longer be used.

id
required
string
Example: "disc_01F0YESMW10MGHWJKZSDDMN0VN"

The discount's ID

is_disabled
required
boolean
Example: false

Whether the Discount has been disabled. Disabled discounts cannot be applied to carts

is_dynamic
required
boolean
Example: false

A flag to indicate if multiple instances of the discount can be generated. I.e. for newsletter discounts

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

An optional key-value map with additional details

parent_discount_id
required
string or null
Example: "disc_01G8ZH853YPY9B94857DY91YGW"

The Discount that the discount was created from. This will always be a dynamic discount

rule_id
required
string or null
Example: "dru_01F0YESMVK96HVX7N419E3CJ7C"

The ID of the discount rule that defines how the discount will be applied to a cart.

starts_at
required
string <date-time>

The time at which the discount can be used.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

usage_count
required
integer
Default: 0
Example: 50

The number of times a discount has been used.

usage_limit
required
integer or null
Example: 100

The maximum number of times that a discount can be used.

valid_duration
required
string or null
Example: "P3Y6M4DT12H30M5S"

Duration the discount runs between

object (Discount Rule)

A discount rule defines how a Discount is calculated when applied to a Cart.

parent_discount
object or null

The details of the parent discount that this discount was created from.

Array of objects (Region)

The details of the regions in which the Discount can be used.

Request samples

Content type
application/json
{
  • "products": [
    ],
  • "product_types": [
    ],
  • "product_collections": [
    ],
  • "product_tags": [
    ],
  • "customer_groups": [
    ]
}

Response samples

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

Delete a Condition

Deletes a Discount Condition. This does not delete resources associated to the discount condition.

Authorizations:
API TokenCookie Session ID
path Parameters
discount_id
required
string

The ID of the Discount

condition_id
required
string

The ID of the Discount Condition

query Parameters
expand
string

Comma-separated relations that should be expanded in the returned discount.

fields
string

Comma-separated fields that should be included in the returned discount.

Responses

Response Schema: application/json
id
required
string

The ID of the deleted Discount Condition

object
required
string
Default: "discount-condition"

The type of the object that was deleted.

deleted
required
boolean
Default: true

Whether the discount condition was deleted successfully.

required
object (Discount)

A discount can be applied to a cart for promotional purposes.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.discounts.deleteCondition(discountId, conditionId)
.then(({ id, object, deleted }) => {
  console.log(id);
});

Response samples

Content type
application/json
{
  • "id": "string",
  • "object": "discount-condition",
  • "deleted": true,
  • "discount": {
    }
}

Add Batch Resources

Add a batch of resources to a discount condition. The type of resource depends on the type of discount condition. For example, if the discount condition's type is products, the resources being added should be products.

Authorizations:
API TokenCookie Session ID
path Parameters
discount_id
required
string

The ID of the discount the condition belongs to.

condition_id
required
string

The ID of the discount condition on which to add the item.

query Parameters
expand
string

Comma-separated relations that should be expanded in the returned discount.

fields
string

Comma-separated fields that should be included in the returned discount.

Request Body schema: application/json
required
Array of objects

The resources to be added to the discount condition

Array
id
required
string

The id of the item

Responses

Response Schema: application/json
required
object (Discount)

A discount can be applied to a cart for promotional purposes.

code
required
string
Example: "10DISC"

A unique code for the discount - this will be used by the customer to apply the discount

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.

ends_at
required
string or null <date-time>

The time at which the discount can no longer be used.

id
required
string
Example: "disc_01F0YESMW10MGHWJKZSDDMN0VN"

The discount's ID

is_disabled
required
boolean
Example: false

Whether the Discount has been disabled. Disabled discounts cannot be applied to carts

is_dynamic
required
boolean
Example: false

A flag to indicate if multiple instances of the discount can be generated. I.e. for newsletter discounts

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

An optional key-value map with additional details

parent_discount_id
required
string or null
Example: "disc_01G8ZH853YPY9B94857DY91YGW"

The Discount that the discount was created from. This will always be a dynamic discount

rule_id
required
string or null
Example: "dru_01F0YESMVK96HVX7N419E3CJ7C"

The ID of the discount rule that defines how the discount will be applied to a cart.

starts_at
required
string <date-time>

The time at which the discount can be used.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

usage_count
required
integer
Default: 0
Example: 50

The number of times a discount has been used.

usage_limit
required
integer or null
Example: 100

The maximum number of times that a discount can be used.

valid_duration
required
string or null
Example: "P3Y6M4DT12H30M5S"

Duration the discount runs between

object (Discount Rule)

A discount rule defines how a Discount is calculated when applied to a Cart.

parent_discount
object or null

The details of the parent discount that this discount was created from.

Array of objects (Region)

The details of the regions in which the Discount can be used.

Request samples

Content type
application/json
{
  • "resources": [
    ]
}

Response samples

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

Remove Batch Resources

Remove a batch of resources from a discount condition. This will only remove the association between the resource and the discount condition, but not the resource itself.

Authorizations:
API TokenCookie Session ID
path Parameters
discount_id
required
string

The ID of the discount.

condition_id
required
string

The ID of the condition to remove the resources from.

query Parameters
expand
string

Comma-separated relations that should be expanded in the returned discount.

fields
string

Comma-separated fields that should be included in the returned discount.

Request Body schema: application/json
required
Array of objects

The resources to be removed from the discount condition

Array
id
required
string

The id of the item

Responses

Response Schema: application/json
required
object (Discount)

A discount can be applied to a cart for promotional purposes.

code
required
string
Example: "10DISC"

A unique code for the discount - this will be used by the customer to apply the discount

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.

ends_at
required
string or null <date-time>

The time at which the discount can no longer be used.

id
required
string
Example: "disc_01F0YESMW10MGHWJKZSDDMN0VN"

The discount's ID

is_disabled
required
boolean
Example: false

Whether the Discount has been disabled. Disabled discounts cannot be applied to carts

is_dynamic
required
boolean
Example: false

A flag to indicate if multiple instances of the discount can be generated. I.e. for newsletter discounts

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

An optional key-value map with additional details

parent_discount_id
required
string or null
Example: "disc_01G8ZH853YPY9B94857DY91YGW"

The Discount that the discount was created from. This will always be a dynamic discount

rule_id
required
string or null
Example: "dru_01F0YESMVK96HVX7N419E3CJ7C"

The ID of the discount rule that defines how the discount will be applied to a cart.

starts_at
required
string <date-time>

The time at which the discount can be used.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

usage_count
required
integer
Default: 0
Example: 50

The number of times a discount has been used.

usage_limit
required
integer or null
Example: 100

The maximum number of times that a discount can be used.

valid_duration
required
string or null
Example: "P3Y6M4DT12H30M5S"

Duration the discount runs between

object (Discount Rule)

A discount rule defines how a Discount is calculated when applied to a Cart.

parent_discount
object or null

The details of the parent discount that this discount was created from.

Array of objects (Region)

The details of the regions in which the Discount can be used.

Request samples

Content type
application/json
{
  • "resources": [
    ]
}

Response samples

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

Get a Discount

Retrieves a Discount

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Discount

query Parameters
expand
string

Comma-separated relations that should be expanded in the returned discount.

fields
string

Comma-separated fields that should be included in the returned discount.

Responses

Response Schema: application/json
required
object (Discount)

A discount can be applied to a cart for promotional purposes.

code
required
string
Example: "10DISC"

A unique code for the discount - this will be used by the customer to apply the discount

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.

ends_at
required
string or null <date-time>

The time at which the discount can no longer be used.

id
required
string
Example: "disc_01F0YESMW10MGHWJKZSDDMN0VN"

The discount's ID

is_disabled
required
boolean
Example: false

Whether the Discount has been disabled. Disabled discounts cannot be applied to carts

is_dynamic
required
boolean
Example: false

A flag to indicate if multiple instances of the discount can be generated. I.e. for newsletter discounts

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

An optional key-value map with additional details

parent_discount_id
required
string or null
Example: "disc_01G8ZH853YPY9B94857DY91YGW"

The Discount that the discount was created from. This will always be a dynamic discount

rule_id
required
string or null
Example: "dru_01F0YESMVK96HVX7N419E3CJ7C"

The ID of the discount rule that defines how the discount will be applied to a cart.

starts_at
required
string <date-time>

The time at which the discount can be used.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

usage_count
required
integer
Default: 0
Example: 50

The number of times a discount has been used.

usage_limit
required
integer or null
Example: 100

The maximum number of times that a discount can be used.

valid_duration
required
string or null
Example: "P3Y6M4DT12H30M5S"

Duration the discount runs between

object (Discount Rule)

A discount rule defines how a Discount is calculated when applied to a Cart.

parent_discount
object or null

The details of the parent discount that this discount was created from.

Array of objects (Region)

The details of the regions in which the Discount can be used.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.discounts.retrieve(discountId)
.then(({ discount }) => {
  console.log(discount.id);
});

Response samples

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

Update a Discount

Update a Discount with a given set of rules that define how the Discount is applied.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Discount.

query Parameters
expand
string

Comma-separated relations that should be expanded in the returned discount.

fields
string

Comma-separated fields that should be retrieved in the returned discount.

Request Body schema: application/json
code
string

A unique code that will be used to redeem the discount

object

The discount rule that defines how discounts are calculated

is_disabled
boolean

Whether the discount code is disabled on creation. If set to true, it will not be available for customers.

starts_at
string <date-time>

The date and time at which the discount should be available.

ends_at
string <date-time>

The date and time at which the discount should no longer be available.

valid_duration
string
Example: "P3Y6M4DT12H30M5S"

The duration the discount runs between

usage_limit
number

Maximum number of times the discount can be used

regions
Array of strings

A list of region IDs representing the Regions in which the Discount can be used.

metadata
object

An object containing metadata of the discount

Responses

Response Schema: application/json
required
object (Discount)

A discount can be applied to a cart for promotional purposes.

code
required
string
Example: "10DISC"

A unique code for the discount - this will be used by the customer to apply the discount

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.

ends_at
required
string or null <date-time>

The time at which the discount can no longer be used.

id
required
string
Example: "disc_01F0YESMW10MGHWJKZSDDMN0VN"

The discount's ID

is_disabled
required
boolean
Example: false

Whether the Discount has been disabled. Disabled discounts cannot be applied to carts

is_dynamic
required
boolean
Example: false

A flag to indicate if multiple instances of the discount can be generated. I.e. for newsletter discounts

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

An optional key-value map with additional details

parent_discount_id
required
string or null
Example: "disc_01G8ZH853YPY9B94857DY91YGW"

The Discount that the discount was created from. This will always be a dynamic discount

rule_id
required
string or null
Example: "dru_01F0YESMVK96HVX7N419E3CJ7C"

The ID of the discount rule that defines how the discount will be applied to a cart.

starts_at
required
string <date-time>

The time at which the discount can be used.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

usage_count
required
integer
Default: 0
Example: 50

The number of times a discount has been used.

usage_limit
required
integer or null
Example: 100

The maximum number of times that a discount can be used.

valid_duration
required
string or null
Example: "P3Y6M4DT12H30M5S"

Duration the discount runs between

object (Discount Rule)

A discount rule defines how a Discount is calculated when applied to a Cart.

parent_discount
object or null

The details of the parent discount that this discount was created from.

Array of objects (Region)

The details of the regions in which the Discount can be used.

Request samples

Content type
application/json
{
  • "code": "string",
  • "rule": {
    },
  • "is_disabled": true,
  • "starts_at": "2019-08-24T14:15:22Z",
  • "ends_at": "2019-08-24T14:15:22Z",
  • "valid_duration": "P3Y6M4DT12H30M5S",
  • "usage_limit": 0,
  • "regions": [
    ],
  • "metadata": { }
}

Response samples

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

Delete a Discount

Delete a Discount. Deleting the discount will make it unavailable for customers to use.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Discount

Responses

Response Schema: application/json
id
required
string

The ID of the deleted Discount

object
required
string
Default: "discount"

The type of the object that was deleted.

deleted
required
boolean
Default: true

Whether the discount was deleted successfully.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.discounts.delete(discountId)
.then(({ id, object, deleted }) => {
  console.log(id);
});

Response samples

Content type
application/json
{
  • "id": "string",
  • "object": "discount",
  • "deleted": true
}

Create a Dynamic Code

Create a dynamic unique code that can map to a parent Discount. This is useful if you want to automatically generate codes with the same rules and conditions.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Discount to create the dynamic code for."

Request Body schema: application/json
code
required
string

A unique code that will be used to redeem the Discount

usage_limit
number
Default: 1

Maximum number of times the discount code can be used

metadata
object

An optional set of key-value pairs to hold additional information.

Responses

Response Schema: application/json
required
object (Discount)

A discount can be applied to a cart for promotional purposes.

code
required
string
Example: "10DISC"

A unique code for the discount - this will be used by the customer to apply the discount

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.

ends_at
required
string or null <date-time>

The time at which the discount can no longer be used.

id
required
string
Example: "disc_01F0YESMW10MGHWJKZSDDMN0VN"

The discount's ID

is_disabled
required
boolean
Example: false

Whether the Discount has been disabled. Disabled discounts cannot be applied to carts

is_dynamic
required
boolean
Example: false

A flag to indicate if multiple instances of the discount can be generated. I.e. for newsletter discounts

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

An optional key-value map with additional details

parent_discount_id
required
string or null
Example: "disc_01G8ZH853YPY9B94857DY91YGW"

The Discount that the discount was created from. This will always be a dynamic discount

rule_id
required
string or null
Example: "dru_01F0YESMVK96HVX7N419E3CJ7C"

The ID of the discount rule that defines how the discount will be applied to a cart.

starts_at
required
string <date-time>

The time at which the discount can be used.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

usage_count
required
integer
Default: 0
Example: 50

The number of times a discount has been used.

usage_limit
required
integer or null
Example: 100

The maximum number of times that a discount can be used.

valid_duration
required
string or null
Example: "P3Y6M4DT12H30M5S"

Duration the discount runs between

object (Discount Rule)

A discount rule defines how a Discount is calculated when applied to a Cart.

parent_discount
object or null

The details of the parent discount that this discount was created from.

Array of objects (Region)

The details of the regions in which the Discount can be used.

Request samples

Content type
application/json
{
  • "code": "string",
  • "usage_limit": 1,
  • "metadata": { }
}

Response samples

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

Delete a Dynamic Code

Delete a dynamic code from a Discount.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Discount

code
required
string

The dynamic code to delete

Responses

Response Schema: application/json
required
object (Discount)

A discount can be applied to a cart for promotional purposes.

code
required
string
Example: "10DISC"

A unique code for the discount - this will be used by the customer to apply the discount

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.

ends_at
required
string or null <date-time>

The time at which the discount can no longer be used.

id
required
string
Example: "disc_01F0YESMW10MGHWJKZSDDMN0VN"

The discount's ID

is_disabled
required
boolean
Example: false

Whether the Discount has been disabled. Disabled discounts cannot be applied to carts

is_dynamic
required
boolean
Example: false

A flag to indicate if multiple instances of the discount can be generated. I.e. for newsletter discounts

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

An optional key-value map with additional details

parent_discount_id
required
string or null
Example: "disc_01G8ZH853YPY9B94857DY91YGW"

The Discount that the discount was created from. This will always be a dynamic discount

rule_id
required
string or null
Example: "dru_01F0YESMVK96HVX7N419E3CJ7C"

The ID of the discount rule that defines how the discount will be applied to a cart.

starts_at
required
string <date-time>

The time at which the discount can be used.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

usage_count
required
integer
Default: 0
Example: 50

The number of times a discount has been used.

usage_limit
required
integer or null
Example: 100

The maximum number of times that a discount can be used.

valid_duration
required
string or null
Example: "P3Y6M4DT12H30M5S"

Duration the discount runs between

object (Discount Rule)

A discount rule defines how a Discount is calculated when applied to a Cart.

parent_discount
object or null

The details of the parent discount that this discount was created from.

Array of objects (Region)

The details of the regions in which the Discount can be used.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.discounts.deleteDynamicCode(discountId, code)
.then(({ discount }) => {
  console.log(discount.id);
});

Response samples

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

Add Region to Discount

Add a Region to the list of Regions a Discount can be used in.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Discount.

region_id
required
string

The ID of the Region.

Responses

Response Schema: application/json
required
object (Discount)

A discount can be applied to a cart for promotional purposes.

code
required
string
Example: "10DISC"

A unique code for the discount - this will be used by the customer to apply the discount

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.

ends_at
required
string or null <date-time>

The time at which the discount can no longer be used.

id
required
string
Example: "disc_01F0YESMW10MGHWJKZSDDMN0VN"

The discount's ID

is_disabled
required
boolean
Example: false

Whether the Discount has been disabled. Disabled discounts cannot be applied to carts

is_dynamic
required
boolean
Example: false

A flag to indicate if multiple instances of the discount can be generated. I.e. for newsletter discounts

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

An optional key-value map with additional details

parent_discount_id
required
string or null
Example: "disc_01G8ZH853YPY9B94857DY91YGW"

The Discount that the discount was created from. This will always be a dynamic discount

rule_id
required
string or null
Example: "dru_01F0YESMVK96HVX7N419E3CJ7C"

The ID of the discount rule that defines how the discount will be applied to a cart.

starts_at
required
string <date-time>

The time at which the discount can be used.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

usage_count
required
integer
Default: 0
Example: 50

The number of times a discount has been used.

usage_limit
required
integer or null
Example: 100

The maximum number of times that a discount can be used.

valid_duration
required
string or null
Example: "P3Y6M4DT12H30M5S"

Duration the discount runs between

object (Discount Rule)

A discount rule defines how a Discount is calculated when applied to a Cart.

parent_discount
object or null

The details of the parent discount that this discount was created from.

Array of objects (Region)

The details of the regions in which the Discount can be used.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.discounts.addRegion(discountId, regionId)
.then(({ discount }) => {
  console.log(discount.id);
});

Response samples

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

Remove Region

Remove a Region from the list of Regions that a Discount can be used in. This does not delete a region, only the association between it and the discount.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Discount.

region_id
required
string

The ID of the Region.

Responses

Response Schema: application/json
required
object (Discount)

A discount can be applied to a cart for promotional purposes.

code
required
string
Example: "10DISC"

A unique code for the discount - this will be used by the customer to apply the discount

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.

ends_at
required
string or null <date-time>

The time at which the discount can no longer be used.

id
required
string
Example: "disc_01F0YESMW10MGHWJKZSDDMN0VN"

The discount's ID

is_disabled
required
boolean
Example: false

Whether the Discount has been disabled. Disabled discounts cannot be applied to carts

is_dynamic
required
boolean
Example: false

A flag to indicate if multiple instances of the discount can be generated. I.e. for newsletter discounts

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

An optional key-value map with additional details

parent_discount_id
required
string or null
Example: "disc_01G8ZH853YPY9B94857DY91YGW"

The Discount that the discount was created from. This will always be a dynamic discount

rule_id
required
string or null
Example: "dru_01F0YESMVK96HVX7N419E3CJ7C"

The ID of the discount rule that defines how the discount will be applied to a cart.

starts_at
required
string <date-time>

The time at which the discount can be used.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

usage_count
required
integer
Default: 0
Example: 50

The number of times a discount has been used.

usage_limit
required
integer or null
Example: 100

The maximum number of times that a discount can be used.

valid_duration
required
string or null
Example: "P3Y6M4DT12H30M5S"

Duration the discount runs between

object (Discount Rule)

A discount rule defines how a Discount is calculated when applied to a Cart.

parent_discount
object or null

The details of the parent discount that this discount was created from.

Array of objects (Region)

The details of the regions in which the Discount can be used.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.discounts.removeRegion(discountId, regionId)
.then(({ discount }) => {
  console.log(discount.id);
});

Response samples

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

Draft Orders

A draft order is an order created manually by the admin. It allows admins to create orders without direct involvement from the customer.

List Draft Orders

Retrieve an list of Draft Orders. The draft orders can be filtered by fields such as q. The draft orders can also paginated.

Authorizations:
API TokenCookie Session ID
query Parameters
offset
number
Default: "0"

The number of draft orders to skip when retrieving the draft orders.

limit
number
Default: "50"

Limit the number of draft orders returned.

q
string

a term to search draft orders' display IDs and emails in the draft order's cart

Responses

Response Schema: application/json
required
Array of objects (DraftOrder)

An array of draft order's details.

count
required
integer

The total number of items available

offset
required
integer

The number of draft orders skipped when retrieving the draft orders.

limit
required
integer

The number of items per page

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.draftOrders.list()
.then(({ draft_orders, limit, offset, count }) => {
  console.log(draft_orders.length);
});

Response samples

Content type
application/json
{
  • "draft_orders": [
    ],
  • "count": 0,
  • "offset": 0,
  • "limit": 0
}

Create a Draft Order

Create a Draft Order. A draft order is not transformed into an order until payment is captured.

Authorizations:
API TokenCookie Session ID
Request Body schema: application/json
email
required
string <email>

The email of the customer of the draft order

region_id
required
string

The ID of the region for the draft order

required
Array of objects

The shipping methods for the draft order

status
string
Enum: "open" "completed"

The status of the draft order. The draft order's default status is open. It's changed to completed when its payment is marked as paid.

AddressPayload (object) or string

The Address to be used for billing purposes.

AddressPayload (object) or string

The Address to be used for shipping purposes.

Array of objects

The draft order's line items.

Array of objects

The discounts to add to the draft order

customer_id
string

The ID of the customer this draft order is associated with.

no_notification_order
boolean

An optional flag passed to the resulting order that indicates whether the customer should receive notifications about order updates.

metadata
object

The optional key-value map with additional details about the Draft Order.

Responses

Response Schema: application/json
required
object (DraftOrder)

A draft order is created by an admin without direct involvement of the customer. Once its payment is marked as captured, it is transformed into an order.

canceled_at
required
string or null <date-time>

The date the draft order was canceled at.

cart_id
required
string or null
Example: "cart_01G8ZH853Y6TFXWPG5EYE81X63"

The ID of the cart associated with the draft order.

completed_at
required
string or null <date-time>

The date the draft order was completed at.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

display_id
required
string
Example: 2

The draft order's display ID

id
required
string
Example: "dorder_01G8TJFKBG38YYFQ035MSVG03C"

The draft order's ID

idempotency_key
required
string or null

Randomly generated key used to continue the completion of the cart associated with the draft order in case of failure.

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

An optional key-value map with additional details

no_notification_order
required
boolean or null
Example: false

Whether to send the customer notifications regarding order updates.

order_id
required
string or null
Example: "order_01G8TJSYT9M6AVS5N4EMNFS1EK"

The ID of the order created from the draft order when its payment is captured.

status
required
string
Default: "open"
Enum: "open" "completed"

The status of the draft order. It's changed to completed when it's transformed to an order.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

cart
object or null

The details of the cart associated with the draft order.

order
object or null

The details of the order created from the draft order when its payment is captured.

Request samples

Content type
application/json
{
  • "status": "open",
  • "email": "user@example.com",
  • "billing_address": {
    },
  • "shipping_address": {
    },
  • "items": [
    ],
  • "region_id": "string",
  • "discounts": [
    ],
  • "customer_id": "string",
  • "no_notification_order": true,
  • "shipping_methods": [
    ],
  • "metadata": { }
}

Response samples

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

Get a Draft Order

Retrieve a Draft Order's details.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Draft Order.

Responses

Response Schema: application/json
required
object (DraftOrder)

A draft order is created by an admin without direct involvement of the customer. Once its payment is marked as captured, it is transformed into an order.

canceled_at
required
string or null <date-time>

The date the draft order was canceled at.

cart_id
required
string or null
Example: "cart_01G8ZH853Y6TFXWPG5EYE81X63"

The ID of the cart associated with the draft order.

completed_at
required
string or null <date-time>

The date the draft order was completed at.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

display_id
required
string
Example: 2

The draft order's display ID

id
required
string
Example: "dorder_01G8TJFKBG38YYFQ035MSVG03C"

The draft order's ID

idempotency_key
required
string or null

Randomly generated key used to continue the completion of the cart associated with the draft order in case of failure.

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

An optional key-value map with additional details

no_notification_order
required
boolean or null
Example: false

Whether to send the customer notifications regarding order updates.

order_id
required
string or null
Example: "order_01G8TJSYT9M6AVS5N4EMNFS1EK"

The ID of the order created from the draft order when its payment is captured.

status
required
string
Default: "open"
Enum: "open" "completed"

The status of the draft order. It's changed to completed when it's transformed to an order.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

cart
object or null

The details of the cart associated with the draft order.

order
object or null

The details of the order created from the draft order when its payment is captured.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.draftOrders.retrieve(draftOrderId)
.then(({ draft_order }) => {
  console.log(draft_order.id);
});

Response samples

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

Update a Draft Order

Update a Draft Order's details.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Draft Order.

Request Body schema: application/json
region_id
string

The ID of the Region to create the Draft Order in.

country_code
string

The 2 character ISO code for the Country.

email
string <email>

An email to be used in the Draft Order.

AddressPayload (object) or string

The Address to be used for billing purposes.

AddressPayload (object) or string

The Address to be used for shipping purposes.

Array of objects

An array of Discount codes to add to the Draft Order.

no_notification_order
boolean

An optional flag passed to the resulting order that indicates whether the customer should receive notifications about order updates.

customer_id
string

The ID of the customer this draft order is associated with.

Responses

Response Schema: application/json
required
object (DraftOrder)

A draft order is created by an admin without direct involvement of the customer. Once its payment is marked as captured, it is transformed into an order.

canceled_at
required
string or null <date-time>

The date the draft order was canceled at.

cart_id
required
string or null
Example: "cart_01G8ZH853Y6TFXWPG5EYE81X63"

The ID of the cart associated with the draft order.

completed_at
required
string or null <date-time>

The date the draft order was completed at.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

display_id
required
string
Example: 2

The draft order's display ID

id
required
string
Example: "dorder_01G8TJFKBG38YYFQ035MSVG03C"

The draft order's ID

idempotency_key
required
string or null

Randomly generated key used to continue the completion of the cart associated with the draft order in case of failure.

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

An optional key-value map with additional details

no_notification_order
required
boolean or null
Example: false

Whether to send the customer notifications regarding order updates.

order_id
required
string or null
Example: "order_01G8TJSYT9M6AVS5N4EMNFS1EK"

The ID of the order created from the draft order when its payment is captured.

status
required
string
Default: "open"
Enum: "open" "completed"

The status of the draft order. It's changed to completed when it's transformed to an order.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

cart
object or null

The details of the cart associated with the draft order.

order
object or null

The details of the order created from the draft order when its payment is captured.

Request samples

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

Response samples

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

Delete a Draft Order

Delete a Draft Order

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Draft Order.

Responses

Response Schema: application/json
id
required
string

The ID of the deleted Draft Order.

object
required
string
Default: "draft-order"

The type of the object that was deleted.

deleted
required
boolean
Default: true

Whether the draft order was deleted successfully.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.draftOrders.delete(draftOrderId)
.then(({ id, object, deleted }) => {
  console.log(id);
});

Response samples

Content type
application/json
{
  • "id": "string",
  • "object": "draft-order",
  • "deleted": true
}

Create a Line Item

Create a Line Item in the Draft Order.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Draft Order.

Request Body schema: application/json
quantity
required
integer

The quantity of the line item.

variant_id
string

The ID of the Product Variant associated with the line item. If the line item is custom, the variant_id should be omitted.

unit_price
integer

The custom price of the line item. If a variant_id is supplied, the price provided here will override the variant's price.

title
string
Default: "Custom item"

The title of the line item if variant_id is not provided.

metadata
object

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

Responses

Response Schema: application/json
required
object (DraftOrder)

A draft order is created by an admin without direct involvement of the customer. Once its payment is marked as captured, it is transformed into an order.

canceled_at
required
string or null <date-time>

The date the draft order was canceled at.

cart_id
required
string or null
Example: "cart_01G8ZH853Y6TFXWPG5EYE81X63"

The ID of the cart associated with the draft order.

completed_at
required
string or null <date-time>

The date the draft order was completed at.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

display_id
required
string
Example: 2

The draft order's display ID

id
required
string
Example: "dorder_01G8TJFKBG38YYFQ035MSVG03C"

The draft order's ID

idempotency_key
required
string or null

Randomly generated key used to continue the completion of the cart associated with the draft order in case of failure.

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

An optional key-value map with additional details

no_notification_order
required
boolean or null
Example: false

Whether to send the customer notifications regarding order updates.

order_id
required
string or null
Example: "order_01G8TJSYT9M6AVS5N4EMNFS1EK"

The ID of the order created from the draft order when its payment is captured.

status
required
string
Default: "open"
Enum: "open" "completed"

The status of the draft order. It's changed to completed when it's transformed to an order.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

cart
object or null

The details of the cart associated with the draft order.

order
object or null

The details of the order created from the draft order when its payment is captured.

Request samples

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

Response samples

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

Update a Line Item

Update a Line Item in a Draft Order

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Draft Order.

line_id
required
string

The ID of the Line Item.

Request Body schema: application/json
unit_price
integer

The custom price of the line item. If a variant_id is supplied, the price provided here will override the variant's price.

title
string

The title of the line item if variant_id is not provided.

quantity
integer

The quantity of the line item.

metadata
object

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

Responses

Response Schema: application/json
required
object (DraftOrder)

A draft order is created by an admin without direct involvement of the customer. Once its payment is marked as captured, it is transformed into an order.

canceled_at
required
string or null <date-time>

The date the draft order was canceled at.

cart_id
required
string or null
Example: "cart_01G8ZH853Y6TFXWPG5EYE81X63"

The ID of the cart associated with the draft order.

completed_at
required
string or null <date-time>

The date the draft order was completed at.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

display_id
required
string
Example: 2

The draft order's display ID

id
required
string
Example: "dorder_01G8TJFKBG38YYFQ035MSVG03C"

The draft order's ID

idempotency_key
required
string or null

Randomly generated key used to continue the completion of the cart associated with the draft order in case of failure.

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

An optional key-value map with additional details

no_notification_order
required
boolean or null
Example: false

Whether to send the customer notifications regarding order updates.

order_id
required
string or null
Example: "order_01G8TJSYT9M6AVS5N4EMNFS1EK"

The ID of the order created from the draft order when its payment is captured.

status
required
string
Default: "open"
Enum: "open" "completed"

The status of the draft order. It's changed to completed when it's transformed to an order.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

cart
object or null

The details of the cart associated with the draft order.

order
object or null

The details of the order created from the draft order when its payment is captured.

Request samples

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

Response samples

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

Delete a Line Item

Deletes a Line Item from a Draft Order.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Draft Order.

line_id
required
string

The ID of the line item.

Responses

Response Schema: application/json
required
object (DraftOrder)

A draft order is created by an admin without direct involvement of the customer. Once its payment is marked as captured, it is transformed into an order.

canceled_at
required
string or null <date-time>

The date the draft order was canceled at.

cart_id
required
string or null
Example: "cart_01G8ZH853Y6TFXWPG5EYE81X63"

The ID of the cart associated with the draft order.

completed_at
required
string or null <date-time>

The date the draft order was completed at.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

display_id
required
string
Example: 2

The draft order's display ID

id
required
string
Example: "dorder_01G8TJFKBG38YYFQ035MSVG03C"

The draft order's ID

idempotency_key
required
string or null

Randomly generated key used to continue the completion of the cart associated with the draft order in case of failure.

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

An optional key-value map with additional details

no_notification_order
required
boolean or null
Example: false

Whether to send the customer notifications regarding order updates.

order_id
required
string or null
Example: "order_01G8TJSYT9M6AVS5N4EMNFS1EK"

The ID of the order created from the draft order when its payment is captured.

status
required
string
Default: "open"
Enum: "open" "completed"

The status of the draft order. It's changed to completed when it's transformed to an order.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

cart
object or null

The details of the cart associated with the draft order.

order
object or null

The details of the order created from the draft order when its payment is captured.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.draftOrders.removeLineItem(draftOrderId, itemId)
.then(({ draft_order }) => {
  console.log(draft_order.id);
});

Response samples

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

Mark Paid

Capture the draft order's payment. This will also set the draft order's status to completed and create an Order from the draft order. The payment is captured through Medusa's system payment, which is manual payment that isn't integrated with any third-party payment provider. It is assumed that the payment capturing is handled manually by the admin.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The Draft Order ID.

Responses

Response Schema: application/json
required
object (Order)

An order is a purchase made by a customer. It holds details about payment and fulfillment of the order. An order may also be created from a draft order, which is created by an admin user.

billing_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The ID of the billing address associated with the order

canceled_at
required
string or null <date-time>

The date the order was canceled on.

cart_id
required
string or null
Example: "cart_01G8ZH853Y6TFXWPG5EYE81X63"

The ID of the cart associated with the order

created_at
required
string <date-time>

The date with timezone at which the resource was created.

currency_code
required
string
Example: "usd"

The 3 character currency code that is used in the order

customer_id
required
string
Example: "cus_01G2SG30J8C85S4A5CHM2S1NS2"

The ID of the customer associated with the order

draft_order_id
required
string or null
Example: null

The ID of the draft order this order was created from.

display_id
required
integer
Example: 2

The order's display ID

email
required
string <email>

The email associated with the order

external_id
required
string or null
Example: null

The ID of an external order.

fulfillment_status
required
string
Default: "not_fulfilled"
Enum: "not_fulfilled" "partially_fulfilled" "fulfilled" "partially_shipped" "shipped" "partially_returned" "returned" "canceled" "requires_action"

The order's fulfillment status

id
required
string
Example: "order_01G8TJSYT9M6AVS5N4EMNFS1EK"

The order's ID

idempotency_key
required
string or null

Randomly generated key used to continue the processing of the order in case of failure.

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

An optional key-value map with additional details

no_notification
required
boolean or null
Example: false

Flag for describing whether or not notifications related to this should be send.

payment_status
required
string
Default: "not_paid"
Enum: "not_paid" "awaiting" "captured" "partially_refunded" "refunded" "canceled" "requires_action"

The order's payment status

region_id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The ID of the region this order was created in.

shipping_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The ID of the shipping address associated with the order

status
required
string
Default: "pending"
Enum: "pending" "completed" "archived" "canceled" "requires_action"

The order's status

tax_rate
required
number or null
Example: 0

The order's tax rate

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

cart
object or null

The details of the cart associated with the order.

customer
object or null

The details of the customer associated with the order.

object (Address)

An address is used across the Medusa backend within other schemas and object types. For example, a customer's billing and shipping addresses both use the Address entity.

object (Address)

An address is used across the Medusa backend within other schemas and object types. For example, a customer's billing and shipping addresses both use the Address entity.

object (Region)

A region holds settings specific to a geographical location, including the currency, tax rates, and fulfillment and payment providers. A Region can consist of multiple countries to accomodate common shopping settings across countries.

object (Currency)

Currency

Array of objects (Discount)

The details of the discounts applied on the order.

Array of objects (Gift Card)

The details of the gift card used in the order.

Array of objects (Shipping Method)

The details of the shipping methods used in the order.

payments
Array of objects

The details of the payments used in the order.

fulfillments
Array of objects

The details of the fulfillments created for the order.

returns
Array of objects

The details of the returns created for the order.

claims
Array of objects

The details of the claims created for the order.

refunds
Array of objects

The details of the refunds created for the order.

swaps
Array of objects

The details of the swaps created for the order.

draft_order
object or null

The details of the draft order this order was created from.

Array of objects (Line Item)

The details of the line items that belong to the order.

edits
Array of objects

The details of the order edits done on the order.

Array of objects (Gift Card Transaction)

The gift card transactions made in the order.

sales_channel_id
string or null
Example: null

The ID of the sales channel this order belongs to.

object (Sales Channel)

A Sales Channel is a method a business offers its products for purchase for the customers. For example, a Webshop can be a sales channel, and a mobile app can be another.

shipping_total
integer
Example: 1000

The total of shipping

raw_discount_total
integer
Example: 800

The total of discount

discount_total
integer
Example: 800

The total of discount rounded

tax_total
integer
Example: 0

The total of tax

refunded_total
integer
Example: 0

The total amount refunded if the order is returned.

total
integer
Example: 8200

The total amount of the order

subtotal
integer
Example: 8000

The subtotal of the order

paid_total
integer
Example: 8000

The total amount paid

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

Array of objects (Line Item)

The details of the line items that are returnable as part of the order, swaps, or claims

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.draftOrders.markPaid(draftOrderId)
.then(({ order }) => {
  console.log(order.id);
});

Response samples

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

Gift Cards

Admins can create gift cards and send them directly to customers, specifying options like their balance, region, and more. These gift cards are different than the saleable gift cards in a store, which are created and managed through Product endpoints.

List Gift Cards

Retrieve a list of Gift Cards. The gift cards can be filtered by fields such as q. The gift cards can also paginated.

Authorizations:
API TokenCookie Session ID
query Parameters
offset
number
Default: "0"

The number of gift cards to skip when retrieving the gift cards.

limit
number
Default: "50"

Limit the number of gift cards returned.

q
string

a term to search gift cards' code or display ID

Responses

Response Schema: application/json
required
Array of objects (Gift Card)
count
required
integer

The total number of items available

offset
required
integer

The number of gift cards skipped when retrieving the gift cards.

limit
required
integer

The number of items per page

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.giftCards.list()
.then(({ gift_cards, limit, offset, count }) => {
  console.log(gift_cards.length);
});

Response samples

Content type
application/json
{
  • "gift_cards": [
    ],
  • "count": 0,
  • "offset": 0,
  • "limit": 0
}

Create a Gift Card

Create a Gift Card that can redeemed by its unique code. The Gift Card is only valid within 1 region.

Authorizations:
API TokenCookie Session ID
Request Body schema: application/json
region_id
required
string

The ID of the Region in which the Gift Card can be used.

value
integer

The value (excluding VAT) that the Gift Card should represent.

is_disabled
boolean

Whether the Gift Card is disabled on creation. If set to true, the gift card will not be available for customers.

ends_at
string <date-time>

The date and time at which the Gift Card should no longer be available.

metadata
object

An optional set of key-value pairs to hold additional information.

Responses

Response Schema: application/json
required
object (Gift Card)

Gift Cards are redeemable and represent a value that can be used towards the payment of an Order.

balance
required
integer
Example: 10

The remaining value on the Gift Card.

code
required
string
Example: "3RFT-MH2C-Y4YZ-XMN4"

The unique code that identifies the Gift Card. This is used by the Customer to redeem the value of the Gift Card.

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.

ends_at
required
string or null <date-time>

The time at which the Gift Card can no longer be used.

id
required
string
Example: "gift_01G8XKBPBQY2R7RBET4J7E0XQZ"

The gift card's ID

is_disabled
required
boolean
Default: false

Whether the Gift Card has been disabled. Disabled Gift Cards cannot be applied to carts.

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

An optional key-value map with additional details

order_id
required
string or null
Example: "order_01G8TJSYT9M6AVS5N4EMNFS1EK"

The ID of the order that the gift card was purchased in.

region_id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The ID of the region this gift card is available in.

tax_rate
required
number or null
Example: 0

The gift card's tax rate that will be applied on calculating totals

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

value
required
integer
Example: 10

The value that the Gift Card represents.

object (Region)

A region holds settings specific to a geographical location, including the currency, tax rates, and fulfillment and payment providers. A Region can consist of multiple countries to accomodate common shopping settings across countries.

order
object or null

The details of the order that the gift card was purchased in.

Request samples

Content type
application/json
{
  • "value": 0,
  • "is_disabled": true,
  • "ends_at": "2019-08-24T14:15:22Z",
  • "region_id": "string",
  • "metadata": { }
}

Response samples

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

Get a Gift Card

Retrieve a Gift Card's details.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Gift Card.

Responses

Response Schema: application/json
required
object (Gift Card)

Gift Cards are redeemable and represent a value that can be used towards the payment of an Order.

balance
required
integer
Example: 10

The remaining value on the Gift Card.

code
required
string
Example: "3RFT-MH2C-Y4YZ-XMN4"

The unique code that identifies the Gift Card. This is used by the Customer to redeem the value of the Gift Card.

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.

ends_at
required
string or null <date-time>

The time at which the Gift Card can no longer be used.

id
required
string
Example: "gift_01G8XKBPBQY2R7RBET4J7E0XQZ"

The gift card's ID

is_disabled
required
boolean
Default: false

Whether the Gift Card has been disabled. Disabled Gift Cards cannot be applied to carts.

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

An optional key-value map with additional details

order_id
required
string or null
Example: "order_01G8TJSYT9M6AVS5N4EMNFS1EK"

The ID of the order that the gift card was purchased in.

region_id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The ID of the region this gift card is available in.

tax_rate
required
number or null
Example: 0

The gift card's tax rate that will be applied on calculating totals

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

value
required
integer
Example: 10

The value that the Gift Card represents.

object (Region)

A region holds settings specific to a geographical location, including the currency, tax rates, and fulfillment and payment providers. A Region can consist of multiple countries to accomodate common shopping settings across countries.

order
object or null

The details of the order that the gift card was purchased in.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.giftCards.retrieve(giftCardId)
.then(({ gift_card }) => {
  console.log(gift_card.id);
});

Response samples

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

Update a Gift Card

Update a Gift Card's details.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Gift Card.

Request Body schema: application/json
balance
integer

The value (excluding VAT) that the Gift Card should represent.

is_disabled
boolean

Whether the Gift Card is disabled on creation. If set to true, the gift card will not be available for customers.

ends_at
string <date-time>

The date and time at which the Gift Card should no longer be available.

region_id
string

The ID of the Region in which the Gift Card can be used.

metadata
object

An optional set of key-value pairs to hold additional information.

Responses

Response Schema: application/json
required
object (Gift Card)

Gift Cards are redeemable and represent a value that can be used towards the payment of an Order.

balance
required
integer
Example: 10

The remaining value on the Gift Card.

code
required
string
Example: "3RFT-MH2C-Y4YZ-XMN4"

The unique code that identifies the Gift Card. This is used by the Customer to redeem the value of the Gift Card.

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.

ends_at
required
string or null <date-time>

The time at which the Gift Card can no longer be used.

id
required
string
Example: "gift_01G8XKBPBQY2R7RBET4J7E0XQZ"

The gift card's ID

is_disabled
required
boolean
Default: false

Whether the Gift Card has been disabled. Disabled Gift Cards cannot be applied to carts.

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

An optional key-value map with additional details

order_id
required
string or null
Example: "order_01G8TJSYT9M6AVS5N4EMNFS1EK"

The ID of the order that the gift card was purchased in.

region_id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The ID of the region this gift card is available in.

tax_rate
required
number or null
Example: 0

The gift card's tax rate that will be applied on calculating totals

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

value
required
integer
Example: 10

The value that the Gift Card represents.

object (Region)

A region holds settings specific to a geographical location, including the currency, tax rates, and fulfillment and payment providers. A Region can consist of multiple countries to accomodate common shopping settings across countries.

order
object or null

The details of the order that the gift card was purchased in.

Request samples

Content type
application/json
{
  • "balance": 0,
  • "is_disabled": true,
  • "ends_at": "2019-08-24T14:15:22Z",
  • "region_id": "string",
  • "metadata": { }
}

Response samples

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

Delete a Gift Card

Delete a Gift Card. Once deleted, it can't be used by customers.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Gift Card to delete.

Responses

Response Schema: application/json
id
required
string

The ID of the deleted Gift Card

object
required
string
Default: "gift-card"

The type of the object that was deleted.

deleted
required
boolean
Default: true

Whether the gift card was deleted successfully.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.giftCards.delete(giftCardId)
.then(({ id, object, deleted }) => {
  console.log(id);
});

Response samples

Content type
application/json
{
  • "id": "string",
  • "object": "gift-card",
  • "deleted": true
}

Inventory Items

Inventory items, provided by the Inventory Module, can be used to manage the inventory of saleable items in your store.

List Inventory Items

Retrieve a list of inventory items. The inventory items can be filtered by fields such as q or location_id. The inventory items can also be paginated.

Authorizations:
API TokenCookie Session ID
query Parameters
offset
integer
Default: 0

The number of inventory items to skip when retrieving the inventory items.

limit
integer
Default: 20

Limit the number of inventory items returned.

expand
string

Comma-separated relations that should be expanded in each returned inventory item.

fields
string

Comma-separated fields that should be included in the returned inventory item.

q
string

term to search inventory item's sku, title, and description.

location_id
Array of strings

Filter by location IDs.

string or Array of strings

Filter by the inventory ID

sku
string

Filter by SKU

origin_country
string

Filter by origin country

mid_code
string

Filter by MID code

material
string

Filter by material

hs_code
string

Filter by HS Code

weight
string

Filter by weight

length
string

Filter by length

height
string

Filter by height

width
string

Filter by width

requires_shipping
string

Filter by whether the item requires shipping

Responses

Response Schema: application/json
required
Array of objects (DecoratedInventoryItemDTO)

an array of Inventory Item details

count
required
integer

The total number of items available

offset
required
integer

The number of inventory items skipped when retrieving the inventory items.

limit
required
integer

The number of items per page

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.inventoryItems.list()
.then(({ inventory_items, count, offset, limit }) => {
  console.log(inventory_items.length);
});

Response samples

Content type
application/json
{
  • "inventory_items": [
    ],
  • "count": 0,
  • "offset": 0,
  • "limit": 0
}

Create an Inventory Item

Create an Inventory Item.

Authorizations:
API TokenCookie Session ID
query Parameters
expand
string

Comma-separated relations that should be expanded in the returned inventory item.

fields
string

Comma-separated fields that should be included in the returned inventory item.

Request Body schema: application/json
sku
string

The unique SKU of the associated Product Variant.

ean
string

The EAN number of the item.

upc
string

The UPC number of the item.

barcode
string

A generic GTIN field for the Product Variant.

hs_code
string

The Harmonized System code of the Inventory Item. May be used by Fulfillment Providers to pass customs information to shipping carriers.

inventory_quantity
integer
Default: 0

The amount of stock kept of the associated Product Variant.

allow_backorder
boolean

Whether the associated Product Variant can be purchased when out of stock.

manage_inventory
boolean
Default: true

Whether Medusa should keep track of the inventory for the associated Product Variant.

weight
number

The weight of the Inventory Item. May be used in shipping rate calculations.

length
number

The length of the Inventory Item. May be used in shipping rate calculations.

height
number

The height of the Inventory Item. May be used in shipping rate calculations.

width
number

The width of the Inventory Item. May be used in shipping rate calculations.

origin_country
string

The country in which the Inventory Item was produced. May be used by Fulfillment Providers to pass customs information to shipping carriers.

mid_code
string

The Manufacturers Identification code that identifies the manufacturer of the Inventory Item. May be used by Fulfillment Providers to pass customs information to shipping carriers.

material
string

The material and composition that the Inventory Item is made of, May be used by Fulfillment Providers to pass customs information to shipping carriers.

metadata
object

An optional set of key-value pairs with additional information.

Responses

Response Schema: application/json
required
object (InventoryItemDTO)
sku
required
string

The Stock Keeping Unit (SKU) code of the Inventory Item.

hs_code
string

The Harmonized System code of the Inventory Item. May be used by Fulfillment Providers to pass customs information to shipping carriers.

origin_country
string

The country in which the Inventory Item was produced. May be used by Fulfillment Providers to pass customs information to shipping carriers.

mid_code
string

The Manufacturers Identification code that identifies the manufacturer of the Inventory Item. May be used by Fulfillment Providers to pass customs information to shipping carriers.

title
string

Title of the inventory item

description
string

Description of the inventory item

thumbnail
string

Thumbnail for the inventory item

material
string

The material and composition that the Inventory Item is made of, May be used by Fulfillment Providers to pass customs information to shipping carriers.

weight
number

The weight of the Inventory Item. May be used in shipping rate calculations.

height
number

The height of the Inventory Item. May be used in shipping rate calculations.

width
number

The width of the Inventory Item. May be used in shipping rate calculations.

length
number

The length of the Inventory Item. May be used in shipping rate calculations.

requires_shipping
boolean

Whether the item requires shipping.

metadata
object
Example: {"car":"white"}

An optional key-value map with additional details

created_at
string <date-time>

The date with timezone at which the resource was created.

updated_at
string <date-time>

The date with timezone at which the resource was updated.

deleted_at
string <date-time>

The date with timezone at which the resource was deleted.

Request samples

Content type
application/json
{
  • "sku": "string",
  • "ean": "string",
  • "upc": "string",
  • "barcode": "string",
  • "hs_code": "string",
  • "inventory_quantity": 0,
  • "allow_backorder": true,
  • "manage_inventory": true,
  • "weight": 0,
  • "length": 0,
  • "height": 0,
  • "width": 0,
  • "origin_country": "string",
  • "mid_code": "string",
  • "material": "string",
  • "metadata": { }
}

Response samples

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

Get an Inventory Item

Retrieve an Inventory Item's details.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Inventory Item.

query Parameters
expand
string

Comma-separated relations that should be expanded in the returned inventory item.

fields
string

Comma-separated fields that should be included in the returned inventory item.

Responses

Response Schema: application/json
required
object (InventoryItemDTO)
sku
required
string

The Stock Keeping Unit (SKU) code of the Inventory Item.

hs_code
string

The Harmonized System code of the Inventory Item. May be used by Fulfillment Providers to pass customs information to shipping carriers.

origin_country
string

The country in which the Inventory Item was produced. May be used by Fulfillment Providers to pass customs information to shipping carriers.

mid_code
string

The Manufacturers Identification code that identifies the manufacturer of the Inventory Item. May be used by Fulfillment Providers to pass customs information to shipping carriers.

title
string

Title of the inventory item

description
string

Description of the inventory item

thumbnail
string

Thumbnail for the inventory item

material
string

The material and composition that the Inventory Item is made of, May be used by Fulfillment Providers to pass customs information to shipping carriers.

weight
number

The weight of the Inventory Item. May be used in shipping rate calculations.

height
number

The height of the Inventory Item. May be used in shipping rate calculations.

width
number

The width of the Inventory Item. May be used in shipping rate calculations.

length
number

The length of the Inventory Item. May be used in shipping rate calculations.

requires_shipping
boolean

Whether the item requires shipping.

metadata
object
Example: {"car":"white"}

An optional key-value map with additional details

created_at
string <date-time>

The date with timezone at which the resource was created.

updated_at
string <date-time>

The date with timezone at which the resource was updated.

deleted_at
string <date-time>

The date with timezone at which the resource was deleted.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.inventoryItems.retrieve(inventoryItemId)
.then(({ inventory_item }) => {
  console.log(inventory_item.id);
});

Response samples

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

Update an Inventory Item

Update an Inventory Item's details.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Inventory Item.

query Parameters
expand
string

Comma-separated relations that should be expanded in the returned inventory level.

fields
string

Comma-separated fields that should be included in the returned inventory level.

Request Body schema: application/json
hs_code
string

The Harmonized System code of the Inventory Item. May be used by Fulfillment Providers to pass customs information to shipping carriers.

origin_country
string

The country in which the Inventory Item was produced. May be used by Fulfillment Providers to pass customs information to shipping carriers.

mid_code
string

The Manufacturers Identification code that identifies the manufacturer of the Inventory Item. May be used by Fulfillment Providers to pass customs information to shipping carriers.

material
string

The material and composition that the Inventory Item is made of, May be used by Fulfillment Providers to pass customs information to shipping carriers.

weight
number

The weight of the Inventory Item. May be used in shipping rate calculations.

height
number

The height of the Inventory Item. May be used in shipping rate calculations.

width
number

The width of the Inventory Item. May be used in shipping rate calculations.

length
number

The length of the Inventory Item. May be used in shipping rate calculations.

requires_shipping
boolean

Whether the item requires shipping.

Responses

Response Schema: application/json
required
object (InventoryItemDTO)
sku
required
string

The Stock Keeping Unit (SKU) code of the Inventory Item.

hs_code
string

The Harmonized System code of the Inventory Item. May be used by Fulfillment Providers to pass customs information to shipping carriers.

origin_country
string

The country in which the Inventory Item was produced. May be used by Fulfillment Providers to pass customs information to shipping carriers.

mid_code
string

The Manufacturers Identification code that identifies the manufacturer of the Inventory Item. May be used by Fulfillment Providers to pass customs information to shipping carriers.

title
string

Title of the inventory item

description
string

Description of the inventory item

thumbnail
string

Thumbnail for the inventory item

material
string

The material and composition that the Inventory Item is made of, May be used by Fulfillment Providers to pass customs information to shipping carriers.

weight
number

The weight of the Inventory Item. May be used in shipping rate calculations.

height
number

The height of the Inventory Item. May be used in shipping rate calculations.

width
number

The width of the Inventory Item. May be used in shipping rate calculations.

length
number

The length of the Inventory Item. May be used in shipping rate calculations.

requires_shipping
boolean

Whether the item requires shipping.

metadata
object
Example: {"car":"white"}

An optional key-value map with additional details

created_at
string <date-time>

The date with timezone at which the resource was created.

updated_at
string <date-time>

The date with timezone at which the resource was updated.

deleted_at
string <date-time>

The date with timezone at which the resource was deleted.

Request samples

Content type
application/json
{
  • "hs_code": "string",
  • "origin_country": "string",
  • "mid_code": "string",
  • "material": "string",
  • "weight": 0,
  • "height": 0,
  • "width": 0,
  • "length": 0,
  • "requires_shipping": true
}

Response samples

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

Delete an Inventory Item

Delete an Inventory Item. This does not delete the associated product variant.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Inventory Item to delete.

Responses

Response Schema: application/json
id
required
string

The ID of the deleted Inventory Item.

object
required
string <inventory_item>

The type of the object that was deleted.

deleted
required
boolean
Default: true

Whether or not the Inventory Item was deleted.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.inventoryItems.delete(inventoryItemId)
  .then(({ id, object, deleted }) => {
    console.log(id)
  })

Response samples

Content type
application/json
{
  • "id": "string",
  • "object": "string",
  • "deleted": true
}

List Inventory Level

Retrieve a list of inventory levels of an inventory item. The inventory levels can be filtered by fields such as location_id. The inventory levels can also be paginated.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Inventory Item the locations are associated with.

query Parameters
location_id
Array of strings

Filter by location IDs.

expand
string

Comma-separated relations that should be expanded in the returned inventory levels.

fields
string

Comma-separated fields that should be included in the returned inventory levels.

Responses

Response Schema: application/json
required
object
id
required
any

The id of the location

required
Array of objects (InventoryLevelDTO)

List of stock levels at a given location

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.inventoryItems.listLocationLevels(inventoryItemId)
.then(({ inventory_item }) => {
  console.log(inventory_item.location_levels);
});

Response samples

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

Create an Inventory Level

Create an Inventory Level for a given Inventory Item.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Inventory Item.

query Parameters
expand
string

Comma-separated relations that should be expanded in the returned inventory item.

fields
string

Comma-separated fields that should be included in the returned inventory item.

Request Body schema: application/json
location_id
required
string

the ID of the stock location

stocked_quantity
required
number

the stock quantity of the inventory item at this location

incoming_quantity
number

the incoming stock quantity of the inventory item at this location

Responses

Response Schema: application/json
required
object (InventoryItemDTO)
sku
required
string

The Stock Keeping Unit (SKU) code of the Inventory Item.

hs_code
string

The Harmonized System code of the Inventory Item. May be used by Fulfillment Providers to pass customs information to shipping carriers.

origin_country
string

The country in which the Inventory Item was produced. May be used by Fulfillment Providers to pass customs information to shipping carriers.

mid_code
string

The Manufacturers Identification code that identifies the manufacturer of the Inventory Item. May be used by Fulfillment Providers to pass customs information to shipping carriers.

title
string

Title of the inventory item

description
string

Description of the inventory item

thumbnail
string

Thumbnail for the inventory item

material
string

The material and composition that the Inventory Item is made of, May be used by Fulfillment Providers to pass customs information to shipping carriers.

weight
number

The weight of the Inventory Item. May be used in shipping rate calculations.

height
number

The height of the Inventory Item. May be used in shipping rate calculations.

width
number

The width of the Inventory Item. May be used in shipping rate calculations.

length
number

The length of the Inventory Item. May be used in shipping rate calculations.

requires_shipping
boolean

Whether the item requires shipping.

metadata
object
Example: {"car":"white"}

An optional key-value map with additional details

created_at
string <date-time>

The date with timezone at which the resource was created.

updated_at
string <date-time>

The date with timezone at which the resource was updated.

deleted_at
string <date-time>

The date with timezone at which the resource was deleted.

Request samples

Content type
application/json
{
  • "location_id": "string",
  • "stocked_quantity": 0,
  • "incoming_quantity": 0
}

Response samples

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

Update an Inventory Level

Update an Inventory Level's details for a given Inventory Item.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Inventory Item that the location is associated with.

location_id
required
string

The ID of the Location to update.

query Parameters
expand
string

Comma-separated relations that should be expanded in the returned inventory level.

fields
string

Comma-separated fields that should be included in the returned inventory level.

Request Body schema: application/json
stocked_quantity
number

the total stock quantity of an inventory item at the given location ID

incoming_quantity
number

the incoming stock quantity of an inventory item at the given location ID

Responses

Response Schema: application/json
required
object (InventoryItemDTO)
sku
required
string

The Stock Keeping Unit (SKU) code of the Inventory Item.

hs_code
string

The Harmonized System code of the Inventory Item. May be used by Fulfillment Providers to pass customs information to shipping carriers.

origin_country
string

The country in which the Inventory Item was produced. May be used by Fulfillment Providers to pass customs information to shipping carriers.

mid_code
string

The Manufacturers Identification code that identifies the manufacturer of the Inventory Item. May be used by Fulfillment Providers to pass customs information to shipping carriers.

title
string

Title of the inventory item

description
string

Description of the inventory item

thumbnail
string

Thumbnail for the inventory item

material
string

The material and composition that the Inventory Item is made of, May be used by Fulfillment Providers to pass customs information to shipping carriers.

weight
number

The weight of the Inventory Item. May be used in shipping rate calculations.

height
number

The height of the Inventory Item. May be used in shipping rate calculations.

width
number

The width of the Inventory Item. May be used in shipping rate calculations.

length
number

The length of the Inventory Item. May be used in shipping rate calculations.

requires_shipping
boolean

Whether the item requires shipping.

metadata
object
Example: {"car":"white"}

An optional key-value map with additional details

created_at
string <date-time>

The date with timezone at which the resource was created.

updated_at
string <date-time>

The date with timezone at which the resource was updated.

deleted_at
string <date-time>

The date with timezone at which the resource was deleted.

Request samples

Content type
application/json
{
  • "stocked_quantity": 0,
  • "incoming_quantity": 0
}

Response samples

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

Delete a Location Level

Delete a location level of an Inventory Item.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Inventory Item.

location_id
required
string

The ID of the location.

Responses

Response Schema: application/json
required
object (InventoryItemDTO)
sku
required
string

The Stock Keeping Unit (SKU) code of the Inventory Item.

hs_code
string

The Harmonized System code of the Inventory Item. May be used by Fulfillment Providers to pass customs information to shipping carriers.

origin_country
string

The country in which the Inventory Item was produced. May be used by Fulfillment Providers to pass customs information to shipping carriers.

mid_code
string

The Manufacturers Identification code that identifies the manufacturer of the Inventory Item. May be used by Fulfillment Providers to pass customs information to shipping carriers.

title
string

Title of the inventory item

description
string

Description of the inventory item

thumbnail
string

Thumbnail for the inventory item

material
string

The material and composition that the Inventory Item is made of, May be used by Fulfillment Providers to pass customs information to shipping carriers.

weight
number

The weight of the Inventory Item. May be used in shipping rate calculations.

height
number

The height of the Inventory Item. May be used in shipping rate calculations.

width
number

The width of the Inventory Item. May be used in shipping rate calculations.

length
number

The length of the Inventory Item. May be used in shipping rate calculations.

requires_shipping
boolean

Whether the item requires shipping.

metadata
object
Example: {"car":"white"}

An optional key-value map with additional details

created_at
string <date-time>

The date with timezone at which the resource was created.

updated_at
string <date-time>

The date with timezone at which the resource was updated.

deleted_at
string <date-time>

The date with timezone at which the resource was deleted.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.inventoryItems.deleteLocationLevel(inventoryItemId, locationId)
.then(({ inventory_item }) => {
  console.log(inventory_item.id);
});

Response samples

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

Invites

An admin can invite new users to manage their team. This would allow new users to authenticate as admins and perform admin functionalities.

Lists Invites

Retrieve a list of invites.

Authorizations:
API TokenCookie Session ID

Responses

Response Schema: application/json
required
Array of objects (Invite)

An array of invites

Array
accepted
required
boolean
Default: false

Whether the invite was accepted or not.

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.

expires_at
required
string <date-time>

The date the invite expires at.

id
required
string
Example: "invite_01G8TKE4XYCTHSCK2GDEP47RE1"

The invite's ID

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

An optional key-value map with additional details

role
required
string or null
Default: "member"
Enum: "admin" "member" "developer"

The user's role. These roles don't change the privileges of the user.

token
required
string

The token used to accept the invite.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

user_email
required
string <email>

The email of the user being invited.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.invites.list()
.then(({ invites }) => {
  console.log(invites.length);
});

Response samples

Content type
application/json
{
  • "invites": [
    ]
}

Create an Invite

Create an Invite. This will generate a token associated with the invite and trigger an invite.created event. If you have a Notification Provider installed that handles this event, a notification should be sent to the email associated with the invite to allow them to accept the invite.

Authorizations:
API TokenCookie Session ID
Request Body schema: application/json
user
required
string <email>

The email associated with the invite. Once the invite is accepted, the email will be associated with the created user.

role
required
string
Enum: "admin" "member" "developer"

The role of the user to be created. This does not actually change the privileges of the user that is eventually created.

Responses

Request samples

Content type
application/json
{
  • "user": "user@example.com",
  • "role": "admin"
}

Response samples

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

Accept an Invite

Accept an Invite. This will also delete the invite and create a new user that can log in and perform admin functionalities. The user will have the email associated with the invite, and the password provided in the request body.

Authorizations:
API TokenCookie Session ID
Request Body schema: application/json
token
required
string

The token of the invite to accept. This is a unique token generated when the invite was created or resent.

required
object

The details of the user to create.

Responses

Request samples

Content type
application/json
{
  • "token": "string",
  • "user": {
    }
}

Response samples

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

Delete an Invite

Delete an Invite. Only invites that weren't accepted can be deleted.

Authorizations:
API TokenCookie Session ID
path Parameters
invite_id
required
string

The ID of the Invite

Responses

Response Schema: application/json
id
required
string

The ID of the deleted Invite.

object
required
string
Default: "invite"

The type of the object that was deleted.

deleted
required
boolean
Default: true

Whether or not the invite was deleted.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.invites.delete(inviteId)
.then(({ id, object, deleted }) => {
  console.log(id);
});

Response samples

Content type
application/json
{
  • "id": "string",
  • "object": "invite",
  • "deleted": true
}

Resend an Invite

Resend an Invite. This renews the expiry date by 7 days and generates a new token for the invite. It also triggers the invite.created event, so if you have a Notification Provider installed that handles this event, a notification should be sent to the email associated with the invite to allow them to accept the invite.

Authorizations:
API TokenCookie Session ID
path Parameters
invite_id
required
string

The ID of the Invite

Responses

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.invites.resend(inviteId)
.then(() => {
  // successful
})
.catch(() => {
  // an error occurred
});

Response samples

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

Notes

Notes are created by admins and can be associated with any resource. For example, an admin can add a note to an order for additional details or remarks.

List Notes

Retrieve a list of notes. The notes can be filtered by fields such as resource_id. The notes can also be paginated.

Authorizations:
API TokenCookie Session ID
query Parameters
limit
number
Default: "50"

Limit the number of notes returned.

offset
number
Default: "0"

The number of notes to skip when retrieving the notes.

resource_id
string

Filter by resource ID

Responses

Response Schema: application/json
required
Array of objects (Note)

An array of notes

count
required
integer

The total number of items available

offset
required
integer

The number of notes skipped when retrieving the notes.

limit
required
integer

The number of items per page

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.notes.list()
.then(({ notes, limit, offset, count }) => {
  console.log(notes.length);
});

Response samples

Content type
application/json
{
  • "notes": [
    ],
  • "count": 0,
  • "offset": 0,
  • "limit": 0
}

Create a Note

Create a Note which can be associated with any resource.

Authorizations:
API TokenCookie Session ID
Request Body schema: application/json
resource_id
required
string

The ID of the resource which the Note relates to. For example, an order ID.

resource_type
required
string

The type of resource which the Note relates to. For example, order.

value
required
string

The content of the Note to create.

Responses

Response Schema: application/json
required
object (Note)

A Note is an element that can be used in association with different resources to allow admin users to describe additional information. For example, they can be used to add additional information about orders.

author_id
required
string or null
Example: "usr_01G1G5V26F5TB3GPAPNJ8X1S3V"

The ID of the user that created the note.

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.

id
required
string
Example: "note_01G8TM8ENBMC7R90XRR1G6H26Q"

The note's ID

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

An optional key-value map with additional details

resource_id
required
string
Example: "order_01G8TJSYT9M6AVS5N4EMNFS1EK"

The ID of the resource that the Note refers to.

resource_type
required
string
Example: "order"

The type of resource that the Note refers to.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

value
required
string
Example: "This order must be fulfilled on Monday"

The contents of the note.

object (User)

A User is an administrator who can manage store settings and data.

Request samples

Content type
application/json
{
  • "resource_id": "string",
  • "resource_type": "string",
  • "value": "string"
}

Response samples

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

Get a Note

Retrieve a note's details.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the note.

Responses

Response Schema: application/json
required
object (Note)

A Note is an element that can be used in association with different resources to allow admin users to describe additional information. For example, they can be used to add additional information about orders.

author_id
required
string or null
Example: "usr_01G1G5V26F5TB3GPAPNJ8X1S3V"

The ID of the user that created the note.

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.

id
required
string
Example: "note_01G8TM8ENBMC7R90XRR1G6H26Q"

The note's ID

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

An optional key-value map with additional details

resource_id
required
string
Example: "order_01G8TJSYT9M6AVS5N4EMNFS1EK"

The ID of the resource that the Note refers to.

resource_type
required
string
Example: "order"

The type of resource that the Note refers to.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

value
required
string
Example: "This order must be fulfilled on Monday"

The contents of the note.

object (User)

A User is an administrator who can manage store settings and data.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.notes.retrieve(noteId)
.then(({ note }) => {
  console.log(note.id);
});

Response samples

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

Update a Note

Update a Note's details.'

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Note

Request Body schema: application/json
value
required
string

The description of the Note.

Responses

Response Schema: application/json
required
object (Note)

A Note is an element that can be used in association with different resources to allow admin users to describe additional information. For example, they can be used to add additional information about orders.

author_id
required
string or null
Example: "usr_01G1G5V26F5TB3GPAPNJ8X1S3V"

The ID of the user that created the note.

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.

id
required
string
Example: "note_01G8TM8ENBMC7R90XRR1G6H26Q"

The note's ID

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

An optional key-value map with additional details

resource_id
required
string
Example: "order_01G8TJSYT9M6AVS5N4EMNFS1EK"

The ID of the resource that the Note refers to.

resource_type
required
string
Example: "order"

The type of resource that the Note refers to.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

value
required
string
Example: "This order must be fulfilled on Monday"

The contents of the note.

object (User)

A User is an administrator who can manage store settings and data.

Request samples

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

Response samples

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

Delete a Note

Delete a Note.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Note to delete.

Responses

Response Schema: application/json
id
required
string

The ID of the deleted Note.

object
required
string
Default: "note"

The type of the object that was deleted.

deleted
required
boolean
Default: true

Whether or not the Note was deleted.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.notes.delete(noteId)
.then(({ id, object, deleted }) => {
  console.log(id);
});

Response samples

Content type
application/json
{
  • "id": "string",
  • "object": "note",
  • "deleted": true
}

Notifications

Notifications are sent to customers to inform them of new updates. For example, a notification can be sent to the customer when their order is place or its state is updated. The notification's type, such as an email or SMS, is determined by the notification provider installed on the Medusa backend.

List Notifications

Retrieve a list of notifications. The notifications can be filtered by fields such as event_name or resource_type. The notifications can also be paginated.

Authorizations:
API TokenCookie Session ID
query Parameters
offset
integer
Default: 0

The number of inventory items to skip when retrieving the inventory items.

limit
integer
Default: 50

Limit the number of notifications returned.

fields
string

Comma-separated fields that should be included in each returned notification.

expand
string

Comma-separated relations that should be expanded in each returned notification.

event_name
string

Filter by the name of the event that triggered sending this notification.

resource_type
string

Filter by the resource type.

resource_id
string

Filter by the resource ID.

to
string

Filter by the address that the Notification was sent to. This will usually be an email address, but it can also represent other addresses such as a chat bot user id.

include_resends
string

A boolean indicating whether the result set should include resent notifications or not

Responses

Response Schema: application/json
required
Array of objects (Notification)

an array of notifications

count
integer

The total number of notifications

offset
integer

The number of notifications skipped when retrieving the notifications.

limit
integer

The number of notifications per page

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.notifications.list()
.then(({ notifications }) => {
  console.log(notifications.length);
});

Response samples

Content type
application/json
{
  • "notifications": [
    ],
  • "count": 0,
  • "offset": 0,
  • "limit": 0
}

Resend Notification

Resend a previously sent notifications, with the same data but optionally to a different address.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Notification

Request Body schema: application/json
to
string

A new address or user identifier that the Notification should be sent to. If not provided, the previous to field of the notification will be used.

Responses

Response Schema: application/json
required
object (Notification)

A notification is an alert sent, typically to customers, using the installed Notification Provider as a reaction to internal events such as order.placed. Notifications can be resent.

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 ID of the customer that this notification was sent to.

data
required
object
Example: {}

The data that the Notification was sent with. This contains all the data necessary for the Notification Provider to initiate a resend.

event_name
required
string or null
Example: "order.placed"

The name of the event that the notification was sent for.

id
required
string
Example: "noti_01G53V9Y6CKMCGBM1P0X7C28RX"

The notification's ID

parent_id
required
string or null
Example: "noti_01G53V9Y6CKMCGBM1P0X7C28RX"

The notification's parent ID

provider_id
required
string or null
Example: "sengrid"

The ID of the notification provider used to send the notification.

resource_type
required
string
Example: "order"

The type of resource that the Notification refers to.

resource_id
required
string
Example: "order_01G8TJSYT9M6AVS5N4EMNFS1EK"

The ID of the resource that the Notification refers to.

to
required
string
Example: "user@example.com"

The address that the Notification was sent to. This will usually be an email address, but can represent other addresses such as a chat bot user ID.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

object (Customer)

A customer can make purchases in your store and manage their profile.

parent_notification
object or null

The details of the parent notification.

resends
Array of objects

The details of all resends of the notification.

object (Notification Provider)

A notification provider represents a notification service installed in the Medusa backend, either through a plugin or backend customizations. It holds the notification service's installation status.

Request samples

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

Response samples

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

Order Edits

An admin can edit an order to remove, add, or update an item's quantity. When an admin edits an order, they're stored as an OrderEdit.

List Order Edits

Retrieve a list of order edits. The order edits can be filtered by fields such as q or order_id. The order edits can also be paginated.

Authorizations:
API TokenCookie Session ID
query Parameters
q
string

term to search order edits' internal note.

order_id
string

Filter by order ID

limit
number
Default: "20"

Limit the number of order edits returned.

offset
number
Default: "0"

The number of order edits to skip when retrieving the order edits.

expand
string

Comma-separated relations that should be expanded in each returned order edit.

fields
string

Comma-separated fields that should be included in each returned order edit.

Responses

Response Schema: application/json
required
Array of objects (Order Edit)

An array of order edit details

count
required
integer

The total number of items available

offset
required
integer

The number of order edits skipped when retrieving the order edits.

limit
required
integer

The number of items per page

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orderEdits.list()
  .then(({ order_edits, count, limit, offset }) => {
    console.log(order_edits.length)
  })

Response samples

Content type
application/json
{
  • "order_edits": [
    ],
  • "count": 0,
  • "offset": 0,
  • "limit": 0
}

Create an OrderEdit

Create an Order Edit.

Authorizations:
API TokenCookie Session ID
Request Body schema: application/json
order_id
required
string

The ID of the order to create the edit for.

internal_note
string

An optional note to associate with the order edit.

Responses

Response Schema: application/json
required
object (Order Edit)

Order edit allows modifying items in an order, such as adding, updating, or deleting items from the original order. Once the order edit is confirmed, the changes are reflected on the original order.

canceled_at
required
string or null <date-time>

The date with timezone at which the edit was cancelled.

canceled_by
required
string or null

The unique identifier of the user or customer who cancelled the order edit.

confirmed_by
required
string or null

The unique identifier of the user or customer who confirmed the order edit.

confirmed_at
required
string or null <date-time>

The date with timezone at which the edit was confirmed.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

created_by
required
string

The unique identifier of the user or customer who created the order edit.

declined_at
required
string or null <date-time>

The date with timezone at which the edit was declined.

declined_by
required
string or null

The unique identifier of the user or customer who declined the order edit.

declined_reason
required
string or null

An optional note why the order edit is declined.

id
required
string
Example: "oe_01G8TJSYT9M6AVS5N4EMNFS1EK"

The order edit's ID

internal_note
required
string or null
Example: "Included two more items B to the order."

An optional note with additional details about the order edit.

order_id
required
string
Example: "order_01G2SG30J8C85S4A5CHM2S1NS2"

The ID of the order that is edited

payment_collection_id
required
string or null
Example: "paycol_01G8TJSYT9M6AVS5N4EMNFS1EK"

The ID of the payment collection

requested_at
required
string or null <date-time>

The date with timezone at which the edit was requested.

requested_by
required
string or null

The unique identifier of the user or customer who requested the order edit.

status
required
string
Enum: "confirmed" "declined" "requested" "created" "canceled"

The status of the order edit.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

order
object or null

The details of the order that this order edit was created for.

Array of objects (Order Item Change)

The details of all the changes on the original order's line items.

subtotal
integer
Example: 8000

The total of subtotal

discount_total
integer
Example: 800

The total of discount

shipping_total
integer
Example: 800

The total of the shipping amount

gift_card_total
integer
Example: 800

The total of the gift card amount

gift_card_tax_total
integer
Example: 800

The total of the gift card tax amount

tax_total
integer
Example: 0

The total of tax

total
integer
Example: 8200

The total amount of the edited order.

difference_due
integer
Example: 8200

The difference between the total amount of the order and total amount of edited order.

Array of objects (Line Item)

The details of the cloned items from the original order with the new changes. Once the order edit is confirmed, these line items are associated with the original order.

object (Payment Collection)

A payment collection allows grouping and managing a list of payments at one. This can be helpful when making additional payment for order edits or integrating installment payments.

Request samples

Content type
application/json
{
  • "order_id": "string",
  • "internal_note": "string"
}

Response samples

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

Get an Order Edit

Retrieve an Order Edit's details.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the OrderEdit.

query Parameters
expand
string

Comma-separated relations that should be expanded in each returned order edit.

fields
string

Comma-separated fields that should be included in the returned order edit.

Responses

Response Schema: application/json
required
object (Order Edit)

Order edit allows modifying items in an order, such as adding, updating, or deleting items from the original order. Once the order edit is confirmed, the changes are reflected on the original order.

canceled_at
required
string or null <date-time>

The date with timezone at which the edit was cancelled.

canceled_by
required
string or null

The unique identifier of the user or customer who cancelled the order edit.

confirmed_by
required
string or null

The unique identifier of the user or customer who confirmed the order edit.

confirmed_at
required
string or null <date-time>

The date with timezone at which the edit was confirmed.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

created_by
required
string

The unique identifier of the user or customer who created the order edit.

declined_at
required
string or null <date-time>

The date with timezone at which the edit was declined.

declined_by
required
string or null

The unique identifier of the user or customer who declined the order edit.

declined_reason
required
string or null

An optional note why the order edit is declined.

id
required
string
Example: "oe_01G8TJSYT9M6AVS5N4EMNFS1EK"

The order edit's ID

internal_note
required
string or null
Example: "Included two more items B to the order."

An optional note with additional details about the order edit.

order_id
required
string
Example: "order_01G2SG30J8C85S4A5CHM2S1NS2"

The ID of the order that is edited

payment_collection_id
required
string or null
Example: "paycol_01G8TJSYT9M6AVS5N4EMNFS1EK"

The ID of the payment collection

requested_at
required
string or null <date-time>

The date with timezone at which the edit was requested.

requested_by
required
string or null

The unique identifier of the user or customer who requested the order edit.

status
required
string
Enum: "confirmed" "declined" "requested" "created" "canceled"

The status of the order edit.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

order
object or null

The details of the order that this order edit was created for.

Array of objects (Order Item Change)

The details of all the changes on the original order's line items.

subtotal
integer
Example: 8000

The total of subtotal

discount_total
integer
Example: 800

The total of discount

shipping_total
integer
Example: 800

The total of the shipping amount

gift_card_total
integer
Example: 800

The total of the gift card amount

gift_card_tax_total
integer
Example: 800

The total of the gift card tax amount

tax_total
integer
Example: 0

The total of tax

total
integer
Example: 8200

The total amount of the edited order.

difference_due
integer
Example: 8200

The difference between the total amount of the order and total amount of edited order.

Array of objects (Line Item)

The details of the cloned items from the original order with the new changes. Once the order edit is confirmed, these line items are associated with the original order.

object (Payment Collection)

A payment collection allows grouping and managing a list of payments at one. This can be helpful when making additional payment for order edits or integrating installment payments.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orderEdits.retrieve(orderEditId)
  .then(({ order_edit }) => {
    console.log(order_edit.id)
  })

Response samples

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

Update an Order Edit

Updates an Order Edit's details.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the OrderEdit.

Request Body schema: application/json
internal_note
string

An optional note to create or update in the order edit.

Responses

Response Schema: application/json
required
object (Order Edit)

Order edit allows modifying items in an order, such as adding, updating, or deleting items from the original order. Once the order edit is confirmed, the changes are reflected on the original order.

canceled_at
required
string or null <date-time>

The date with timezone at which the edit was cancelled.

canceled_by
required
string or null

The unique identifier of the user or customer who cancelled the order edit.

confirmed_by
required
string or null

The unique identifier of the user or customer who confirmed the order edit.

confirmed_at
required
string or null <date-time>

The date with timezone at which the edit was confirmed.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

created_by
required
string

The unique identifier of the user or customer who created the order edit.

declined_at
required
string or null <date-time>

The date with timezone at which the edit was declined.

declined_by
required
string or null

The unique identifier of the user or customer who declined the order edit.

declined_reason
required
string or null

An optional note why the order edit is declined.

id
required
string
Example: "oe_01G8TJSYT9M6AVS5N4EMNFS1EK"

The order edit's ID

internal_note
required
string or null
Example: "Included two more items B to the order."

An optional note with additional details about the order edit.

order_id
required
string
Example: "order_01G2SG30J8C85S4A5CHM2S1NS2"

The ID of the order that is edited

payment_collection_id
required
string or null
Example: "paycol_01G8TJSYT9M6AVS5N4EMNFS1EK"

The ID of the payment collection

requested_at
required
string or null <date-time>

The date with timezone at which the edit was requested.

requested_by
required
string or null

The unique identifier of the user or customer who requested the order edit.

status
required
string
Enum: "confirmed" "declined" "requested" "created" "canceled"

The status of the order edit.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

order
object or null

The details of the order that this order edit was created for.

Array of objects (Order Item Change)

The details of all the changes on the original order's line items.

subtotal
integer
Example: 8000

The total of subtotal

discount_total
integer
Example: 800

The total of discount

shipping_total
integer
Example: 800

The total of the shipping amount

gift_card_total
integer
Example: 800

The total of the gift card amount

gift_card_tax_total
integer
Example: 800

The total of the gift card tax amount

tax_total
integer
Example: 0

The total of tax

total
integer
Example: 8200

The total amount of the edited order.

difference_due
integer
Example: 8200

The difference between the total amount of the order and total amount of edited order.

Array of objects (Line Item)

The details of the cloned items from the original order with the new changes. Once the order edit is confirmed, these line items are associated with the original order.

object (Payment Collection)

A payment collection allows grouping and managing a list of payments at one. This can be helpful when making additional payment for order edits or integrating installment payments.

Request samples

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

Response samples

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

Delete an Order Edit

Delete an Order Edit. Only order edits that have the status created can be deleted.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Order Edit to delete.

Responses

Response Schema: application/json
id
required
string

The ID of the deleted Order Edit.

object
required
string
Default: "order_edit"

The type of the object that was deleted.

deleted
required
boolean
Default: true

Whether or not the Order Edit was deleted.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orderEdits.delete(orderEditId)
  .then(({ id, object, deleted }) => {
    console.log(id)
  })

Response samples

Content type
application/json
{
  • "id": "string",
  • "object": "order_edit",
  • "deleted": true
}

Cancel an Order Edit

Cancel an OrderEdit.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the OrderEdit.

Responses

Response Schema: application/json
required
object (Order Edit)

Order edit allows modifying items in an order, such as adding, updating, or deleting items from the original order. Once the order edit is confirmed, the changes are reflected on the original order.

canceled_at
required
string or null <date-time>

The date with timezone at which the edit was cancelled.

canceled_by
required
string or null

The unique identifier of the user or customer who cancelled the order edit.

confirmed_by
required
string or null

The unique identifier of the user or customer who confirmed the order edit.

confirmed_at
required
string or null <date-time>

The date with timezone at which the edit was confirmed.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

created_by
required
string

The unique identifier of the user or customer who created the order edit.

declined_at
required
string or null <date-time>

The date with timezone at which the edit was declined.

declined_by
required
string or null

The unique identifier of the user or customer who declined the order edit.

declined_reason
required
string or null

An optional note why the order edit is declined.

id
required
string
Example: "oe_01G8TJSYT9M6AVS5N4EMNFS1EK"

The order edit's ID

internal_note
required
string or null
Example: "Included two more items B to the order."

An optional note with additional details about the order edit.

order_id
required
string
Example: "order_01G2SG30J8C85S4A5CHM2S1NS2"

The ID of the order that is edited

payment_collection_id
required
string or null
Example: "paycol_01G8TJSYT9M6AVS5N4EMNFS1EK"

The ID of the payment collection

requested_at
required
string or null <date-time>

The date with timezone at which the edit was requested.

requested_by
required
string or null

The unique identifier of the user or customer who requested the order edit.

status
required
string
Enum: "confirmed" "declined" "requested" "created" "canceled"

The status of the order edit.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

order
object or null

The details of the order that this order edit was created for.

Array of objects (Order Item Change)

The details of all the changes on the original order's line items.

subtotal
integer
Example: 8000

The total of subtotal

discount_total
integer
Example: 800

The total of discount

shipping_total
integer
Example: 800

The total of the shipping amount

gift_card_total
integer
Example: 800

The total of the gift card amount

gift_card_tax_total
integer
Example: 800

The total of the gift card tax amount

tax_total
integer
Example: 0

The total of tax

total
integer
Example: 8200

The total amount of the edited order.

difference_due
integer
Example: 8200

The difference between the total amount of the order and total amount of edited order.

Array of objects (Line Item)

The details of the cloned items from the original order with the new changes. Once the order edit is confirmed, these line items are associated with the original order.

object (Payment Collection)

A payment collection allows grouping and managing a list of payments at one. This can be helpful when making additional payment for order edits or integrating installment payments.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orderEdits.cancel(orderEditId)
  .then(({ order_edit }) => {
    console.log(order_edit.id)
  })

Response samples

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

Delete a Line Item Change

Delete a line item change that indicates the addition, deletion, or update of a line item in the original order.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Order Edit.

change_id
required
string

The ID of the Line Item Change to delete.

Responses

Response Schema: application/json
id
required
string

The ID of the deleted Order Edit Item Change.

object
required
string
Default: "item_change"

The type of the object that was deleted.

deleted
required
boolean
Default: true

Whether or not the Order Edit Item Change was deleted.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orderEdits.deleteItemChange(orderEdit_id, itemChangeId)
  .then(({ id, object, deleted }) => {
    console.log(id)
  })

Response samples

Content type
application/json
{
  • "id": "string",
  • "object": "item_change",
  • "deleted": true
}

Confirm an OrderEdit

Confirm an Order Edit. This will reflect the changes in the order edit on the associated order.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the order edit.

Responses

Response Schema: application/json
required
object (Order Edit)

Order edit allows modifying items in an order, such as adding, updating, or deleting items from the original order. Once the order edit is confirmed, the changes are reflected on the original order.

canceled_at
required
string or null <date-time>

The date with timezone at which the edit was cancelled.

canceled_by
required
string or null

The unique identifier of the user or customer who cancelled the order edit.

confirmed_by
required
string or null

The unique identifier of the user or customer who confirmed the order edit.

confirmed_at
required
string or null <date-time>

The date with timezone at which the edit was confirmed.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

created_by
required
string

The unique identifier of the user or customer who created the order edit.

declined_at
required
string or null <date-time>

The date with timezone at which the edit was declined.

declined_by
required
string or null

The unique identifier of the user or customer who declined the order edit.

declined_reason
required
string or null

An optional note why the order edit is declined.

id
required
string
Example: "oe_01G8TJSYT9M6AVS5N4EMNFS1EK"

The order edit's ID

internal_note
required
string or null
Example: "Included two more items B to the order."

An optional note with additional details about the order edit.

order_id
required
string
Example: "order_01G2SG30J8C85S4A5CHM2S1NS2"

The ID of the order that is edited

payment_collection_id
required
string or null
Example: "paycol_01G8TJSYT9M6AVS5N4EMNFS1EK"

The ID of the payment collection

requested_at
required
string or null <date-time>

The date with timezone at which the edit was requested.

requested_by
required
string or null

The unique identifier of the user or customer who requested the order edit.

status
required
string
Enum: "confirmed" "declined" "requested" "created" "canceled"

The status of the order edit.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

order
object or null

The details of the order that this order edit was created for.

Array of objects (Order Item Change)

The details of all the changes on the original order's line items.

subtotal
integer
Example: 8000

The total of subtotal

discount_total
integer
Example: 800

The total of discount

shipping_total
integer
Example: 800

The total of the shipping amount

gift_card_total
integer
Example: 800

The total of the gift card amount

gift_card_tax_total
integer
Example: 800

The total of the gift card tax amount

tax_total
integer
Example: 0

The total of tax

total
integer
Example: 8200

The total amount of the edited order.

difference_due
integer
Example: 8200

The difference between the total amount of the order and total amount of edited order.

Array of objects (Line Item)

The details of the cloned items from the original order with the new changes. Once the order edit is confirmed, these line items are associated with the original order.

object (Payment Collection)

A payment collection allows grouping and managing a list of payments at one. This can be helpful when making additional payment for order edits or integrating installment payments.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orderEdits.confirm(orderEditId)
  .then(({ order_edit }) => {
    console.log(order_edit.id)
  })

Response samples

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

Add a Line Item

Create a line item change in the order edit that indicates adding an item in the original order. The item will not be added to the original order until the order edit is confirmed.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Order Edit.

Request Body schema: application/json
variant_id
required
string

The ID of the product variant associated with the item.

quantity
required
number

The quantity of the item.

metadata
object

An optional set of key-value pairs to hold additional information.

Responses

Response Schema: application/json
required
object (Order Edit)

Order edit allows modifying items in an order, such as adding, updating, or deleting items from the original order. Once the order edit is confirmed, the changes are reflected on the original order.

canceled_at
required
string or null <date-time>

The date with timezone at which the edit was cancelled.

canceled_by
required
string or null

The unique identifier of the user or customer who cancelled the order edit.

confirmed_by
required
string or null

The unique identifier of the user or customer who confirmed the order edit.

confirmed_at
required
string or null <date-time>

The date with timezone at which the edit was confirmed.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

created_by
required
string

The unique identifier of the user or customer who created the order edit.

declined_at
required
string or null <date-time>

The date with timezone at which the edit was declined.

declined_by
required
string or null

The unique identifier of the user or customer who declined the order edit.

declined_reason
required
string or null

An optional note why the order edit is declined.

id
required
string
Example: "oe_01G8TJSYT9M6AVS5N4EMNFS1EK"

The order edit's ID

internal_note
required
string or null
Example: "Included two more items B to the order."

An optional note with additional details about the order edit.

order_id
required
string
Example: "order_01G2SG30J8C85S4A5CHM2S1NS2"

The ID of the order that is edited

payment_collection_id
required
string or null
Example: "paycol_01G8TJSYT9M6AVS5N4EMNFS1EK"

The ID of the payment collection

requested_at
required
string or null <date-time>

The date with timezone at which the edit was requested.

requested_by
required
string or null

The unique identifier of the user or customer who requested the order edit.

status
required
string
Enum: "confirmed" "declined" "requested" "created" "canceled"

The status of the order edit.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

order
object or null

The details of the order that this order edit was created for.

Array of objects (Order Item Change)

The details of all the changes on the original order's line items.

subtotal
integer
Example: 8000

The total of subtotal

discount_total
integer
Example: 800

The total of discount

shipping_total
integer
Example: 800

The total of the shipping amount

gift_card_total
integer
Example: 800

The total of the gift card amount

gift_card_tax_total
integer
Example: 800

The total of the gift card tax amount

tax_total
integer
Example: 0

The total of tax

total
integer
Example: 8200

The total amount of the edited order.

difference_due
integer
Example: 8200

The difference between the total amount of the order and total amount of edited order.

Array of objects (Line Item)

The details of the cloned items from the original order with the new changes. Once the order edit is confirmed, these line items are associated with the original order.

object (Payment Collection)

A payment collection allows grouping and managing a list of payments at one. This can be helpful when making additional payment for order edits or integrating installment payments.

Request samples

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

Response samples

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

Upsert Line Item Change

Create or update a line item change in the order edit that indicates addition, deletion, or update of a line item into an original order. Line item changes are only reflected on the original order after the order edit is confirmed.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Order Edit.

item_id
required
string

The ID of the line item in the original order.

Request Body schema: application/json
quantity
required
number

The quantity to update

Responses

Response Schema: application/json
required
object (Order Edit)

Order edit allows modifying items in an order, such as adding, updating, or deleting items from the original order. Once the order edit is confirmed, the changes are reflected on the original order.

canceled_at
required
string or null <date-time>

The date with timezone at which the edit was cancelled.

canceled_by
required
string or null

The unique identifier of the user or customer who cancelled the order edit.

confirmed_by
required
string or null

The unique identifier of the user or customer who confirmed the order edit.

confirmed_at
required
string or null <date-time>

The date with timezone at which the edit was confirmed.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

created_by
required
string

The unique identifier of the user or customer who created the order edit.

declined_at
required
string or null <date-time>

The date with timezone at which the edit was declined.

declined_by
required
string or null

The unique identifier of the user or customer who declined the order edit.

declined_reason
required
string or null

An optional note why the order edit is declined.

id
required
string
Example: "oe_01G8TJSYT9M6AVS5N4EMNFS1EK"

The order edit's ID

internal_note
required
string or null
Example: "Included two more items B to the order."

An optional note with additional details about the order edit.

order_id
required
string
Example: "order_01G2SG30J8C85S4A5CHM2S1NS2"

The ID of the order that is edited

payment_collection_id
required
string or null
Example: "paycol_01G8TJSYT9M6AVS5N4EMNFS1EK"

The ID of the payment collection

requested_at
required
string or null <date-time>

The date with timezone at which the edit was requested.

requested_by
required
string or null

The unique identifier of the user or customer who requested the order edit.

status
required
string
Enum: "confirmed" "declined" "requested" "created" "canceled"

The status of the order edit.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

order
object or null

The details of the order that this order edit was created for.

Array of objects (Order Item Change)

The details of all the changes on the original order's line items.

subtotal
integer
Example: 8000

The total of subtotal

discount_total
integer
Example: 800

The total of discount

shipping_total
integer
Example: 800

The total of the shipping amount

gift_card_total
integer
Example: 800

The total of the gift card amount

gift_card_tax_total
integer
Example: 800

The total of the gift card tax amount

tax_total
integer
Example: 0

The total of tax

total
integer
Example: 8200

The total amount of the edited order.

difference_due
integer
Example: 8200

The difference between the total amount of the order and total amount of edited order.

Array of objects (Line Item)

The details of the cloned items from the original order with the new changes. Once the order edit is confirmed, these line items are associated with the original order.

object (Payment Collection)

A payment collection allows grouping and managing a list of payments at one. This can be helpful when making additional payment for order edits or integrating installment payments.

Request samples

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

Response samples

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

Delete Line Item

Create a line item change in the order edit that indicates deleting an item in the original order. The item in the original order will not be deleted until the order edit is confirmed.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Order Edit.

item_id
required
string

The ID of line item in the original order.

Responses

Response Schema: application/json
required
object (Order Edit)

Order edit allows modifying items in an order, such as adding, updating, or deleting items from the original order. Once the order edit is confirmed, the changes are reflected on the original order.

canceled_at
required
string or null <date-time>

The date with timezone at which the edit was cancelled.

canceled_by
required
string or null

The unique identifier of the user or customer who cancelled the order edit.

confirmed_by
required
string or null

The unique identifier of the user or customer who confirmed the order edit.

confirmed_at
required
string or null <date-time>

The date with timezone at which the edit was confirmed.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

created_by
required
string

The unique identifier of the user or customer who created the order edit.

declined_at
required
string or null <date-time>

The date with timezone at which the edit was declined.

declined_by
required
string or null

The unique identifier of the user or customer who declined the order edit.

declined_reason
required
string or null

An optional note why the order edit is declined.

id
required
string
Example: "oe_01G8TJSYT9M6AVS5N4EMNFS1EK"

The order edit's ID

internal_note
required
string or null
Example: "Included two more items B to the order."

An optional note with additional details about the order edit.

order_id
required
string
Example: "order_01G2SG30J8C85S4A5CHM2S1NS2"

The ID of the order that is edited

payment_collection_id
required
string or null
Example: "paycol_01G8TJSYT9M6AVS5N4EMNFS1EK"

The ID of the payment collection

requested_at
required
string or null <date-time>

The date with timezone at which the edit was requested.

requested_by
required
string or null

The unique identifier of the user or customer who requested the order edit.

status
required
string
Enum: "confirmed" "declined" "requested" "created" "canceled"

The status of the order edit.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

order
object or null

The details of the order that this order edit was created for.

Array of objects (Order Item Change)

The details of all the changes on the original order's line items.

subtotal
integer
Example: 8000

The total of subtotal

discount_total
integer
Example: 800

The total of discount

shipping_total
integer
Example: 800

The total of the shipping amount

gift_card_total
integer
Example: 800

The total of the gift card amount

gift_card_tax_total
integer
Example: 800

The total of the gift card tax amount

tax_total
integer
Example: 0

The total of tax

total
integer
Example: 8200

The total amount of the edited order.

difference_due
integer
Example: 8200

The difference between the total amount of the order and total amount of edited order.

Array of objects (Line Item)

The details of the cloned items from the original order with the new changes. Once the order edit is confirmed, these line items are associated with the original order.

object (Payment Collection)

A payment collection allows grouping and managing a list of payments at one. This can be helpful when making additional payment for order edits or integrating installment payments.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orderEdits.removeLineItem(orderEditId, lineItemId)
  .then(({ order_edit }) => {
    console.log(order_edit.id)
  })

Response samples

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

Request Confirmation

Request customer confirmation of an Order Edit. This would emit the event order-edit.requested which Notification Providers listen to and send a notification to the customer about the order edit.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Order Edit.

Responses

Response Schema: application/json
required
object (Order Edit)

Order edit allows modifying items in an order, such as adding, updating, or deleting items from the original order. Once the order edit is confirmed, the changes are reflected on the original order.

canceled_at
required
string or null <date-time>

The date with timezone at which the edit was cancelled.

canceled_by
required
string or null

The unique identifier of the user or customer who cancelled the order edit.

confirmed_by
required
string or null

The unique identifier of the user or customer who confirmed the order edit.

confirmed_at
required
string or null <date-time>

The date with timezone at which the edit was confirmed.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

created_by
required
string

The unique identifier of the user or customer who created the order edit.

declined_at
required
string or null <date-time>

The date with timezone at which the edit was declined.

declined_by
required
string or null

The unique identifier of the user or customer who declined the order edit.

declined_reason
required
string or null

An optional note why the order edit is declined.

id
required
string
Example: "oe_01G8TJSYT9M6AVS5N4EMNFS1EK"

The order edit's ID

internal_note
required
string or null
Example: "Included two more items B to the order."

An optional note with additional details about the order edit.

order_id
required
string
Example: "order_01G2SG30J8C85S4A5CHM2S1NS2"

The ID of the order that is edited

payment_collection_id
required
string or null
Example: "paycol_01G8TJSYT9M6AVS5N4EMNFS1EK"

The ID of the payment collection

requested_at
required
string or null <date-time>

The date with timezone at which the edit was requested.

requested_by
required
string or null

The unique identifier of the user or customer who requested the order edit.

status
required
string
Enum: "confirmed" "declined" "requested" "created" "canceled"

The status of the order edit.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

order
object or null

The details of the order that this order edit was created for.

Array of objects (Order Item Change)

The details of all the changes on the original order's line items.

subtotal
integer
Example: 8000

The total of subtotal

discount_total
integer
Example: 800

The total of discount

shipping_total
integer
Example: 800

The total of the shipping amount

gift_card_total
integer
Example: 800

The total of the gift card amount

gift_card_tax_total
integer
Example: 800

The total of the gift card tax amount

tax_total
integer
Example: 0

The total of tax

total
integer
Example: 8200

The total amount of the edited order.

difference_due
integer
Example: 8200

The difference between the total amount of the order and total amount of edited order.

Array of objects (Line Item)

The details of the cloned items from the original order with the new changes. Once the order edit is confirmed, these line items are associated with the original order.

object (Payment Collection)

A payment collection allows grouping and managing a list of payments at one. This can be helpful when making additional payment for order edits or integrating installment payments.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orderEdits.requestConfirmation(orderEditId)
  .then({ order_edit }) => {
    console.log(order_edit.id)
  })

Response samples

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

Orders

Orders are purchases made by customers, typically through a storefront using the Store API. Draft orders created by the admin are also transformed to an Order once the payment is captured. Managing orders include managing fulfillment, payment, claims, reservations, and more.

List Orders

Retrieve a list of Orders. The orders can be filtered by fields such as status or display_id. The order can also be paginated.

Authorizations:
API TokenCookie Session ID
query Parameters
q
string

term to search orders' shipping address, first name, email, and display ID

id
string

Filter by ID.

status
Array of strings
Items Enum: "pending" "completed" "archived" "canceled" "requires_action"

Filter by status

fulfillment_status
Array of strings
Items Enum: "not_fulfilled" "fulfilled" "partially_fulfilled" "shipped" "partially_shipped" "canceled" "returned" "partially_returned" "requires_action"

Filter by fulfillment status

payment_status
Array of strings
Items Enum: "captured" "awaiting" "not_paid" "refunded" "partially_refunded" "canceled" "requires_action"

Filter by payment status

display_id
string

Filter by display ID

cart_id
string

Filter by cart ID

customer_id
string

Filter by customer ID

email
string

Filter by email

string or Array of strings

Filter by region IDs.

currency_code
string

Filter by currency codes.

tax_rate
string

Filter by tax rate.

object

Filter by a creation date range.

object

Filter by an update date range.

object

Filter by a cancelation date range.

sales_channel_id
Array of strings

Filter by Sales Channel IDs

offset
integer
Default: 0

The number of orders to skip when retrieving the orders.

limit
integer
Default: 50

Limit the number of orders returned.

expand
string

Comma-separated relations that should be expanded in the returned order.

fields
string

Comma-separated fields that should be included in the returned order.

Responses

Response Schema: application/json
required
Array of objects (Order)

An array of order details.

count
required
integer

The total number of items available

offset
required
integer

The number of orders skipped when retrieving the orders.

limit
required
integer

The number of items per page

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.list()
.then(({ orders, limit, offset, count }) => {
  console.log(orders.length);
});

Response samples

Content type
application/json
{
  • "orders": [
    ],
  • "count": 0,
  • "offset": 0,
  • "limit": 0
}

Get an Order

Retrieve an Order's details.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Order.

query Parameters
expand
string

Comma-separated relations that should be expanded in the returned order.

fields
string

Comma-separated fields that should be included in the returned order.

Responses

Response Schema: application/json
required
object (Order)

An order is a purchase made by a customer. It holds details about payment and fulfillment of the order. An order may also be created from a draft order, which is created by an admin user.

billing_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The ID of the billing address associated with the order

canceled_at
required
string or null <date-time>

The date the order was canceled on.

cart_id
required
string or null
Example: "cart_01G8ZH853Y6TFXWPG5EYE81X63"

The ID of the cart associated with the order

created_at
required
string <date-time>

The date with timezone at which the resource was created.

currency_code
required
string
Example: "usd"

The 3 character currency code that is used in the order

customer_id
required
string
Example: "cus_01G2SG30J8C85S4A5CHM2S1NS2"

The ID of the customer associated with the order

draft_order_id
required
string or null
Example: null

The ID of the draft order this order was created from.

display_id
required
integer
Example: 2

The order's display ID

email
required
string <email>

The email associated with the order

external_id
required
string or null
Example: null

The ID of an external order.

fulfillment_status
required
string
Default: "not_fulfilled"
Enum: "not_fulfilled" "partially_fulfilled" "fulfilled" "partially_shipped" "shipped" "partially_returned" "returned" "canceled" "requires_action"

The order's fulfillment status

id
required
string
Example: "order_01G8TJSYT9M6AVS5N4EMNFS1EK"

The order's ID

idempotency_key
required
string or null

Randomly generated key used to continue the processing of the order in case of failure.

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

An optional key-value map with additional details

no_notification
required
boolean or null
Example: false

Flag for describing whether or not notifications related to this should be send.

payment_status
required
string
Default: "not_paid"
Enum: "not_paid" "awaiting" "captured" "partially_refunded" "refunded" "canceled" "requires_action"

The order's payment status

region_id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The ID of the region this order was created in.

shipping_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The ID of the shipping address associated with the order

status
required
string
Default: "pending"
Enum: "pending" "completed" "archived" "canceled" "requires_action"

The order's status

tax_rate
required
number or null
Example: 0

The order's tax rate

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

cart
object or null

The details of the cart associated with the order.

customer
object or null

The details of the customer associated with the order.

object (Address)

An address is used across the Medusa backend within other schemas and object types. For example, a customer's billing and shipping addresses both use the Address entity.

object (Address)

An address is used across the Medusa backend within other schemas and object types. For example, a customer's billing and shipping addresses both use the Address entity.

object (Region)

A region holds settings specific to a geographical location, including the currency, tax rates, and fulfillment and payment providers. A Region can consist of multiple countries to accomodate common shopping settings across countries.

object (Currency)

Currency

Array of objects (Discount)

The details of the discounts applied on the order.

Array of objects (Gift Card)

The details of the gift card used in the order.

Array of objects (Shipping Method)

The details of the shipping methods used in the order.

payments
Array of objects

The details of the payments used in the order.

fulfillments
Array of objects

The details of the fulfillments created for the order.

returns
Array of objects

The details of the returns created for the order.

claims
Array of objects

The details of the claims created for the order.

refunds
Array of objects

The details of the refunds created for the order.

swaps
Array of objects

The details of the swaps created for the order.

draft_order
object or null

The details of the draft order this order was created from.

Array of objects (Line Item)

The details of the line items that belong to the order.

edits
Array of objects

The details of the order edits done on the order.

Array of objects (Gift Card Transaction)

The gift card transactions made in the order.

sales_channel_id
string or null
Example: null

The ID of the sales channel this order belongs to.

object (Sales Channel)

A Sales Channel is a method a business offers its products for purchase for the customers. For example, a Webshop can be a sales channel, and a mobile app can be another.

shipping_total
integer
Example: 1000

The total of shipping

raw_discount_total
integer
Example: 800

The total of discount

discount_total
integer
Example: 800

The total of discount rounded

tax_total
integer
Example: 0

The total of tax

refunded_total
integer
Example: 0

The total amount refunded if the order is returned.

total
integer
Example: 8200

The total amount of the order

subtotal
integer
Example: 8000

The subtotal of the order

paid_total
integer
Example: 8000

The total amount paid

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

Array of objects (Line Item)

The details of the line items that are returnable as part of the order, swaps, or claims

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.retrieve(orderId)
.then(({ order }) => {
  console.log(order.id);
});

Response samples

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

Update an Order

Update and order's details.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Order.

query Parameters
expand
string

Comma-separated relations that should be expanded in the returned order.

fields
string

Comma-separated fields that should be included in the returned order.

Request Body schema: application/json
email
string

the email associated with the order

object (AddressPayload)

Address fields used when creating/updating an address.

object (AddressPayload)

Address fields used when creating/updating an address.

Array of objects (Line Item)

The line items of the order

region
string

ID of the region that the order is associated with.

Array of objects (Discount)

The discounts applied to the order

customer_id
string

The ID of the customer associated with the order.

object

The payment method chosen for the order.

object

The Shipping Method used for shipping the order.

no_notification
boolean

If set to true, no notification will be sent to the customer related to this order.

Responses

Response Schema: application/json
required
object (Order)

An order is a purchase made by a customer. It holds details about payment and fulfillment of the order. An order may also be created from a draft order, which is created by an admin user.

billing_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The ID of the billing address associated with the order

canceled_at
required
string or null <date-time>

The date the order was canceled on.

cart_id
required
string or null
Example: "cart_01G8ZH853Y6TFXWPG5EYE81X63"

The ID of the cart associated with the order

created_at
required
string <date-time>

The date with timezone at which the resource was created.

currency_code
required
string
Example: "usd"

The 3 character currency code that is used in the order

customer_id
required
string
Example: "cus_01G2SG30J8C85S4A5CHM2S1NS2"

The ID of the customer associated with the order

draft_order_id
required
string or null
Example: null

The ID of the draft order this order was created from.

display_id
required
integer
Example: 2

The order's display ID

email
required
string <email>

The email associated with the order

external_id
required
string or null
Example: null

The ID of an external order.

fulfillment_status
required
string
Default: "not_fulfilled"
Enum: "not_fulfilled" "partially_fulfilled" "fulfilled" "partially_shipped" "shipped" "partially_returned" "returned" "canceled" "requires_action"

The order's fulfillment status

id
required
string
Example: "order_01G8TJSYT9M6AVS5N4EMNFS1EK"

The order's ID

idempotency_key
required
string or null

Randomly generated key used to continue the processing of the order in case of failure.

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

An optional key-value map with additional details

no_notification
required
boolean or null
Example: false

Flag for describing whether or not notifications related to this should be send.

payment_status
required
string
Default: "not_paid"
Enum: "not_paid" "awaiting" "captured" "partially_refunded" "refunded" "canceled" "requires_action"

The order's payment status

region_id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The ID of the region this order was created in.

shipping_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The ID of the shipping address associated with the order

status
required
string
Default: "pending"
Enum: "pending" "completed" "archived" "canceled" "requires_action"

The order's status

tax_rate
required
number or null
Example: 0

The order's tax rate

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

cart
object or null

The details of the cart associated with the order.

customer
object or null

The details of the customer associated with the order.

object (Address)

An address is used across the Medusa backend within other schemas and object types. For example, a customer's billing and shipping addresses both use the Address entity.

object (Address)

An address is used across the Medusa backend within other schemas and object types. For example, a customer's billing and shipping addresses both use the Address entity.

object (Region)

A region holds settings specific to a geographical location, including the currency, tax rates, and fulfillment and payment providers. A Region can consist of multiple countries to accomodate common shopping settings across countries.

object (Currency)

Currency

Array of objects (Discount)

The details of the discounts applied on the order.

Array of objects (Gift Card)

The details of the gift card used in the order.

Array of objects (Shipping Method)

The details of the shipping methods used in the order.

payments
Array of objects

The details of the payments used in the order.

fulfillments
Array of objects

The details of the fulfillments created for the order.

returns
Array of objects

The details of the returns created for the order.

claims
Array of objects

The details of the claims created for the order.

refunds
Array of objects

The details of the refunds created for the order.

swaps
Array of objects

The details of the swaps created for the order.

draft_order
object or null

The details of the draft order this order was created from.

Array of objects (Line Item)

The details of the line items that belong to the order.

edits
Array of objects

The details of the order edits done on the order.

Array of objects (Gift Card Transaction)

The gift card transactions made in the order.

sales_channel_id
string or null
Example: null

The ID of the sales channel this order belongs to.

object (Sales Channel)

A Sales Channel is a method a business offers its products for purchase for the customers. For example, a Webshop can be a sales channel, and a mobile app can be another.

shipping_total
integer
Example: 1000

The total of shipping

raw_discount_total
integer
Example: 800

The total of discount

discount_total
integer
Example: 800

The total of discount rounded

tax_total
integer
Example: 0

The total of tax

refunded_total
integer
Example: 0

The total amount refunded if the order is returned.

total
integer
Example: 8200

The total amount of the order

subtotal
integer
Example: 8000

The subtotal of the order

paid_total
integer
Example: 8000

The total amount paid

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

Array of objects (Line Item)

The details of the line items that are returnable as part of the order, swaps, or claims

Request samples

Content type
application/json
{
  • "email": "string",
  • "billing_address": {
    },
  • "shipping_address": {
    },
  • "items": [
    ],
  • "region": "string",
  • "discounts": [
    ],
  • "customer_id": "string",
  • "payment_method": {
    },
  • "shipping_method": {
    },
  • "no_notification": true
}

Response samples

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

Archive Order

Archive an order and change its status.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Order.

query Parameters
expand
string

Comma-separated relations that should be expanded in the returned order.

fields
string

Comma-separated fields that should be included in the returned order.

Responses

Response Schema: application/json
required
object (Order)

An order is a purchase made by a customer. It holds details about payment and fulfillment of the order. An order may also be created from a draft order, which is created by an admin user.

billing_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The ID of the billing address associated with the order

canceled_at
required
string or null <date-time>

The date the order was canceled on.

cart_id
required
string or null
Example: "cart_01G8ZH853Y6TFXWPG5EYE81X63"

The ID of the cart associated with the order

created_at
required
string <date-time>

The date with timezone at which the resource was created.

currency_code
required
string
Example: "usd"

The 3 character currency code that is used in the order

customer_id
required
string
Example: "cus_01G2SG30J8C85S4A5CHM2S1NS2"

The ID of the customer associated with the order

draft_order_id
required
string or null
Example: null

The ID of the draft order this order was created from.

display_id
required
integer
Example: 2

The order's display ID

email
required
string <email>

The email associated with the order

external_id
required
string or null
Example: null

The ID of an external order.

fulfillment_status
required
string
Default: "not_fulfilled"
Enum: "not_fulfilled" "partially_fulfilled" "fulfilled" "partially_shipped" "shipped" "partially_returned" "returned" "canceled" "requires_action"

The order's fulfillment status

id
required
string
Example: "order_01G8TJSYT9M6AVS5N4EMNFS1EK"

The order's ID

idempotency_key
required
string or null

Randomly generated key used to continue the processing of the order in case of failure.

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

An optional key-value map with additional details

no_notification
required
boolean or null
Example: false

Flag for describing whether or not notifications related to this should be send.

payment_status
required
string
Default: "not_paid"
Enum: "not_paid" "awaiting" "captured" "partially_refunded" "refunded" "canceled" "requires_action"

The order's payment status

region_id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The ID of the region this order was created in.

shipping_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The ID of the shipping address associated with the order

status
required
string
Default: "pending"
Enum: "pending" "completed" "archived" "canceled" "requires_action"

The order's status

tax_rate
required
number or null
Example: 0

The order's tax rate

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

cart
object or null

The details of the cart associated with the order.

customer
object or null

The details of the customer associated with the order.

object (Address)

An address is used across the Medusa backend within other schemas and object types. For example, a customer's billing and shipping addresses both use the Address entity.

object (Address)

An address is used across the Medusa backend within other schemas and object types. For example, a customer's billing and shipping addresses both use the Address entity.

object (Region)

A region holds settings specific to a geographical location, including the currency, tax rates, and fulfillment and payment providers. A Region can consist of multiple countries to accomodate common shopping settings across countries.

object (Currency)

Currency

Array of objects (Discount)

The details of the discounts applied on the order.

Array of objects (Gift Card)

The details of the gift card used in the order.

Array of objects (Shipping Method)

The details of the shipping methods used in the order.

payments
Array of objects

The details of the payments used in the order.

fulfillments
Array of objects

The details of the fulfillments created for the order.

returns
Array of objects

The details of the returns created for the order.

claims
Array of objects

The details of the claims created for the order.

refunds
Array of objects

The details of the refunds created for the order.

swaps
Array of objects

The details of the swaps created for the order.

draft_order
object or null

The details of the draft order this order was created from.

Array of objects (Line Item)

The details of the line items that belong to the order.

edits
Array of objects

The details of the order edits done on the order.

Array of objects (Gift Card Transaction)

The gift card transactions made in the order.

sales_channel_id
string or null
Example: null

The ID of the sales channel this order belongs to.

object (Sales Channel)

A Sales Channel is a method a business offers its products for purchase for the customers. For example, a Webshop can be a sales channel, and a mobile app can be another.

shipping_total
integer
Example: 1000

The total of shipping

raw_discount_total
integer
Example: 800

The total of discount

discount_total
integer
Example: 800

The total of discount rounded

tax_total
integer
Example: 0

The total of tax

refunded_total
integer
Example: 0

The total amount refunded if the order is returned.

total
integer
Example: 8200

The total amount of the order

subtotal
integer
Example: 8000

The subtotal of the order

paid_total
integer
Example: 8000

The total amount paid

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

Array of objects (Line Item)

The details of the line items that are returnable as part of the order, swaps, or claims

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.archive(orderId)
.then(({ order }) => {
  console.log(order.id);
});

Response samples

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

Cancel an Order

Cancel an order and change its status. This will also cancel any associated Fulfillments and Payments, and it may fail if the Payment or Fulfillment Provider is unable to cancel the Payment/Fulfillment.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Order.

query Parameters
expand
string

Comma-separated relations that should be expanded in the returned order.

fields
string

Comma-separated fields that should be included in the returned order.

Responses

Response Schema: application/json
required
object (Order)

An order is a purchase made by a customer. It holds details about payment and fulfillment of the order. An order may also be created from a draft order, which is created by an admin user.

billing_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The ID of the billing address associated with the order

canceled_at
required
string or null <date-time>

The date the order was canceled on.

cart_id
required
string or null
Example: "cart_01G8ZH853Y6TFXWPG5EYE81X63"

The ID of the cart associated with the order

created_at
required
string <date-time>

The date with timezone at which the resource was created.

currency_code
required
string
Example: "usd"

The 3 character currency code that is used in the order

customer_id
required
string
Example: "cus_01G2SG30J8C85S4A5CHM2S1NS2"

The ID of the customer associated with the order

draft_order_id
required
string or null
Example: null

The ID of the draft order this order was created from.

display_id
required
integer
Example: 2

The order's display ID

email
required
string <email>

The email associated with the order

external_id
required
string or null
Example: null

The ID of an external order.

fulfillment_status
required
string
Default: "not_fulfilled"
Enum: "not_fulfilled" "partially_fulfilled" "fulfilled" "partially_shipped" "shipped" "partially_returned" "returned" "canceled" "requires_action"

The order's fulfillment status

id
required
string
Example: "order_01G8TJSYT9M6AVS5N4EMNFS1EK"

The order's ID

idempotency_key
required
string or null

Randomly generated key used to continue the processing of the order in case of failure.

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

An optional key-value map with additional details

no_notification
required
boolean or null
Example: false

Flag for describing whether or not notifications related to this should be send.

payment_status
required
string
Default: "not_paid"
Enum: "not_paid" "awaiting" "captured" "partially_refunded" "refunded" "canceled" "requires_action"

The order's payment status

region_id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The ID of the region this order was created in.

shipping_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The ID of the shipping address associated with the order

status
required
string
Default: "pending"
Enum: "pending" "completed" "archived" "canceled" "requires_action"

The order's status

tax_rate
required
number or null
Example: 0

The order's tax rate

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

cart
object or null

The details of the cart associated with the order.

customer
object or null

The details of the customer associated with the order.

object (Address)

An address is used across the Medusa backend within other schemas and object types. For example, a customer's billing and shipping addresses both use the Address entity.

object (Address)

An address is used across the Medusa backend within other schemas and object types. For example, a customer's billing and shipping addresses both use the Address entity.

object (Region)

A region holds settings specific to a geographical location, including the currency, tax rates, and fulfillment and payment providers. A Region can consist of multiple countries to accomodate common shopping settings across countries.

object (Currency)

Currency

Array of objects (Discount)

The details of the discounts applied on the order.

Array of objects (Gift Card)

The details of the gift card used in the order.

Array of objects (Shipping Method)

The details of the shipping methods used in the order.

payments
Array of objects

The details of the payments used in the order.

fulfillments
Array of objects

The details of the fulfillments created for the order.

returns
Array of objects

The details of the returns created for the order.

claims
Array of objects

The details of the claims created for the order.

refunds
Array of objects

The details of the refunds created for the order.

swaps
Array of objects

The details of the swaps created for the order.

draft_order
object or null

The details of the draft order this order was created from.

Array of objects (Line Item)

The details of the line items that belong to the order.

edits
Array of objects

The details of the order edits done on the order.

Array of objects (Gift Card Transaction)

The gift card transactions made in the order.

sales_channel_id
string or null
Example: null

The ID of the sales channel this order belongs to.

object (Sales Channel)

A Sales Channel is a method a business offers its products for purchase for the customers. For example, a Webshop can be a sales channel, and a mobile app can be another.

shipping_total
integer
Example: 1000

The total of shipping

raw_discount_total
integer
Example: 800

The total of discount

discount_total
integer
Example: 800

The total of discount rounded

tax_total
integer
Example: 0

The total of tax

refunded_total
integer
Example: 0

The total amount refunded if the order is returned.

total
integer
Example: 8200

The total amount of the order

subtotal
integer
Example: 8000

The subtotal of the order

paid_total
integer
Example: 8000

The total amount paid

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

Array of objects (Line Item)

The details of the line items that are returnable as part of the order, swaps, or claims

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.cancel(orderId)
.then(({ order }) => {
  console.log(order.id);
});

Response samples

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

Capture an Order's Payments

Capture all the Payments associated with an Order. The payment of canceled orders can't be captured.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Order.

query Parameters
expand
string

Comma-separated relations that should be expanded in the returned order.

fields
string

Comma-separated fields that should be included in the returned order.

Responses

Response Schema: application/json
required
object (Order)

An order is a purchase made by a customer. It holds details about payment and fulfillment of the order. An order may also be created from a draft order, which is created by an admin user.

billing_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The ID of the billing address associated with the order

canceled_at
required
string or null <date-time>

The date the order was canceled on.

cart_id
required
string or null
Example: "cart_01G8ZH853Y6TFXWPG5EYE81X63"

The ID of the cart associated with the order

created_at
required
string <date-time>

The date with timezone at which the resource was created.

currency_code
required
string
Example: "usd"

The 3 character currency code that is used in the order

customer_id
required
string
Example: "cus_01G2SG30J8C85S4A5CHM2S1NS2"

The ID of the customer associated with the order

draft_order_id
required
string or null
Example: null

The ID of the draft order this order was created from.

display_id
required
integer
Example: 2

The order's display ID

email
required
string <email>

The email associated with the order

external_id
required
string or null
Example: null

The ID of an external order.

fulfillment_status
required
string
Default: "not_fulfilled"
Enum: "not_fulfilled" "partially_fulfilled" "fulfilled" "partially_shipped" "shipped" "partially_returned" "returned" "canceled" "requires_action"

The order's fulfillment status

id
required
string
Example: "order_01G8TJSYT9M6AVS5N4EMNFS1EK"

The order's ID

idempotency_key
required
string or null

Randomly generated key used to continue the processing of the order in case of failure.

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

An optional key-value map with additional details

no_notification
required
boolean or null
Example: false

Flag for describing whether or not notifications related to this should be send.

payment_status
required
string
Default: "not_paid"
Enum: "not_paid" "awaiting" "captured" "partially_refunded" "refunded" "canceled" "requires_action"

The order's payment status

region_id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The ID of the region this order was created in.

shipping_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The ID of the shipping address associated with the order

status
required
string
Default: "pending"
Enum: "pending" "completed" "archived" "canceled" "requires_action"

The order's status

tax_rate
required
number or null
Example: 0

The order's tax rate

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

cart
object or null

The details of the cart associated with the order.

customer
object or null

The details of the customer associated with the order.

object (Address)

An address is used across the Medusa backend within other schemas and object types. For example, a customer's billing and shipping addresses both use the Address entity.

object (Address)

An address is used across the Medusa backend within other schemas and object types. For example, a customer's billing and shipping addresses both use the Address entity.

object (Region)

A region holds settings specific to a geographical location, including the currency, tax rates, and fulfillment and payment providers. A Region can consist of multiple countries to accomodate common shopping settings across countries.

object (Currency)

Currency

Array of objects (Discount)

The details of the discounts applied on the order.

Array of objects (Gift Card)

The details of the gift card used in the order.

Array of objects (Shipping Method)

The details of the shipping methods used in the order.

payments
Array of objects

The details of the payments used in the order.

fulfillments
Array of objects

The details of the fulfillments created for the order.

returns
Array of objects

The details of the returns created for the order.

claims
Array of objects

The details of the claims created for the order.

refunds
Array of objects

The details of the refunds created for the order.

swaps
Array of objects

The details of the swaps created for the order.

draft_order
object or null

The details of the draft order this order was created from.

Array of objects (Line Item)

The details of the line items that belong to the order.

edits
Array of objects

The details of the order edits done on the order.

Array of objects (Gift Card Transaction)

The gift card transactions made in the order.

sales_channel_id
string or null
Example: null

The ID of the sales channel this order belongs to.

object (Sales Channel)

A Sales Channel is a method a business offers its products for purchase for the customers. For example, a Webshop can be a sales channel, and a mobile app can be another.

shipping_total
integer
Example: 1000

The total of shipping

raw_discount_total
integer
Example: 800

The total of discount

discount_total
integer
Example: 800

The total of discount rounded

tax_total
integer
Example: 0

The total of tax

refunded_total
integer
Example: 0

The total amount refunded if the order is returned.

total
integer
Example: 8200

The total amount of the order

subtotal
integer
Example: 8000

The subtotal of the order

paid_total
integer
Example: 8000

The total amount paid

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

Array of objects (Line Item)

The details of the line items that are returnable as part of the order, swaps, or claims

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.capturePayment(orderId)
.then(({ order }) => {
  console.log(order.id);
});

Response samples

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

Create a Claim

Create a Claim for an order. If a return shipping method is specified, a return will also be created and associated with the claim. If the claim's type is refund, the refund is processed as well.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Order.

query Parameters
expand
string

Comma-separated relations that should be expanded in the returned order.

fields
string

Comma-separated fields that should be included in the returned order.

Request Body schema: application/json
type
required
string
Enum: "replace" "refund"

The type of the Claim. This will determine how the Claim is treated: replace Claims will result in a Fulfillment with new items being created, while a refund Claim will refund the amount paid for the claimed items.

required
Array of objects

The Claim Items that the Claim will consist of.

object

Optional details for the Return Shipping Method, if the items are to be sent back. Providing this field will result in a return being created and associated with the claim.

Array of objects

The new items to send to the Customer. This is only used if the claim's type is replace.

Array of objects

The Shipping Methods to send the additional Line Items with. This is only used if the claim's type is replace.

object (AddressPayload)

Address fields used when creating/updating an address.

refund_amount
integer

The amount to refund the customer. This is used when the claim's type is refund.

no_notification
boolean

If set to true no notification will be send related to this Claim.

metadata
object

An optional set of key-value pairs to hold additional information.

Responses

Response Schema: application/json
required
object (Order)

An order is a purchase made by a customer. It holds details about payment and fulfillment of the order. An order may also be created from a draft order, which is created by an admin user.

billing_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The ID of the billing address associated with the order

canceled_at
required
string or null <date-time>

The date the order was canceled on.

cart_id
required
string or null
Example: "cart_01G8ZH853Y6TFXWPG5EYE81X63"

The ID of the cart associated with the order

created_at
required
string <date-time>

The date with timezone at which the resource was created.

currency_code
required
string
Example: "usd"

The 3 character currency code that is used in the order

customer_id
required
string
Example: "cus_01G2SG30J8C85S4A5CHM2S1NS2"

The ID of the customer associated with the order

draft_order_id
required
string or null
Example: null

The ID of the draft order this order was created from.

display_id
required
integer
Example: 2

The order's display ID

email
required
string <email>

The email associated with the order

external_id
required
string or null
Example: null

The ID of an external order.

fulfillment_status
required
string
Default: "not_fulfilled"
Enum: "not_fulfilled" "partially_fulfilled" "fulfilled" "partially_shipped" "shipped" "partially_returned" "returned" "canceled" "requires_action"

The order's fulfillment status

id
required
string
Example: "order_01G8TJSYT9M6AVS5N4EMNFS1EK"

The order's ID

idempotency_key
required
string or null

Randomly generated key used to continue the processing of the order in case of failure.

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

An optional key-value map with additional details

no_notification
required
boolean or null
Example: false

Flag for describing whether or not notifications related to this should be send.

payment_status
required
string
Default: "not_paid"
Enum: "not_paid" "awaiting" "captured" "partially_refunded" "refunded" "canceled" "requires_action"

The order's payment status

region_id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The ID of the region this order was created in.

shipping_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The ID of the shipping address associated with the order

status
required
string
Default: "pending"
Enum: "pending" "completed" "archived" "canceled" "requires_action"

The order's status

tax_rate
required
number or null
Example: 0

The order's tax rate

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

cart
object or null

The details of the cart associated with the order.

customer
object or null

The details of the customer associated with the order.

object (Address)

An address is used across the Medusa backend within other schemas and object types. For example, a customer's billing and shipping addresses both use the Address entity.

object (Address)

An address is used across the Medusa backend within other schemas and object types. For example, a customer's billing and shipping addresses both use the Address entity.

object (Region)

A region holds settings specific to a geographical location, including the currency, tax rates, and fulfillment and payment providers. A Region can consist of multiple countries to accomodate common shopping settings across countries.

object (Currency)

Currency

Array of objects (Discount)

The details of the discounts applied on the order.

Array of objects (Gift Card)

The details of the gift card used in the order.

Array of objects (Shipping Method)

The details of the shipping methods used in the order.

payments
Array of objects

The details of the payments used in the order.

fulfillments
Array of objects

The details of the fulfillments created for the order.

returns
Array of objects

The details of the returns created for the order.

claims
Array of objects

The details of the claims created for the order.

refunds
Array of objects

The details of the refunds created for the order.

swaps
Array of objects

The details of the swaps created for the order.

draft_order
object or null

The details of the draft order this order was created from.

Array of objects (Line Item)

The details of the line items that belong to the order.

edits
Array of objects

The details of the order edits done on the order.

Array of objects (Gift Card Transaction)

The gift card transactions made in the order.

sales_channel_id
string or null
Example: null

The ID of the sales channel this order belongs to.

object (Sales Channel)

A Sales Channel is a method a business offers its products for purchase for the customers. For example, a Webshop can be a sales channel, and a mobile app can be another.

shipping_total
integer
Example: 1000

The total of shipping

raw_discount_total
integer
Example: 800

The total of discount

discount_total
integer
Example: 800

The total of discount rounded

tax_total
integer
Example: 0

The total of tax

refunded_total
integer
Example: 0

The total amount refunded if the order is returned.

total
integer
Example: 8200

The total amount of the order

subtotal
integer
Example: 8000

The subtotal of the order

paid_total
integer
Example: 8000

The total amount paid

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

Array of objects (Line Item)

The details of the line items that are returnable as part of the order, swaps, or claims

Request samples

Content type
application/json
{
  • "type": "replace",
  • "claim_items": [
    ],
  • "return_shipping": {
    },
  • "additional_items": [
    ],
  • "shipping_methods": [
    ],
  • "shipping_address": {
    },
  • "refund_amount": 0,
  • "no_notification": true,
  • "metadata": { }
}

Response samples

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

Update a Claim

Update a Claim's details.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Order associated with the claim.

claim_id
required
string

The ID of the Claim.

query Parameters
expand
string

Comma-separated relations that should be expanded in the returned order.

fields
string

Comma-separated fields that should be included in the returned order.

Request Body schema: application/json
Array of objects

The Claim Items that the Claim will consist of.

Array of objects

The Shipping Methods to send the additional Line Items with.

no_notification
boolean

If set to true no notification will be send related to this Swap.

metadata
object

An optional set of key-value pairs to hold additional information.

Responses

Response Schema: application/json
required
object (Order)

An order is a purchase made by a customer. It holds details about payment and fulfillment of the order. An order may also be created from a draft order, which is created by an admin user.

billing_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The ID of the billing address associated with the order

canceled_at
required
string or null <date-time>

The date the order was canceled on.

cart_id
required
string or null
Example: "cart_01G8ZH853Y6TFXWPG5EYE81X63"

The ID of the cart associated with the order

created_at
required
string <date-time>

The date with timezone at which the resource was created.

currency_code
required
string
Example: "usd"

The 3 character currency code that is used in the order

customer_id
required
string
Example: "cus_01G2SG30J8C85S4A5CHM2S1NS2"

The ID of the customer associated with the order

draft_order_id
required
string or null
Example: null

The ID of the draft order this order was created from.

display_id
required
integer
Example: 2

The order's display ID

email
required
string <email>

The email associated with the order

external_id
required
string or null
Example: null

The ID of an external order.

fulfillment_status
required
string
Default: "not_fulfilled"
Enum: "not_fulfilled" "partially_fulfilled" "fulfilled" "partially_shipped" "shipped" "partially_returned" "returned" "canceled" "requires_action"

The order's fulfillment status

id
required
string
Example: "order_01G8TJSYT9M6AVS5N4EMNFS1EK"

The order's ID

idempotency_key
required
string or null

Randomly generated key used to continue the processing of the order in case of failure.

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

An optional key-value map with additional details

no_notification
required
boolean or null
Example: false

Flag for describing whether or not notifications related to this should be send.

payment_status
required
string
Default: "not_paid"
Enum: "not_paid" "awaiting" "captured" "partially_refunded" "refunded" "canceled" "requires_action"

The order's payment status

region_id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The ID of the region this order was created in.

shipping_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The ID of the shipping address associated with the order

status
required
string
Default: "pending"
Enum: "pending" "completed" "archived" "canceled" "requires_action"

The order's status

tax_rate
required
number or null
Example: 0

The order's tax rate

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

cart
object or null

The details of the cart associated with the order.

customer
object or null

The details of the customer associated with the order.

object (Address)

An address is used across the Medusa backend within other schemas and object types. For example, a customer's billing and shipping addresses both use the Address entity.

object (Address)

An address is used across the Medusa backend within other schemas and object types. For example, a customer's billing and shipping addresses both use the Address entity.

object (Region)

A region holds settings specific to a geographical location, including the currency, tax rates, and fulfillment and payment providers. A Region can consist of multiple countries to accomodate common shopping settings across countries.

object (Currency)

Currency

Array of objects (Discount)

The details of the discounts applied on the order.

Array of objects (Gift Card)

The details of the gift card used in the order.

Array of objects (Shipping Method)

The details of the shipping methods used in the order.

payments
Array of objects

The details of the payments used in the order.

fulfillments
Array of objects

The details of the fulfillments created for the order.

returns
Array of objects

The details of the returns created for the order.

claims
Array of objects

The details of the claims created for the order.

refunds
Array of objects

The details of the refunds created for the order.

swaps
Array of objects

The details of the swaps created for the order.

draft_order
object or null

The details of the draft order this order was created from.

Array of objects (Line Item)

The details of the line items that belong to the order.

edits
Array of objects

The details of the order edits done on the order.

Array of objects (Gift Card Transaction)

The gift card transactions made in the order.

sales_channel_id
string or null
Example: null

The ID of the sales channel this order belongs to.

object (Sales Channel)

A Sales Channel is a method a business offers its products for purchase for the customers. For example, a Webshop can be a sales channel, and a mobile app can be another.

shipping_total
integer
Example: 1000

The total of shipping

raw_discount_total
integer
Example: 800

The total of discount

discount_total
integer
Example: 800

The total of discount rounded

tax_total
integer
Example: 0

The total of tax

refunded_total
integer
Example: 0

The total amount refunded if the order is returned.

total
integer
Example: 8200

The total amount of the order

subtotal
integer
Example: 8000

The subtotal of the order

paid_total
integer
Example: 8000

The total amount paid

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

Array of objects (Line Item)

The details of the line items that are returnable as part of the order, swaps, or claims

Request samples

Content type
application/json
{
  • "claim_items": [
    ],
  • "shipping_methods": [
    ],
  • "no_notification": true,
  • "metadata": { }
}

Response samples

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

Cancel a Claim

Cancel a Claim and change its status. A claim can't be canceled if it has a refund, if its fulfillments haven't been canceled, of if its associated return hasn't been canceled.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the order the claim is associated with.

claim_id
required
string

The ID of the Claim.

query Parameters
expand
string

Comma-separated relations that should be expanded in the returned order.

fields
string

Comma-separated fields that should be included in the returned order.

Responses

Response Schema: application/json
required
object (Order)

An order is a purchase made by a customer. It holds details about payment and fulfillment of the order. An order may also be created from a draft order, which is created by an admin user.

billing_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The ID of the billing address associated with the order

canceled_at
required
string or null <date-time>

The date the order was canceled on.

cart_id
required
string or null
Example: "cart_01G8ZH853Y6TFXWPG5EYE81X63"

The ID of the cart associated with the order

created_at
required
string <date-time>

The date with timezone at which the resource was created.

currency_code
required
string
Example: "usd"

The 3 character currency code that is used in the order

customer_id
required
string
Example: "cus_01G2SG30J8C85S4A5CHM2S1NS2"

The ID of the customer associated with the order

draft_order_id
required
string or null
Example: null

The ID of the draft order this order was created from.

display_id
required
integer
Example: 2

The order's display ID

email
required
string <email>

The email associated with the order

external_id
required
string or null
Example: null

The ID of an external order.

fulfillment_status
required
string
Default: "not_fulfilled"
Enum: "not_fulfilled" "partially_fulfilled" "fulfilled" "partially_shipped" "shipped" "partially_returned" "returned" "canceled" "requires_action"

The order's fulfillment status

id
required
string
Example: "order_01G8TJSYT9M6AVS5N4EMNFS1EK"

The order's ID

idempotency_key
required
string or null

Randomly generated key used to continue the processing of the order in case of failure.

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

An optional key-value map with additional details

no_notification
required
boolean or null
Example: false

Flag for describing whether or not notifications related to this should be send.

payment_status
required
string
Default: "not_paid"
Enum: "not_paid" "awaiting" "captured" "partially_refunded" "refunded" "canceled" "requires_action"

The order's payment status

region_id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The ID of the region this order was created in.

shipping_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The ID of the shipping address associated with the order

status
required
string
Default: "pending"
Enum: "pending" "completed" "archived" "canceled" "requires_action"

The order's status

tax_rate
required
number or null
Example: 0

The order's tax rate

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

cart
object or null

The details of the cart associated with the order.

customer
object or null

The details of the customer associated with the order.

object (Address)

An address is used across the Medusa backend within other schemas and object types. For example, a customer's billing and shipping addresses both use the Address entity.

object (Address)

An address is used across the Medusa backend within other schemas and object types. For example, a customer's billing and shipping addresses both use the Address entity.

object (Region)

A region holds settings specific to a geographical location, including the currency, tax rates, and fulfillment and payment providers. A Region can consist of multiple countries to accomodate common shopping settings across countries.

object (Currency)

Currency

Array of objects (Discount)

The details of the discounts applied on the order.

Array of objects (Gift Card)

The details of the gift card used in the order.

Array of objects (Shipping Method)

The details of the shipping methods used in the order.

payments
Array of objects

The details of the payments used in the order.

fulfillments
Array of objects

The details of the fulfillments created for the order.

returns
Array of objects

The details of the returns created for the order.

claims
Array of objects

The details of the claims created for the order.

refunds
Array of objects

The details of the refunds created for the order.

swaps
Array of objects

The details of the swaps created for the order.

draft_order
object or null

The details of the draft order this order was created from.

Array of objects (Line Item)

The details of the line items that belong to the order.

edits
Array of objects

The details of the order edits done on the order.

Array of objects (Gift Card Transaction)

The gift card transactions made in the order.

sales_channel_id
string or null
Example: null

The ID of the sales channel this order belongs to.

object (Sales Channel)

A Sales Channel is a method a business offers its products for purchase for the customers. For example, a Webshop can be a sales channel, and a mobile app can be another.

shipping_total
integer
Example: 1000

The total of shipping

raw_discount_total
integer
Example: 800

The total of discount

discount_total
integer
Example: 800

The total of discount rounded

tax_total
integer
Example: 0

The total of tax

refunded_total
integer
Example: 0

The total amount refunded if the order is returned.

total
integer
Example: 8200

The total amount of the order

subtotal
integer
Example: 8000

The subtotal of the order

paid_total
integer
Example: 8000

The total amount paid

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

Array of objects (Line Item)

The details of the line items that are returnable as part of the order, swaps, or claims

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.cancelClaim(orderId, claimId)
.then(({ order }) => {
  console.log(order.id);
});

Response samples

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

Create a Claim Fulfillment

Create a Fulfillment for a Claim.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Order the claim is associated with.

claim_id
required
string

The ID of the Claim.

query Parameters
expand
string

Comma-separated relations that should be expanded in the returned order.

fields
string

Comma-separated fields that should be included in the returned order.

Request Body schema: application/json
metadata
object

An optional set of key-value pairs to hold additional information.

no_notification
boolean

If set to true, no notification will be sent to the customer related to this Claim.

Responses

Response Schema: application/json
required
object (Order)

An order is a purchase made by a customer. It holds details about payment and fulfillment of the order. An order may also be created from a draft order, which is created by an admin user.

billing_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The ID of the billing address associated with the order

canceled_at
required
string or null <date-time>

The date the order was canceled on.

cart_id
required
string or null
Example: "cart_01G8ZH853Y6TFXWPG5EYE81X63"

The ID of the cart associated with the order

created_at
required
string <date-time>

The date with timezone at which the resource was created.

currency_code
required
string
Example: "usd"

The 3 character currency code that is used in the order

customer_id
required
string
Example: "cus_01G2SG30J8C85S4A5CHM2S1NS2"

The ID of the customer associated with the order

draft_order_id
required
string or null
Example: null

The ID of the draft order this order was created from.

display_id
required
integer
Example: 2

The order's display ID

email
required
string <email>

The email associated with the order

external_id
required
string or null
Example: null

The ID of an external order.

fulfillment_status
required
string
Default: "not_fulfilled"
Enum: "not_fulfilled" "partially_fulfilled" "fulfilled" "partially_shipped" "shipped" "partially_returned" "returned" "canceled" "requires_action"

The order's fulfillment status

id
required
string
Example: "order_01G8TJSYT9M6AVS5N4EMNFS1EK"

The order's ID

idempotency_key
required
string or null

Randomly generated key used to continue the processing of the order in case of failure.

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

An optional key-value map with additional details

no_notification
required
boolean or null
Example: false

Flag for describing whether or not notifications related to this should be send.

payment_status
required
string
Default: "not_paid"
Enum: "not_paid" "awaiting" "captured" "partially_refunded" "refunded" "canceled" "requires_action"

The order's payment status

region_id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The ID of the region this order was created in.

shipping_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The ID of the shipping address associated with the order

status
required
string
Default: "pending"
Enum: "pending" "completed" "archived" "canceled" "requires_action"

The order's status

tax_rate
required
number or null
Example: 0

The order's tax rate

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

cart
object or null

The details of the cart associated with the order.

customer
object or null

The details of the customer associated with the order.

object (Address)

An address is used across the Medusa backend within other schemas and object types. For example, a customer's billing and shipping addresses both use the Address entity.

object (Address)

An address is used across the Medusa backend within other schemas and object types. For example, a customer's billing and shipping addresses both use the Address entity.

object (Region)

A region holds settings specific to a geographical location, including the currency, tax rates, and fulfillment and payment providers. A Region can consist of multiple countries to accomodate common shopping settings across countries.

object (Currency)

Currency

Array of objects (Discount)

The details of the discounts applied on the order.

Array of objects (Gift Card)

The details of the gift card used in the order.

Array of objects (Shipping Method)

The details of the shipping methods used in the order.

payments
Array of objects

The details of the payments used in the order.

fulfillments
Array of objects

The details of the fulfillments created for the order.

returns
Array of objects

The details of the returns created for the order.

claims
Array of objects

The details of the claims created for the order.

refunds
Array of objects

The details of the refunds created for the order.

swaps
Array of objects

The details of the swaps created for the order.

draft_order
object or null

The details of the draft order this order was created from.

Array of objects (Line Item)

The details of the line items that belong to the order.

edits
Array of objects

The details of the order edits done on the order.

Array of objects (Gift Card Transaction)

The gift card transactions made in the order.

sales_channel_id
string or null
Example: null

The ID of the sales channel this order belongs to.

object (Sales Channel)

A Sales Channel is a method a business offers its products for purchase for the customers. For example, a Webshop can be a sales channel, and a mobile app can be another.

shipping_total
integer
Example: 1000

The total of shipping

raw_discount_total
integer
Example: 800

The total of discount

discount_total
integer
Example: 800

The total of discount rounded

tax_total
integer
Example: 0

The total of tax

refunded_total
integer
Example: 0

The total amount refunded if the order is returned.

total
integer
Example: 8200

The total amount of the order

subtotal
integer
Example: 8000

The subtotal of the order

paid_total
integer
Example: 8000

The total amount paid

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

Array of objects (Line Item)

The details of the line items that are returnable as part of the order, swaps, or claims

Request samples

Content type
application/json
{
  • "metadata": { },
  • "no_notification": true
}

Response samples

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

Cancel Claim's Fulfillment

Cancel a claim's fulfillment and change its status.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the order the claim is associated with.

claim_id
required
string

The ID of the claim.

fulfillment_id
required
string

The ID of the fulfillment.

query Parameters
expand
string

Comma-separated relations that should be expanded in the returned order.

fields
string

Comma-separated fields that should be included in the returned order.

Responses

Response Schema: application/json
required
object (Order)

An order is a purchase made by a customer. It holds details about payment and fulfillment of the order. An order may also be created from a draft order, which is created by an admin user.

billing_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The ID of the billing address associated with the order

canceled_at
required
string or null <date-time>

The date the order was canceled on.

cart_id
required
string or null
Example: "cart_01G8ZH853Y6TFXWPG5EYE81X63"

The ID of the cart associated with the order

created_at
required
string <date-time>

The date with timezone at which the resource was created.

currency_code
required
string
Example: "usd"

The 3 character currency code that is used in the order

customer_id
required
string
Example: "cus_01G2SG30J8C85S4A5CHM2S1NS2"

The ID of the customer associated with the order

draft_order_id
required
string or null
Example: null

The ID of the draft order this order was created from.

display_id
required
integer
Example: 2

The order's display ID

email
required
string <email>

The email associated with the order

external_id
required
string or null
Example: null

The ID of an external order.

fulfillment_status
required
string
Default: "not_fulfilled"
Enum: "not_fulfilled" "partially_fulfilled" "fulfilled" "partially_shipped" "shipped" "partially_returned" "returned" "canceled" "requires_action"

The order's fulfillment status

id
required
string
Example: "order_01G8TJSYT9M6AVS5N4EMNFS1EK"

The order's ID

idempotency_key
required
string or null

Randomly generated key used to continue the processing of the order in case of failure.

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

An optional key-value map with additional details

no_notification
required
boolean or null
Example: false

Flag for describing whether or not notifications related to this should be send.

payment_status
required
string
Default: "not_paid"
Enum: "not_paid" "awaiting" "captured" "partially_refunded" "refunded" "canceled" "requires_action"

The order's payment status

region_id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The ID of the region this order was created in.

shipping_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The ID of the shipping address associated with the order

status
required
string
Default: "pending"
Enum: "pending" "completed" "archived" "canceled" "requires_action"

The order's status

tax_rate
required
number or null
Example: 0

The order's tax rate

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

cart
object or null

The details of the cart associated with the order.

customer
object or null

The details of the customer associated with the order.

object (Address)

An address is used across the Medusa backend within other schemas and object types. For example, a customer's billing and shipping addresses both use the Address entity.

object (Address)

An address is used across the Medusa backend within other schemas and object types. For example, a customer's billing and shipping addresses both use the Address entity.

object (Region)

A region holds settings specific to a geographical location, including the currency, tax rates, and fulfillment and payment providers. A Region can consist of multiple countries to accomodate common shopping settings across countries.

object (Currency)

Currency

Array of objects (Discount)

The details of the discounts applied on the order.

Array of objects (Gift Card)

The details of the gift card used in the order.

Array of objects (Shipping Method)

The details of the shipping methods used in the order.

payments
Array of objects

The details of the payments used in the order.

fulfillments
Array of objects

The details of the fulfillments created for the order.

returns
Array of objects

The details of the returns created for the order.

claims
Array of objects

The details of the claims created for the order.

refunds
Array of objects

The details of the refunds created for the order.

swaps
Array of objects

The details of the swaps created for the order.

draft_order
object or null

The details of the draft order this order was created from.

Array of objects (Line Item)

The details of the line items that belong to the order.

edits
Array of objects

The details of the order edits done on the order.

Array of objects (Gift Card Transaction)

The gift card transactions made in the order.

sales_channel_id
string or null
Example: null

The ID of the sales channel this order belongs to.

object (Sales Channel)

A Sales Channel is a method a business offers its products for purchase for the customers. For example, a Webshop can be a sales channel, and a mobile app can be another.

shipping_total
integer
Example: 1000

The total of shipping

raw_discount_total
integer
Example: 800

The total of discount

discount_total
integer
Example: 800

The total of discount rounded

tax_total
integer
Example: 0

The total of tax

refunded_total
integer
Example: 0

The total amount refunded if the order is returned.

total
integer
Example: 8200

The total amount of the order

subtotal
integer
Example: 8000

The subtotal of the order

paid_total
integer
Example: 8000

The total amount paid

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

Array of objects (Line Item)

The details of the line items that are returnable as part of the order, swaps, or claims

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.cancelClaimFulfillment(orderId, claimId, fulfillmentId)
.then(({ order }) => {
  console.log(order.id);
});

Response samples

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

Ship a Claim's Fulfillment

Mark a claim's fulfillment as shipped. This changes the claim's fulfillment status to either shipped or partially_shipped, depending on whether all the items were shipped.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Order the claim is associated with.

claim_id
required
string

The ID of the Claim.

query Parameters
expand
string

Comma-separated relations that should be expanded in the returned order.

fields
string

Comma-separated fields that should be included in the returned order.

Request Body schema: application/json
fulfillment_id
required
string

The ID of the Fulfillment.

tracking_numbers
Array of strings

An array of tracking numbers for the shipment.

Responses

Response Schema: application/json
required
object (Order)

An order is a purchase made by a customer. It holds details about payment and fulfillment of the order. An order may also be created from a draft order, which is created by an admin user.

billing_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The ID of the billing address associated with the order

canceled_at
required
string or null <date-time>

The date the order was canceled on.

cart_id
required
string or null
Example: "cart_01G8ZH853Y6TFXWPG5EYE81X63"

The ID of the cart associated with the order

created_at
required
string <date-time>

The date with timezone at which the resource was created.

currency_code
required
string
Example: "usd"

The 3 character currency code that is used in the order

customer_id
required
string
Example: "cus_01G2SG30J8C85S4A5CHM2S1NS2"

The ID of the customer associated with the order

draft_order_id
required
string or null
Example: null

The ID of the draft order this order was created from.

display_id
required
integer
Example: 2

The order's display ID

email
required
string <email>

The email associated with the order

external_id
required
string or null
Example: null

The ID of an external order.

fulfillment_status
required
string
Default: "not_fulfilled"
Enum: "not_fulfilled" "partially_fulfilled" "fulfilled" "partially_shipped" "shipped" "partially_returned" "returned" "canceled" "requires_action"

The order's fulfillment status

id
required
string
Example: "order_01G8TJSYT9M6AVS5N4EMNFS1EK"

The order's ID

idempotency_key
required
string or null

Randomly generated key used to continue the processing of the order in case of failure.

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

An optional key-value map with additional details

no_notification
required
boolean or null
Example: false

Flag for describing whether or not notifications related to this should be send.

payment_status
required
string
Default: "not_paid"
Enum: "not_paid" "awaiting" "captured" "partially_refunded" "refunded" "canceled" "requires_action"

The order's payment status

region_id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The ID of the region this order was created in.

shipping_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The ID of the shipping address associated with the order

status
required
string
Default: "pending"
Enum: "pending" "completed" "archived" "canceled" "requires_action"

The order's status

tax_rate
required
number or null
Example: 0

The order's tax rate

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

cart
object or null

The details of the cart associated with the order.

customer
object or null

The details of the customer associated with the order.

object (Address)

An address is used across the Medusa backend within other schemas and object types. For example, a customer's billing and shipping addresses both use the Address entity.

object (Address)

An address is used across the Medusa backend within other schemas and object types. For example, a customer's billing and shipping addresses both use the Address entity.

object (Region)

A region holds settings specific to a geographical location, including the currency, tax rates, and fulfillment and payment providers. A Region can consist of multiple countries to accomodate common shopping settings across countries.

object (Currency)

Currency

Array of objects (Discount)

The details of the discounts applied on the order.

Array of objects (Gift Card)

The details of the gift card used in the order.

Array of objects (Shipping Method)

The details of the shipping methods used in the order.

payments
Array of objects

The details of the payments used in the order.

fulfillments
Array of objects

The details of the fulfillments created for the order.

returns
Array of objects

The details of the returns created for the order.

claims
Array of objects

The details of the claims created for the order.

refunds
Array of objects

The details of the refunds created for the order.

swaps
Array of objects

The details of the swaps created for the order.

draft_order
object or null

The details of the draft order this order was created from.

Array of objects (Line Item)

The details of the line items that belong to the order.

edits
Array of objects

The details of the order edits done on the order.

Array of objects (Gift Card Transaction)

The gift card transactions made in the order.

sales_channel_id
string or null
Example: null

The ID of the sales channel this order belongs to.

object (Sales Channel)

A Sales Channel is a method a business offers its products for purchase for the customers. For example, a Webshop can be a sales channel, and a mobile app can be another.

shipping_total
integer
Example: 1000

The total of shipping

raw_discount_total
integer
Example: 800

The total of discount

discount_total
integer
Example: 800

The total of discount rounded

tax_total
integer
Example: 0

The total of tax

refunded_total
integer
Example: 0

The total amount refunded if the order is returned.

total
integer
Example: 8200

The total amount of the order

subtotal
integer
Example: 8000

The subtotal of the order

paid_total
integer
Example: 8000

The total amount paid

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

Array of objects (Line Item)

The details of the line items that are returnable as part of the order, swaps, or claims

Request samples

Content type
application/json
{
  • "fulfillment_id": "string",
  • "tracking_numbers": [
    ]
}

Response samples

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

Complete an Order

Complete an Order and change its status. A canceled order can't be completed.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Order.

query Parameters
expand
string

Comma-separated relations that should be expanded in the returned order.

fields
string

Comma-separated fields that should be included in the returned order.

Responses

Response Schema: application/json
required
object (Order)

An order is a purchase made by a customer. It holds details about payment and fulfillment of the order. An order may also be created from a draft order, which is created by an admin user.

billing_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The ID of the billing address associated with the order

canceled_at
required
string or null <date-time>

The date the order was canceled on.

cart_id
required
string or null
Example: "cart_01G8ZH853Y6TFXWPG5EYE81X63"

The ID of the cart associated with the order

created_at
required
string <date-time>

The date with timezone at which the resource was created.

currency_code
required
string
Example: "usd"

The 3 character currency code that is used in the order

customer_id
required
string
Example: "cus_01G2SG30J8C85S4A5CHM2S1NS2"

The ID of the customer associated with the order

draft_order_id
required
string or null
Example: null

The ID of the draft order this order was created from.

display_id
required
integer
Example: 2

The order's display ID

email
required
string <email>

The email associated with the order

external_id
required
string or null
Example: null

The ID of an external order.

fulfillment_status
required
string
Default: "not_fulfilled"
Enum: "not_fulfilled" "partially_fulfilled" "fulfilled" "partially_shipped" "shipped" "partially_returned" "returned" "canceled" "requires_action"

The order's fulfillment status

id
required
string
Example: "order_01G8TJSYT9M6AVS5N4EMNFS1EK"

The order's ID

idempotency_key
required
string or null

Randomly generated key used to continue the processing of the order in case of failure.

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

An optional key-value map with additional details

no_notification
required
boolean or null
Example: false

Flag for describing whether or not notifications related to this should be send.

payment_status
required
string
Default: "not_paid"
Enum: "not_paid" "awaiting" "captured" "partially_refunded" "refunded" "canceled" "requires_action"

The order's payment status

region_id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The ID of the region this order was created in.

shipping_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The ID of the shipping address associated with the order

status
required
string
Default: "pending"
Enum: "pending" "completed" "archived" "canceled" "requires_action"

The order's status

tax_rate
required
number or null
Example: 0

The order's tax rate

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

cart
object or null

The details of the cart associated with the order.

customer
object or null

The details of the customer associated with the order.

object (Address)

An address is used across the Medusa backend within other schemas and object types. For example, a customer's billing and shipping addresses both use the Address entity.

object (Address)

An address is used across the Medusa backend within other schemas and object types. For example, a customer's billing and shipping addresses both use the Address entity.

object (Region)

A region holds settings specific to a geographical location, including the currency, tax rates, and fulfillment and payment providers. A Region can consist of multiple countries to accomodate common shopping settings across countries.

object (Currency)

Currency

Array of objects (Discount)

The details of the discounts applied on the order.

Array of objects (Gift Card)

The details of the gift card used in the order.

Array of objects (Shipping Method)

The details of the shipping methods used in the order.

payments
Array of objects

The details of the payments used in the order.

fulfillments
Array of objects

The details of the fulfillments created for the order.

returns
Array of objects

The details of the returns created for the order.

claims
Array of objects

The details of the claims created for the order.

refunds
Array of objects

The details of the refunds created for the order.

swaps
Array of objects

The details of the swaps created for the order.

draft_order
object or null

The details of the draft order this order was created from.

Array of objects (Line Item)

The details of the line items that belong to the order.

edits
Array of objects

The details of the order edits done on the order.

Array of objects (Gift Card Transaction)

The gift card transactions made in the order.

sales_channel_id
string or null
Example: null

The ID of the sales channel this order belongs to.

object (Sales Channel)

A Sales Channel is a method a business offers its products for purchase for the customers. For example, a Webshop can be a sales channel, and a mobile app can be another.

shipping_total
integer
Example: 1000

The total of shipping

raw_discount_total
integer
Example: 800

The total of discount

discount_total
integer
Example: 800

The total of discount rounded

tax_total
integer
Example: 0

The total of tax

refunded_total
integer
Example: 0

The total amount refunded if the order is returned.

total
integer
Example: 8200

The total amount of the order

subtotal
integer
Example: 8000

The subtotal of the order

paid_total
integer
Example: 8000

The total amount paid

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

Array of objects (Line Item)

The details of the line items that are returnable as part of the order, swaps, or claims

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.complete(orderId)
.then(({ order }) => {
  console.log(order.id);
});

Response samples

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

Create a Fulfillment

Create a Fulfillment of an Order using the fulfillment provider.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Order.

query Parameters
expand
string

Comma-separated relations that should be expanded in the returned order.

fields
string

Comma-separated fields that should be included in the returned order.

Request Body schema: application/json
required
Array of objects

The Line Items to include in the Fulfillment.

no_notification
boolean

If set to true, no notification will be sent to the customer related to this fulfillment.

metadata
object

An optional set of key-value pairs to hold additional information.

Responses

Response Schema: application/json
required
object (Order)

An order is a purchase made by a customer. It holds details about payment and fulfillment of the order. An order may also be created from a draft order, which is created by an admin user.

billing_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The ID of the billing address associated with the order

canceled_at
required
string or null <date-time>

The date the order was canceled on.

cart_id
required
string or null
Example: "cart_01G8ZH853Y6TFXWPG5EYE81X63"

The ID of the cart associated with the order

created_at
required
string <date-time>

The date with timezone at which the resource was created.

currency_code
required
string
Example: "usd"

The 3 character currency code that is used in the order

customer_id
required
string
Example: "cus_01G2SG30J8C85S4A5CHM2S1NS2"

The ID of the customer associated with the order

draft_order_id
required
string or null
Example: null

The ID of the draft order this order was created from.

display_id
required
integer
Example: 2

The order's display ID

email
required
string <email>

The email associated with the order

external_id
required
string or null
Example: null

The ID of an external order.

fulfillment_status
required
string
Default: "not_fulfilled"
Enum: "not_fulfilled" "partially_fulfilled" "fulfilled" "partially_shipped" "shipped" "partially_returned" "returned" "canceled" "requires_action"

The order's fulfillment status

id
required
string
Example: "order_01G8TJSYT9M6AVS5N4EMNFS1EK"

The order's ID

idempotency_key
required
string or null

Randomly generated key used to continue the processing of the order in case of failure.

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

An optional key-value map with additional details

no_notification
required
boolean or null
Example: false

Flag for describing whether or not notifications related to this should be send.

payment_status
required
string
Default: "not_paid"
Enum: "not_paid" "awaiting" "captured" "partially_refunded" "refunded" "canceled" "requires_action"

The order's payment status

region_id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The ID of the region this order was created in.

shipping_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The ID of the shipping address associated with the order

status
required
string
Default: "pending"
Enum: "pending" "completed" "archived" "canceled" "requires_action"

The order's status

tax_rate
required
number or null
Example: 0

The order's tax rate

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

cart
object or null

The details of the cart associated with the order.

customer
object or null

The details of the customer associated with the order.

object (Address)

An address is used across the Medusa backend within other schemas and object types. For example, a customer's billing and shipping addresses both use the Address entity.

object (Address)

An address is used across the Medusa backend within other schemas and object types. For example, a customer's billing and shipping addresses both use the Address entity.

object (Region)

A region holds settings specific to a geographical location, including the currency, tax rates, and fulfillment and payment providers. A Region can consist of multiple countries to accomodate common shopping settings across countries.

object (Currency)

Currency

Array of objects (Discount)

The details of the discounts applied on the order.

Array of objects (Gift Card)

The details of the gift card used in the order.

Array of objects (Shipping Method)

The details of the shipping methods used in the order.

payments
Array of objects

The details of the payments used in the order.

fulfillments
Array of objects

The details of the fulfillments created for the order.

returns
Array of objects

The details of the returns created for the order.

claims
Array of objects

The details of the claims created for the order.

refunds
Array of objects

The details of the refunds created for the order.

swaps
Array of objects

The details of the swaps created for the order.

draft_order
object or null

The details of the draft order this order was created from.

Array of objects (Line Item)

The details of the line items that belong to the order.

edits
Array of objects

The details of the order edits done on the order.

Array of objects (Gift Card Transaction)

The gift card transactions made in the order.

sales_channel_id
string or null
Example: null

The ID of the sales channel this order belongs to.

object (Sales Channel)

A Sales Channel is a method a business offers its products for purchase for the customers. For example, a Webshop can be a sales channel, and a mobile app can be another.

shipping_total
integer
Example: 1000

The total of shipping

raw_discount_total
integer
Example: 800

The total of discount

discount_total
integer
Example: 800

The total of discount rounded

tax_total
integer
Example: 0

The total of tax

refunded_total
integer
Example: 0

The total amount refunded if the order is returned.

total
integer
Example: 8200

The total amount of the order

subtotal
integer
Example: 8000

The subtotal of the order

paid_total
integer
Example: 8000

The total amount paid

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

Array of objects (Line Item)

The details of the line items that are returnable as part of the order, swaps, or claims

Request samples

Content type
application/json
{
  • "items": [
    ],
  • "no_notification": true,
  • "metadata": { }
}

Response samples

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

Cancel a Fulfilmment

Cancel an order's fulfillment and change its status.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Order.

fulfillment_id
required
string

The ID of the Fulfillment.

query Parameters
expand
string

Comma-separated relations that should be expanded in the returned order.

fields
string

Comma-separated fields that should be included in the returned order.

Responses

Response Schema: application/json
required
object (Order)

An order is a purchase made by a customer. It holds details about payment and fulfillment of the order. An order may also be created from a draft order, which is created by an admin user.

billing_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The ID of the billing address associated with the order

canceled_at
required
string or null <date-time>

The date the order was canceled on.

cart_id
required
string or null
Example: "cart_01G8ZH853Y6TFXWPG5EYE81X63"

The ID of the cart associated with the order

created_at
required
string <date-time>

The date with timezone at which the resource was created.

currency_code
required
string
Example: "usd"

The 3 character currency code that is used in the order

customer_id
required
string
Example: "cus_01G2SG30J8C85S4A5CHM2S1NS2"

The ID of the customer associated with the order

draft_order_id
required
string or null
Example: null

The ID of the draft order this order was created from.

display_id
required
integer
Example: 2

The order's display ID

email
required
string <email>

The email associated with the order

external_id
required
string or null
Example: null

The ID of an external order.

fulfillment_status
required
string
Default: "not_fulfilled"
Enum: "not_fulfilled" "partially_fulfilled" "fulfilled" "partially_shipped" "shipped" "partially_returned" "returned" "canceled" "requires_action"

The order's fulfillment status

id
required
string
Example: "order_01G8TJSYT9M6AVS5N4EMNFS1EK"

The order's ID

idempotency_key
required
string or null

Randomly generated key used to continue the processing of the order in case of failure.

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

An optional key-value map with additional details

no_notification
required
boolean or null
Example: false

Flag for describing whether or not notifications related to this should be send.

payment_status
required
string
Default: "not_paid"
Enum: "not_paid" "awaiting" "captured" "partially_refunded" "refunded" "canceled" "requires_action"

The order's payment status

region_id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The ID of the region this order was created in.

shipping_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The ID of the shipping address associated with the order

status
required
string
Default: "pending"
Enum: "pending" "completed" "archived" "canceled" "requires_action"

The order's status

tax_rate
required
number or null
Example: 0

The order's tax rate

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

cart
object or null

The details of the cart associated with the order.

customer
object or null

The details of the customer associated with the order.

object (Address)

An address is used across the Medusa backend within other schemas and object types. For example, a customer's billing and shipping addresses both use the Address entity.

object (Address)

An address is used across the Medusa backend within other schemas and object types. For example, a customer's billing and shipping addresses both use the Address entity.

object (Region)

A region holds settings specific to a geographical location, including the currency, tax rates, and fulfillment and payment providers. A Region can consist of multiple countries to accomodate common shopping settings across countries.

object (Currency)

Currency

Array of objects (Discount)

The details of the discounts applied on the order.

Array of objects (Gift Card)

The details of the gift card used in the order.

Array of objects (Shipping Method)

The details of the shipping methods used in the order.

payments
Array of objects

The details of the payments used in the order.

fulfillments
Array of objects

The details of the fulfillments created for the order.

returns
Array of objects

The details of the returns created for the order.

claims
Array of objects

The details of the claims created for the order.

refunds
Array of objects

The details of the refunds created for the order.

swaps
Array of objects

The details of the swaps created for the order.

draft_order
object or null

The details of the draft order this order was created from.

Array of objects (Line Item)

The details of the line items that belong to the order.

edits
Array of objects

The details of the order edits done on the order.

Array of objects (Gift Card Transaction)

The gift card transactions made in the order.

sales_channel_id
string or null
Example: null

The ID of the sales channel this order belongs to.

object (Sales Channel)

A Sales Channel is a method a business offers its products for purchase for the customers. For example, a Webshop can be a sales channel, and a mobile app can be another.

shipping_total
integer
Example: 1000

The total of shipping

raw_discount_total
integer
Example: 800

The total of discount

discount_total
integer
Example: 800

The total of discount rounded

tax_total
integer
Example: 0

The total of tax

refunded_total
integer
Example: 0

The total amount refunded if the order is returned.

total
integer
Example: 8200

The total amount of the order

subtotal
integer
Example: 8000

The subtotal of the order

paid_total
integer
Example: 8000

The total amount paid

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

Array of objects (Line Item)

The details of the line items that are returnable as part of the order, swaps, or claims

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.cancelFulfillment(orderId, fulfillmentId)
.then(({ order }) => {
  console.log(order.id);
});

Response samples

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

Create a Reservation

Create a Reservation for a line item at a specified location, optionally for a partial quantity.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Order.

line_item_id
required
string

The ID of the Line item.

Request Body schema: application/json
location_id
required
string

The ID of the location of the reservation

quantity
number

The quantity to reserve

Responses

Response Schema: application/json
location_id
required
string

The ID of the location of the reservation.

inventory_item_id
required
string

The ID of the inventory item the reservation is associated with.

quantity
required
number

The quantity to reserve.

line_item_id
string

The ID of the line item of the reservation.

metadata
object

An optional set of key-value pairs with additional information.

Request samples

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

Response samples

Content type
application/json
{
  • "line_item_id": "string",
  • "location_id": "string",
  • "inventory_item_id": "string",
  • "quantity": 0,
  • "metadata": { }
}

Create a Refund

Refund an amount for an order. The amount must be less than or equal the refundable_amount of the order.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Order.

query Parameters
expand
string

Comma-separated relations that should be expanded in the returned order.

fields
string

Comma-separated fields that should be included in the returned order.

Request Body schema: application/json
amount
required
integer

The amount to refund. It should be less than or equal the refundable_amount of the order.

reason
required
string

The reason for the Refund.

note
string

A note with additional details about the Refund.

no_notification
boolean

If set to true, no notification will be sent to the customer related to this Refund.

Responses

Response Schema: application/json
required
object (Order)

An order is a purchase made by a customer. It holds details about payment and fulfillment of the order. An order may also be created from a draft order, which is created by an admin user.

billing_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The ID of the billing address associated with the order

canceled_at
required
string or null <date-time>

The date the order was canceled on.

cart_id
required
string or null
Example: "cart_01G8ZH853Y6TFXWPG5EYE81X63"

The ID of the cart associated with the order

created_at
required
string <date-time>

The date with timezone at which the resource was created.

currency_code
required
string
Example: "usd"

The 3 character currency code that is used in the order

customer_id
required
string
Example: "cus_01G2SG30J8C85S4A5CHM2S1NS2"

The ID of the customer associated with the order

draft_order_id
required
string or null
Example: null

The ID of the draft order this order was created from.

display_id
required
integer
Example: 2

The order's display ID

email
required
string <email>

The email associated with the order

external_id
required
string or null
Example: null

The ID of an external order.

fulfillment_status
required
string
Default: "not_fulfilled"
Enum: "not_fulfilled" "partially_fulfilled" "fulfilled" "partially_shipped" "shipped" "partially_returned" "returned" "canceled" "requires_action"

The order's fulfillment status

id
required
string
Example: "order_01G8TJSYT9M6AVS5N4EMNFS1EK"

The order's ID

idempotency_key
required
string or null

Randomly generated key used to continue the processing of the order in case of failure.

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

An optional key-value map with additional details

no_notification
required
boolean or null
Example: false

Flag for describing whether or not notifications related to this should be send.

payment_status
required
string
Default: "not_paid"
Enum: "not_paid" "awaiting" "captured" "partially_refunded" "refunded" "canceled" "requires_action"

The order's payment status

region_id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The ID of the region this order was created in.

shipping_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The ID of the shipping address associated with the order

status
required
string
Default: "pending"
Enum: "pending" "completed" "archived" "canceled" "requires_action"

The order's status

tax_rate
required
number or null
Example: 0

The order's tax rate

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

cart
object or null

The details of the cart associated with the order.

customer
object or null

The details of the customer associated with the order.

object (Address)

An address is used across the Medusa backend within other schemas and object types. For example, a customer's billing and shipping addresses both use the Address entity.

object (Address)

An address is used across the Medusa backend within other schemas and object types. For example, a customer's billing and shipping addresses both use the Address entity.

object (Region)

A region holds settings specific to a geographical location, including the currency, tax rates, and fulfillment and payment providers. A Region can consist of multiple countries to accomodate common shopping settings across countries.

object (Currency)

Currency

Array of objects (Discount)

The details of the discounts applied on the order.

Array of objects (Gift Card)

The details of the gift card used in the order.

Array of objects (Shipping Method)

The details of the shipping methods used in the order.

payments
Array of objects

The details of the payments used in the order.

fulfillments
Array of objects

The details of the fulfillments created for the order.

returns
Array of objects

The details of the returns created for the order.

claims
Array of objects

The details of the claims created for the order.

refunds
Array of objects

The details of the refunds created for the order.

swaps
Array of objects

The details of the swaps created for the order.

draft_order
object or null

The details of the draft order this order was created from.

Array of objects (Line Item)

The details of the line items that belong to the order.

edits
Array of objects

The details of the order edits done on the order.

Array of objects (Gift Card Transaction)

The gift card transactions made in the order.

sales_channel_id
string or null
Example: null

The ID of the sales channel this order belongs to.

object (Sales Channel)

A Sales Channel is a method a business offers its products for purchase for the customers. For example, a Webshop can be a sales channel, and a mobile app can be another.

shipping_total
integer
Example: 1000

The total of shipping

raw_discount_total
integer
Example: 800

The total of discount

discount_total
integer
Example: 800

The total of discount rounded

tax_total
integer
Example: 0

The total of tax

refunded_total
integer
Example: 0

The total amount refunded if the order is returned.

total
integer
Example: 8200

The total amount of the order

subtotal
integer
Example: 8000

The subtotal of the order

paid_total
integer
Example: 8000

The total amount paid

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

Array of objects (Line Item)

The details of the line items that are returnable as part of the order, swaps, or claims

Request samples

Content type
application/json
{
  • "amount": 0,
  • "reason": "string",
  • "note": "string",
  • "no_notification": true
}

Response samples

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

Get Order Reservations

Retrieve the list of reservations of an Order

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Order.

query Parameters
offset
integer
Default: 0

The number of reservations to skip when retrieving the reservations.

limit
integer
Default: 20

Limit the number of reservations returned.

Responses

Response Schema: application/json
required
Array of objects (ExtendedReservationItem)

An array of reservations details.

count
required
integer

The total number of items available

offset
required
integer

The number of reservations skipped when retrieving the reservations.

limit
required
integer

The number of items per page

Request samples

curl 'https://medusa-url.com/admin/orders/{id}/reservations' \
-H 'Authorization: Bearer {api_token}'

Response samples

Content type
application/json
{
  • "reservations": [
    ],
  • "count": 0,
  • "offset": 0,
  • "limit": 0
}

Request a Return

Request and create a Return for items in an order. If the return shipping method is specified, it will be automatically fulfilled.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Order.

query Parameters
expand
string

Comma-separated relations that should be expanded in the returned order.

fields
string

Comma-separated fields that should be included in the returned order.

Request Body schema: application/json
required
Array of objects

The line items that will be returned.

object

The Shipping Method to be used to handle the return shipment.

note
string

An optional note with information about the Return.

receive_now
boolean
Default: false

A flag to indicate if the Return should be registerd as received immediately.

no_notification
boolean

If set to true, no notification will be sent to the customer related to this Return.

refund
integer

The amount to refund.

Responses

Response Schema: application/json
required
object (Order)

An order is a purchase made by a customer. It holds details about payment and fulfillment of the order. An order may also be created from a draft order, which is created by an admin user.

billing_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The ID of the billing address associated with the order

canceled_at
required
string or null <date-time>

The date the order was canceled on.

cart_id
required
string or null
Example: "cart_01G8ZH853Y6TFXWPG5EYE81X63"

The ID of the cart associated with the order

created_at
required
string <date-time>

The date with timezone at which the resource was created.

currency_code
required
string
Example: "usd"

The 3 character currency code that is used in the order

customer_id
required
string
Example: "cus_01G2SG30J8C85S4A5CHM2S1NS2"

The ID of the customer associated with the order

draft_order_id
required
string or null
Example: null

The ID of the draft order this order was created from.

display_id
required
integer
Example: 2

The order's display ID

email
required
string <email>

The email associated with the order

external_id
required
string or null
Example: null

The ID of an external order.

fulfillment_status
required
string
Default: "not_fulfilled"
Enum: "not_fulfilled" "partially_fulfilled" "fulfilled" "partially_shipped" "shipped" "partially_returned" "returned" "canceled" "requires_action"

The order's fulfillment status

id
required
string
Example: "order_01G8TJSYT9M6AVS5N4EMNFS1EK"

The order's ID

idempotency_key
required
string or null

Randomly generated key used to continue the processing of the order in case of failure.

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

An optional key-value map with additional details

no_notification
required
boolean or null
Example: false

Flag for describing whether or not notifications related to this should be send.

payment_status
required
string
Default: "not_paid"
Enum: "not_paid" "awaiting" "captured" "partially_refunded" "refunded" "canceled" "requires_action"

The order's payment status

region_id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The ID of the region this order was created in.

shipping_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The ID of the shipping address associated with the order

status
required
string
Default: "pending"
Enum: "pending" "completed" "archived" "canceled" "requires_action"

The order's status

tax_rate
required
number or null
Example: 0

The order's tax rate

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

cart
object or null

The details of the cart associated with the order.

customer
object or null

The details of the customer associated with the order.

object (Address)

An address is used across the Medusa backend within other schemas and object types. For example, a customer's billing and shipping addresses both use the Address entity.

object (Address)

An address is used across the Medusa backend within other schemas and object types. For example, a customer's billing and shipping addresses both use the Address entity.

object (Region)

A region holds settings specific to a geographical location, including the currency, tax rates, and fulfillment and payment providers. A Region can consist of multiple countries to accomodate common shopping settings across countries.

object (Currency)

Currency

Array of objects (Discount)

The details of the discounts applied on the order.

Array of objects (Gift Card)

The details of the gift card used in the order.

Array of objects (Shipping Method)

The details of the shipping methods used in the order.

payments
Array of objects

The details of the payments used in the order.

fulfillments
Array of objects

The details of the fulfillments created for the order.

returns
Array of objects

The details of the returns created for the order.

claims
Array of objects

The details of the claims created for the order.

refunds
Array of objects

The details of the refunds created for the order.

swaps
Array of objects

The details of the swaps created for the order.

draft_order
object or null

The details of the draft order this order was created from.

Array of objects (Line Item)

The details of the line items that belong to the order.

edits
Array of objects

The details of the order edits done on the order.

Array of objects (Gift Card Transaction)

The gift card transactions made in the order.

sales_channel_id
string or null
Example: null

The ID of the sales channel this order belongs to.

object (Sales Channel)

A Sales Channel is a method a business offers its products for purchase for the customers. For example, a Webshop can be a sales channel, and a mobile app can be another.

shipping_total
integer
Example: 1000

The total of shipping

raw_discount_total
integer
Example: 800

The total of discount

discount_total
integer
Example: 800

The total of discount rounded

tax_total
integer
Example: 0

The total of tax

refunded_total
integer
Example: 0

The total amount refunded if the order is returned.

total
integer
Example: 8200

The total amount of the order

subtotal
integer
Example: 8000

The subtotal of the order

paid_total
integer
Example: 8000

The total amount paid

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

Array of objects (Line Item)

The details of the line items that are returnable as part of the order, swaps, or claims

Request samples

Content type
application/json
{
  • "items": [
    ],
  • "return_shipping": {
    },
  • "note": "string",
  • "receive_now": false,
  • "no_notification": true,
  • "refund": 0
}

Response samples

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

Ship a Fulfillment

Mark a fulfillment as shipped. This changes the order's fulfillment status to either shipped or partially_shipped, depending on whether all the items were shipped.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Order.

query Parameters
expand
string

Comma-separated relations that should be expanded in the returned order.

fields
string

Comma-separated fields that should be included in the returned order.

Request Body schema: application/json
fulfillment_id
required
string

The ID of the Fulfillment.

tracking_numbers
Array of strings

The tracking numbers for the shipment.

no_notification
boolean

If set to true no notification will be send related to this Shipment.

Responses

Response Schema: application/json
required
object (Order)

An order is a purchase made by a customer. It holds details about payment and fulfillment of the order. An order may also be created from a draft order, which is created by an admin user.

billing_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The ID of the billing address associated with the order

canceled_at
required
string or null <date-time>

The date the order was canceled on.

cart_id
required
string or null
Example: "cart_01G8ZH853Y6TFXWPG5EYE81X63"

The ID of the cart associated with the order

created_at
required
string <date-time>

The date with timezone at which the resource was created.

currency_code
required
string
Example: "usd"

The 3 character currency code that is used in the order

customer_id
required
string
Example: "cus_01G2SG30J8C85S4A5CHM2S1NS2"

The ID of the customer associated with the order

draft_order_id
required
string or null
Example: null

The ID of the draft order this order was created from.

display_id
required
integer
Example: 2

The order's display ID

email
required
string <email>

The email associated with the order

external_id
required
string or null
Example: null

The ID of an external order.

fulfillment_status
required
string
Default: "not_fulfilled"
Enum: "not_fulfilled" "partially_fulfilled" "fulfilled" "partially_shipped" "shipped" "partially_returned" "returned" "canceled" "requires_action"

The order's fulfillment status

id
required
string
Example: "order_01G8TJSYT9M6AVS5N4EMNFS1EK"

The order's ID

idempotency_key
required
string or null

Randomly generated key used to continue the processing of the order in case of failure.

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

An optional key-value map with additional details

no_notification
required
boolean or null
Example: false

Flag for describing whether or not notifications related to this should be send.

payment_status
required
string
Default: "not_paid"
Enum: "not_paid" "awaiting" "captured" "partially_refunded" "refunded" "canceled" "requires_action"

The order's payment status

region_id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The ID of the region this order was created in.

shipping_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The ID of the shipping address associated with the order

status
required
string
Default: "pending"
Enum: "pending" "completed" "archived" "canceled" "requires_action"

The order's status

tax_rate
required
number or null
Example: 0

The order's tax rate

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

cart
object or null

The details of the cart associated with the order.

customer
object or null

The details of the customer associated with the order.

object (Address)

An address is used across the Medusa backend within other schemas and object types. For example, a customer's billing and shipping addresses both use the Address entity.

object (Address)

An address is used across the Medusa backend within other schemas and object types. For example, a customer's billing and shipping addresses both use the Address entity.

object (Region)

A region holds settings specific to a geographical location, including the currency, tax rates, and fulfillment and payment providers. A Region can consist of multiple countries to accomodate common shopping settings across countries.

object (Currency)

Currency

Array of objects (Discount)

The details of the discounts applied on the order.

Array of objects (Gift Card)

The details of the gift card used in the order.

Array of objects (Shipping Method)

The details of the shipping methods used in the order.

payments
Array of objects

The details of the payments used in the order.

fulfillments
Array of objects

The details of the fulfillments created for the order.

returns
Array of objects

The details of the returns created for the order.

claims
Array of objects

The details of the claims created for the order.

refunds
Array of objects

The details of the refunds created for the order.

swaps
Array of objects

The details of the swaps created for the order.

draft_order
object or null

The details of the draft order this order was created from.

Array of objects (Line Item)

The details of the line items that belong to the order.

edits
Array of objects

The details of the order edits done on the order.

Array of objects (Gift Card Transaction)

The gift card transactions made in the order.

sales_channel_id
string or null
Example: null

The ID of the sales channel this order belongs to.

object (Sales Channel)

A Sales Channel is a method a business offers its products for purchase for the customers. For example, a Webshop can be a sales channel, and a mobile app can be another.

shipping_total
integer
Example: 1000

The total of shipping

raw_discount_total
integer
Example: 800

The total of discount

discount_total
integer
Example: 800

The total of discount rounded

tax_total
integer
Example: 0

The total of tax

refunded_total
integer
Example: 0

The total amount refunded if the order is returned.

total
integer
Example: 8200

The total amount of the order

subtotal
integer
Example: 8000

The subtotal of the order

paid_total
integer
Example: 8000

The total amount paid

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

Array of objects (Line Item)

The details of the line items that are returnable as part of the order, swaps, or claims

Request samples

Content type
application/json
{
  • "fulfillment_id": "string",
  • "tracking_numbers": [
    ],
  • "no_notification": true
}

Response samples

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

Add a Shipping Method

Adds a Shipping Method to an Order. If another Shipping Method exists with the same Shipping Profile, the previous Shipping Method will be replaced.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Order.

query Parameters
expand
string

Comma-separated relations that should be expanded in the returned order.

fields
string

Comma-separated fields that should be included in the returned order.

Request Body schema: application/json
price
required
number

The price (excluding VAT) that should be charged for the Shipping Method

option_id
required
string

The ID of the Shipping Option to create the Shipping Method from.

date
object

The data required for the Shipping Option to create a Shipping Method. This depends on the Fulfillment Provider.

Responses

Response Schema: application/json
required
object (Order)

An order is a purchase made by a customer. It holds details about payment and fulfillment of the order. An order may also be created from a draft order, which is created by an admin user.

billing_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The ID of the billing address associated with the order

canceled_at
required
string or null <date-time>

The date the order was canceled on.

cart_id
required
string or null
Example: "cart_01G8ZH853Y6TFXWPG5EYE81X63"

The ID of the cart associated with the order

created_at
required
string <date-time>

The date with timezone at which the resource was created.

currency_code
required
string
Example: "usd"

The 3 character currency code that is used in the order

customer_id
required
string
Example: "cus_01G2SG30J8C85S4A5CHM2S1NS2"

The ID of the customer associated with the order

draft_order_id
required
string or null
Example: null

The ID of the draft order this order was created from.

display_id
required
integer
Example: 2

The order's display ID

email
required
string <email>

The email associated with the order

external_id
required
string or null
Example: null

The ID of an external order.

fulfillment_status
required
string
Default: "not_fulfilled"
Enum: "not_fulfilled" "partially_fulfilled" "fulfilled" "partially_shipped" "shipped" "partially_returned" "returned" "canceled" "requires_action"

The order's fulfillment status

id
required
string
Example: "order_01G8TJSYT9M6AVS5N4EMNFS1EK"

The order's ID

idempotency_key
required
string or null

Randomly generated key used to continue the processing of the order in case of failure.

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

An optional key-value map with additional details

no_notification
required
boolean or null
Example: false

Flag for describing whether or not notifications related to this should be send.

payment_status
required
string
Default: "not_paid"
Enum: "not_paid" "awaiting" "captured" "partially_refunded" "refunded" "canceled" "requires_action"

The order's payment status

region_id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The ID of the region this order was created in.

shipping_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The ID of the shipping address associated with the order

status
required
string
Default: "pending"
Enum: "pending" "completed" "archived" "canceled" "requires_action"

The order's status

tax_rate
required
number or null
Example: 0

The order's tax rate

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

cart
object or null

The details of the cart associated with the order.

customer
object or null

The details of the customer associated with the order.

object (Address)

An address is used across the Medusa backend within other schemas and object types. For example, a customer's billing and shipping addresses both use the Address entity.

object (Address)

An address is used across the Medusa backend within other schemas and object types. For example, a customer's billing and shipping addresses both use the Address entity.

object (Region)

A region holds settings specific to a geographical location, including the currency, tax rates, and fulfillment and payment providers. A Region can consist of multiple countries to accomodate common shopping settings across countries.

object (Currency)

Currency

Array of objects (Discount)

The details of the discounts applied on the order.

Array of objects (Gift Card)

The details of the gift card used in the order.

Array of objects (Shipping Method)

The details of the shipping methods used in the order.

payments
Array of objects

The details of the payments used in the order.

fulfillments
Array of objects

The details of the fulfillments created for the order.

returns
Array of objects

The details of the returns created for the order.

claims
Array of objects

The details of the claims created for the order.

refunds
Array of objects

The details of the refunds created for the order.

swaps
Array of objects

The details of the swaps created for the order.

draft_order
object or null

The details of the draft order this order was created from.

Array of objects (Line Item)

The details of the line items that belong to the order.

edits
Array of objects

The details of the order edits done on the order.

Array of objects (Gift Card Transaction)

The gift card transactions made in the order.

sales_channel_id
string or null
Example: null

The ID of the sales channel this order belongs to.

object (Sales Channel)

A Sales Channel is a method a business offers its products for purchase for the customers. For example, a Webshop can be a sales channel, and a mobile app can be another.

shipping_total
integer
Example: 1000

The total of shipping

raw_discount_total
integer
Example: 800

The total of discount

discount_total
integer
Example: 800

The total of discount rounded

tax_total
integer
Example: 0

The total of tax

refunded_total
integer
Example: 0

The total amount refunded if the order is returned.

total
integer
Example: 8200

The total amount of the order

subtotal
integer
Example: 8000

The subtotal of the order

paid_total
integer
Example: 8000

The total amount paid

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

Array of objects (Line Item)

The details of the line items that are returnable as part of the order, swaps, or claims

Request samples

Content type
application/json
{
  • "price": 0,
  • "option_id": "string",
  • "date": { }
}

Response samples

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

Create a Swap

Create a Swap. This includes creating a return that is associated with the swap.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Order.

query Parameters
expand
string

Comma-separated relations that should be expanded in the returned order.

fields
string

Comma-separated fields that should be included in the returned order.

Request Body schema: application/json
required
Array of objects

The Line Items to associate with the swap's return.

object

The shipping method associated with the swap's return.

Array of objects

The new items to send to the Customer.

Array of objects

An array of custom shipping options to potentially create a Shipping Method from to send the additional items.

no_notification
boolean

If set to true, no notification will be sent to the customer related to this Swap.

allow_backorder
boolean
Default: true

If set to true, swaps can be completed with items out of stock

Responses

Response Schema: application/json
required
object (Order)

An order is a purchase made by a customer. It holds details about payment and fulfillment of the order. An order may also be created from a draft order, which is created by an admin user.

billing_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The ID of the billing address associated with the order

canceled_at
required
string or null <date-time>

The date the order was canceled on.

cart_id
required
string or null
Example: "cart_01G8ZH853Y6TFXWPG5EYE81X63"

The ID of the cart associated with the order

created_at
required
string <date-time>

The date with timezone at which the resource was created.

currency_code
required
string
Example: "usd"

The 3 character currency code that is used in the order

customer_id
required
string
Example: "cus_01G2SG30J8C85S4A5CHM2S1NS2"

The ID of the customer associated with the order

draft_order_id
required
string or null
Example: null

The ID of the draft order this order was created from.

display_id
required
integer
Example: 2

The order's display ID

email
required
string <email>

The email associated with the order

external_id
required
string or null
Example: null

The ID of an external order.

fulfillment_status
required
string
Default: "not_fulfilled"
Enum: "not_fulfilled" "partially_fulfilled" "fulfilled" "partially_shipped" "shipped" "partially_returned" "returned" "canceled" "requires_action"

The order's fulfillment status

id
required
string
Example: "order_01G8TJSYT9M6AVS5N4EMNFS1EK"

The order's ID

idempotency_key
required
string or null

Randomly generated key used to continue the processing of the order in case of failure.

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

An optional key-value map with additional details

no_notification
required
boolean or null
Example: false

Flag for describing whether or not notifications related to this should be send.

payment_status
required
string
Default: "not_paid"
Enum: "not_paid" "awaiting" "captured" "partially_refunded" "refunded" "canceled" "requires_action"

The order's payment status

region_id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The ID of the region this order was created in.

shipping_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The ID of the shipping address associated with the order

status
required
string
Default: "pending"
Enum: "pending" "completed" "archived" "canceled" "requires_action"

The order's status

tax_rate
required
number or null
Example: 0

The order's tax rate

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

cart
object or null

The details of the cart associated with the order.

customer
object or null

The details of the customer associated with the order.

object (Address)

An address is used across the Medusa backend within other schemas and object types. For example, a customer's billing and shipping addresses both use the Address entity.

object (Address)

An address is used across the Medusa backend within other schemas and object types. For example, a customer's billing and shipping addresses both use the Address entity.

object (Region)

A region holds settings specific to a geographical location, including the currency, tax rates, and fulfillment and payment providers. A Region can consist of multiple countries to accomodate common shopping settings across countries.

object (Currency)

Currency

Array of objects (Discount)

The details of the discounts applied on the order.

Array of objects (Gift Card)

The details of the gift card used in the order.

Array of objects (Shipping Method)

The details of the shipping methods used in the order.

payments
Array of objects

The details of the payments used in the order.

fulfillments
Array of objects

The details of the fulfillments created for the order.

returns
Array of objects

The details of the returns created for the order.

claims
Array of objects

The details of the claims created for the order.

refunds
Array of objects

The details of the refunds created for the order.

swaps
Array of objects

The details of the swaps created for the order.

draft_order
object or null

The details of the draft order this order was created from.

Array of objects (Line Item)

The details of the line items that belong to the order.

edits
Array of objects

The details of the order edits done on the order.

Array of objects (Gift Card Transaction)

The gift card transactions made in the order.

sales_channel_id
string or null
Example: null

The ID of the sales channel this order belongs to.

object (Sales Channel)

A Sales Channel is a method a business offers its products for purchase for the customers. For example, a Webshop can be a sales channel, and a mobile app can be another.

shipping_total
integer
Example: 1000

The total of shipping

raw_discount_total
integer
Example: 800

The total of discount

discount_total
integer
Example: 800

The total of discount rounded

tax_total
integer
Example: 0

The total of tax

refunded_total
integer
Example: 0

The total amount refunded if the order is returned.

total
integer
Example: 8200

The total amount of the order

subtotal
integer
Example: 8000

The subtotal of the order

paid_total
integer
Example: 8000

The total amount paid

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

Array of objects (Line Item)

The details of the line items that are returnable as part of the order, swaps, or claims

Request samples

Content type
application/json
{
  • "return_items": [
    ],
  • "return_shipping": {
    },
  • "additional_items": [
    ],
  • "custom_shipping_options": [
    ],
  • "no_notification": true,
  • "allow_backorder": true
}

Response samples

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

Cancel a Swap

Cancel a Swap and change its status.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Order the swap is associated with.

swap_id
required
string

The ID of the Swap.

query Parameters
expand
string

Comma-separated relations that should be expanded in the returned order.

fields
string

Comma-separated fields that should be included in the returned order.

Responses

Response Schema: application/json
required
object (Order)

An order is a purchase made by a customer. It holds details about payment and fulfillment of the order. An order may also be created from a draft order, which is created by an admin user.

billing_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The ID of the billing address associated with the order

canceled_at
required
string or null <date-time>

The date the order was canceled on.

cart_id
required
string or null
Example: "cart_01G8ZH853Y6TFXWPG5EYE81X63"

The ID of the cart associated with the order

created_at
required
string <date-time>

The date with timezone at which the resource was created.

currency_code
required
string
Example: "usd"

The 3 character currency code that is used in the order

customer_id
required
string
Example: "cus_01G2SG30J8C85S4A5CHM2S1NS2"

The ID of the customer associated with the order

draft_order_id
required
string or null
Example: null

The ID of the draft order this order was created from.

display_id
required
integer
Example: 2

The order's display ID

email
required
string <email>

The email associated with the order

external_id
required
string or null
Example: null

The ID of an external order.

fulfillment_status
required
string
Default: "not_fulfilled"
Enum: "not_fulfilled" "partially_fulfilled" "fulfilled" "partially_shipped" "shipped" "partially_returned" "returned" "canceled" "requires_action"

The order's fulfillment status

id
required
string
Example: "order_01G8TJSYT9M6AVS5N4EMNFS1EK"

The order's ID

idempotency_key
required
string or null

Randomly generated key used to continue the processing of the order in case of failure.

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

An optional key-value map with additional details

no_notification
required
boolean or null
Example: false

Flag for describing whether or not notifications related to this should be send.

payment_status
required
string
Default: "not_paid"
Enum: "not_paid" "awaiting" "captured" "partially_refunded" "refunded" "canceled" "requires_action"

The order's payment status

region_id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The ID of the region this order was created in.

shipping_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The ID of the shipping address associated with the order

status
required
string
Default: "pending"
Enum: "pending" "completed" "archived" "canceled" "requires_action"

The order's status

tax_rate
required
number or null
Example: 0

The order's tax rate

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

cart
object or null

The details of the cart associated with the order.

customer
object or null

The details of the customer associated with the order.

object (Address)

An address is used across the Medusa backend within other schemas and object types. For example, a customer's billing and shipping addresses both use the Address entity.

object (Address)

An address is used across the Medusa backend within other schemas and object types. For example, a customer's billing and shipping addresses both use the Address entity.

object (Region)

A region holds settings specific to a geographical location, including the currency, tax rates, and fulfillment and payment providers. A Region can consist of multiple countries to accomodate common shopping settings across countries.

object (Currency)

Currency

Array of objects (Discount)

The details of the discounts applied on the order.

Array of objects (Gift Card)

The details of the gift card used in the order.

Array of objects (Shipping Method)

The details of the shipping methods used in the order.

payments
Array of objects

The details of the payments used in the order.

fulfillments
Array of objects

The details of the fulfillments created for the order.

returns
Array of objects

The details of the returns created for the order.

claims
Array of objects

The details of the claims created for the order.

refunds
Array of objects

The details of the refunds created for the order.

swaps
Array of objects

The details of the swaps created for the order.

draft_order
object or null

The details of the draft order this order was created from.

Array of objects (Line Item)

The details of the line items that belong to the order.

edits
Array of objects

The details of the order edits done on the order.

Array of objects (Gift Card Transaction)

The gift card transactions made in the order.

sales_channel_id
string or null
Example: null

The ID of the sales channel this order belongs to.

object (Sales Channel)

A Sales Channel is a method a business offers its products for purchase for the customers. For example, a Webshop can be a sales channel, and a mobile app can be another.

shipping_total
integer
Example: 1000

The total of shipping

raw_discount_total
integer
Example: 800

The total of discount

discount_total
integer
Example: 800

The total of discount rounded

tax_total
integer
Example: 0

The total of tax

refunded_total
integer
Example: 0

The total amount refunded if the order is returned.

total
integer
Example: 8200

The total amount of the order

subtotal
integer
Example: 8000

The subtotal of the order

paid_total
integer
Example: 8000

The total amount paid

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

Array of objects (Line Item)

The details of the line items that are returnable as part of the order, swaps, or claims

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.cancelSwap(orderId, swapId)
.then(({ order }) => {
  console.log(order.id);
});

Response samples

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

Create a Swap Fulfillment

Create a Fulfillment for a Swap.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Order the swap is associated with.

swap_id
required
string

The ID of the Swap.

query Parameters
expand
string

Comma-separated relations that should be expanded in the returned order.

fields
string

Comma-separated fields that should be included in the returned order.

Request Body schema: application/json
metadata
object

An optional set of key-value pairs to hold additional information.

no_notification
boolean

If set to true, no notification will be sent to the customer related to this swap.

Responses

Response Schema: application/json
required
object (Order)

An order is a purchase made by a customer. It holds details about payment and fulfillment of the order. An order may also be created from a draft order, which is created by an admin user.

billing_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The ID of the billing address associated with the order

canceled_at
required
string or null <date-time>

The date the order was canceled on.

cart_id
required
string or null
Example: "cart_01G8ZH853Y6TFXWPG5EYE81X63"

The ID of the cart associated with the order

created_at
required
string <date-time>

The date with timezone at which the resource was created.

currency_code
required
string
Example: "usd"

The 3 character currency code that is used in the order

customer_id
required
string
Example: "cus_01G2SG30J8C85S4A5CHM2S1NS2"

The ID of the customer associated with the order

draft_order_id
required
string or null
Example: null

The ID of the draft order this order was created from.

display_id
required
integer
Example: 2

The order's display ID

email
required
string <email>

The email associated with the order

external_id
required
string or null
Example: null

The ID of an external order.

fulfillment_status
required
string
Default: "not_fulfilled"
Enum: "not_fulfilled" "partially_fulfilled" "fulfilled" "partially_shipped" "shipped" "partially_returned" "returned" "canceled" "requires_action"

The order's fulfillment status

id
required
string
Example: "order_01G8TJSYT9M6AVS5N4EMNFS1EK"

The order's ID

idempotency_key
required
string or null

Randomly generated key used to continue the processing of the order in case of failure.

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

An optional key-value map with additional details

no_notification
required
boolean or null
Example: false

Flag for describing whether or not notifications related to this should be send.

payment_status
required
string
Default: "not_paid"
Enum: "not_paid" "awaiting" "captured" "partially_refunded" "refunded" "canceled" "requires_action"

The order's payment status

region_id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The ID of the region this order was created in.

shipping_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The ID of the shipping address associated with the order

status
required
string
Default: "pending"
Enum: "pending" "completed" "archived" "canceled" "requires_action"

The order's status

tax_rate
required
number or null
Example: 0

The order's tax rate

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

cart
object or null

The details of the cart associated with the order.

customer
object or null

The details of the customer associated with the order.

object (Address)

An address is used across the Medusa backend within other schemas and object types. For example, a customer's billing and shipping addresses both use the Address entity.

object (Address)

An address is used across the Medusa backend within other schemas and object types. For example, a customer's billing and shipping addresses both use the Address entity.

object (Region)

A region holds settings specific to a geographical location, including the currency, tax rates, and fulfillment and payment providers. A Region can consist of multiple countries to accomodate common shopping settings across countries.

object (Currency)

Currency

Array of objects (Discount)

The details of the discounts applied on the order.

Array of objects (Gift Card)

The details of the gift card used in the order.

Array of objects (Shipping Method)

The details of the shipping methods used in the order.

payments
Array of objects

The details of the payments used in the order.

fulfillments
Array of objects

The details of the fulfillments created for the order.

returns
Array of objects

The details of the returns created for the order.

claims
Array of objects

The details of the claims created for the order.

refunds
Array of objects

The details of the refunds created for the order.

swaps
Array of objects

The details of the swaps created for the order.

draft_order
object or null

The details of the draft order this order was created from.

Array of objects (Line Item)

The details of the line items that belong to the order.

edits
Array of objects

The details of the order edits done on the order.

Array of objects (Gift Card Transaction)

The gift card transactions made in the order.

sales_channel_id
string or null
Example: null

The ID of the sales channel this order belongs to.

object (Sales Channel)

A Sales Channel is a method a business offers its products for purchase for the customers. For example, a Webshop can be a sales channel, and a mobile app can be another.

shipping_total
integer
Example: 1000

The total of shipping

raw_discount_total
integer
Example: 800

The total of discount

discount_total
integer
Example: 800

The total of discount rounded

tax_total
integer
Example: 0

The total of tax

refunded_total
integer
Example: 0

The total amount refunded if the order is returned.

total
integer
Example: 8200

The total amount of the order

subtotal
integer
Example: 8000

The subtotal of the order

paid_total
integer
Example: 8000

The total amount paid

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

Array of objects (Line Item)

The details of the line items that are returnable as part of the order, swaps, or claims

Request samples

Content type
application/json
{
  • "metadata": { },
  • "no_notification": true
}

Response samples

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

Cancel Swap's Fulfilmment

Cancel a swap's fulfillment and change its status.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the order the swap is associated with.

swap_id
required
string

The ID of the swap.

fulfillment_id
required
string

The ID of the fulfillment.

query Parameters
expand
string

Comma-separated relations that should be expanded in the returned order.

fields
string

Comma-separated fields that should be included in the returned order.

Responses

Response Schema: application/json
required
object (Order)

An order is a purchase made by a customer. It holds details about payment and fulfillment of the order. An order may also be created from a draft order, which is created by an admin user.

billing_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The ID of the billing address associated with the order

canceled_at
required
string or null <date-time>

The date the order was canceled on.

cart_id
required
string or null
Example: "cart_01G8ZH853Y6TFXWPG5EYE81X63"

The ID of the cart associated with the order

created_at
required
string <date-time>

The date with timezone at which the resource was created.

currency_code
required
string
Example: "usd"

The 3 character currency code that is used in the order

customer_id
required
string
Example: "cus_01G2SG30J8C85S4A5CHM2S1NS2"

The ID of the customer associated with the order

draft_order_id
required
string or null
Example: null

The ID of the draft order this order was created from.

display_id
required
integer
Example: 2

The order's display ID

email
required
string <email>

The email associated with the order

external_id
required
string or null
Example: null

The ID of an external order.

fulfillment_status
required
string
Default: "not_fulfilled"
Enum: "not_fulfilled" "partially_fulfilled" "fulfilled" "partially_shipped" "shipped" "partially_returned" "returned" "canceled" "requires_action"

The order's fulfillment status

id
required
string
Example: "order_01G8TJSYT9M6AVS5N4EMNFS1EK"

The order's ID

idempotency_key
required
string or null

Randomly generated key used to continue the processing of the order in case of failure.

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

An optional key-value map with additional details

no_notification
required
boolean or null
Example: false

Flag for describing whether or not notifications related to this should be send.

payment_status
required
string
Default: "not_paid"
Enum: "not_paid" "awaiting" "captured" "partially_refunded" "refunded" "canceled" "requires_action"

The order's payment status

region_id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The ID of the region this order was created in.

shipping_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The ID of the shipping address associated with the order

status
required
string
Default: "pending"
Enum: "pending" "completed" "archived" "canceled" "requires_action"

The order's status

tax_rate
required
number or null
Example: 0

The order's tax rate

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

cart
object or null

The details of the cart associated with the order.

customer
object or null

The details of the customer associated with the order.

object (Address)

An address is used across the Medusa backend within other schemas and object types. For example, a customer's billing and shipping addresses both use the Address entity.

object (Address)

An address is used across the Medusa backend within other schemas and object types. For example, a customer's billing and shipping addresses both use the Address entity.

object (Region)

A region holds settings specific to a geographical location, including the currency, tax rates, and fulfillment and payment providers. A Region can consist of multiple countries to accomodate common shopping settings across countries.

object (Currency)

Currency

Array of objects (Discount)

The details of the discounts applied on the order.

Array of objects (Gift Card)

The details of the gift card used in the order.

Array of objects (Shipping Method)

The details of the shipping methods used in the order.

payments
Array of objects

The details of the payments used in the order.

fulfillments
Array of objects

The details of the fulfillments created for the order.

returns
Array of objects

The details of the returns created for the order.

claims
Array of objects

The details of the claims created for the order.

refunds
Array of objects

The details of the refunds created for the order.

swaps
Array of objects

The details of the swaps created for the order.

draft_order
object or null

The details of the draft order this order was created from.

Array of objects (Line Item)

The details of the line items that belong to the order.

edits
Array of objects

The details of the order edits done on the order.

Array of objects (Gift Card Transaction)

The gift card transactions made in the order.

sales_channel_id
string or null
Example: null

The ID of the sales channel this order belongs to.

object (Sales Channel)

A Sales Channel is a method a business offers its products for purchase for the customers. For example, a Webshop can be a sales channel, and a mobile app can be another.

shipping_total
integer
Example: 1000

The total of shipping

raw_discount_total
integer
Example: 800

The total of discount

discount_total
integer
Example: 800

The total of discount rounded

tax_total
integer
Example: 0

The total of tax

refunded_total
integer
Example: 0

The total amount refunded if the order is returned.

total
integer
Example: 8200

The total amount of the order

subtotal
integer
Example: 8000

The subtotal of the order

paid_total
integer
Example: 8000

The total amount paid

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

Array of objects (Line Item)

The details of the line items that are returnable as part of the order, swaps, or claims

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.cancelSwapFulfillment(orderId, swapId, fulfillmentId)
.then(({ order }) => {
  console.log(order.id);
});

Response samples

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

Process a Swap Payment

Process a swap's payment either by refunding or issuing a payment. This depends on the difference_due of the swap. If difference_due is negative, the amount is refunded. If difference_due is positive, the amount is captured.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the order the swap is associated with.

swap_id
required
string

The ID of the swap.

query Parameters
expand
string

Comma-separated relations that should be expanded in the returned order.

fields
string

Comma-separated fields that should be included in the returned order.

Responses

Response Schema: application/json
required
object (Order)

An order is a purchase made by a customer. It holds details about payment and fulfillment of the order. An order may also be created from a draft order, which is created by an admin user.

billing_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The ID of the billing address associated with the order

canceled_at
required
string or null <date-time>

The date the order was canceled on.

cart_id
required
string or null
Example: "cart_01G8ZH853Y6TFXWPG5EYE81X63"

The ID of the cart associated with the order

created_at
required
string <date-time>

The date with timezone at which the resource was created.

currency_code
required
string
Example: "usd"

The 3 character currency code that is used in the order

customer_id
required
string
Example: "cus_01G2SG30J8C85S4A5CHM2S1NS2"

The ID of the customer associated with the order

draft_order_id
required
string or null
Example: null

The ID of the draft order this order was created from.

display_id
required
integer
Example: 2

The order's display ID

email
required
string <email>

The email associated with the order

external_id
required
string or null
Example: null

The ID of an external order.

fulfillment_status
required
string
Default: "not_fulfilled"
Enum: "not_fulfilled" "partially_fulfilled" "fulfilled" "partially_shipped" "shipped" "partially_returned" "returned" "canceled" "requires_action"

The order's fulfillment status

id
required
string
Example: "order_01G8TJSYT9M6AVS5N4EMNFS1EK"

The order's ID

idempotency_key
required
string or null

Randomly generated key used to continue the processing of the order in case of failure.

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

An optional key-value map with additional details

no_notification
required
boolean or null
Example: false

Flag for describing whether or not notifications related to this should be send.

payment_status
required
string
Default: "not_paid"
Enum: "not_paid" "awaiting" "captured" "partially_refunded" "refunded" "canceled" "requires_action"

The order's payment status

region_id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The ID of the region this order was created in.

shipping_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The ID of the shipping address associated with the order

status
required
string
Default: "pending"
Enum: "pending" "completed" "archived" "canceled" "requires_action"

The order's status

tax_rate
required
number or null
Example: 0

The order's tax rate

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

cart
object or null

The details of the cart associated with the order.

customer
object or null

The details of the customer associated with the order.

object (Address)

An address is used across the Medusa backend within other schemas and object types. For example, a customer's billing and shipping addresses both use the Address entity.

object (Address)

An address is used across the Medusa backend within other schemas and object types. For example, a customer's billing and shipping addresses both use the Address entity.

object (Region)

A region holds settings specific to a geographical location, including the currency, tax rates, and fulfillment and payment providers. A Region can consist of multiple countries to accomodate common shopping settings across countries.

object (Currency)

Currency

Array of objects (Discount)

The details of the discounts applied on the order.

Array of objects (Gift Card)

The details of the gift card used in the order.

Array of objects (Shipping Method)

The details of the shipping methods used in the order.

payments
Array of objects

The details of the payments used in the order.

fulfillments
Array of objects

The details of the fulfillments created for the order.

returns
Array of objects

The details of the returns created for the order.

claims
Array of objects

The details of the claims created for the order.

refunds
Array of objects

The details of the refunds created for the order.

swaps
Array of objects

The details of the swaps created for the order.

draft_order
object or null

The details of the draft order this order was created from.

Array of objects (Line Item)

The details of the line items that belong to the order.

edits
Array of objects

The details of the order edits done on the order.

Array of objects (Gift Card Transaction)

The gift card transactions made in the order.

sales_channel_id
string or null
Example: null

The ID of the sales channel this order belongs to.

object (Sales Channel)

A Sales Channel is a method a business offers its products for purchase for the customers. For example, a Webshop can be a sales channel, and a mobile app can be another.

shipping_total
integer
Example: 1000

The total of shipping

raw_discount_total
integer
Example: 800

The total of discount

discount_total
integer
Example: 800

The total of discount rounded

tax_total
integer
Example: 0

The total of tax

refunded_total
integer
Example: 0

The total amount refunded if the order is returned.

total
integer
Example: 8200

The total amount of the order

subtotal
integer
Example: 8000

The subtotal of the order

paid_total
integer
Example: 8000

The total amount paid

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

Array of objects (Line Item)

The details of the line items that are returnable as part of the order, swaps, or claims

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.orders.processSwapPayment(orderId, swapId)
.then(({ order }) => {
  console.log(order.id);
});

Response samples

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

Ship a Swap's Fulfillment

RMark a swap's fulfillment as shipped. This changes the swap's fulfillment status to either shipped or partially_shipped, depending on whether all the items were shipped.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Order.

swap_id
required
string

The ID of the Swap.

query Parameters
expand
string

Comma-separated relations that should be expanded in the returned order.

fields
string

Comma-separated fields that should be included in the returned order.

Request Body schema: application/json
fulfillment_id
required
string

The ID of the Fulfillment.

tracking_numbers
Array of strings

The tracking numbers for the shipment.

no_notification
boolean

If set to true no notification will be sent related to this Claim.

Responses

Response Schema: application/json
required
object (Order)

An order is a purchase made by a customer. It holds details about payment and fulfillment of the order. An order may also be created from a draft order, which is created by an admin user.

billing_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The ID of the billing address associated with the order

canceled_at
required
string or null <date-time>

The date the order was canceled on.

cart_id
required
string or null
Example: "cart_01G8ZH853Y6TFXWPG5EYE81X63"

The ID of the cart associated with the order

created_at
required
string <date-time>

The date with timezone at which the resource was created.

currency_code
required
string
Example: "usd"

The 3 character currency code that is used in the order

customer_id
required
string
Example: "cus_01G2SG30J8C85S4A5CHM2S1NS2"

The ID of the customer associated with the order

draft_order_id
required
string or null
Example: null

The ID of the draft order this order was created from.

display_id
required
integer
Example: 2

The order's display ID

email
required
string <email>

The email associated with the order

external_id
required
string or null
Example: null

The ID of an external order.

fulfillment_status
required
string
Default: "not_fulfilled"
Enum: "not_fulfilled" "partially_fulfilled" "fulfilled" "partially_shipped" "shipped" "partially_returned" "returned" "canceled" "requires_action"

The order's fulfillment status

id
required
string
Example: "order_01G8TJSYT9M6AVS5N4EMNFS1EK"

The order's ID

idempotency_key
required
string or null

Randomly generated key used to continue the processing of the order in case of failure.

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

An optional key-value map with additional details

no_notification
required
boolean or null
Example: false

Flag for describing whether or not notifications related to this should be send.

payment_status
required
string
Default: "not_paid"
Enum: "not_paid" "awaiting" "captured" "partially_refunded" "refunded" "canceled" "requires_action"

The order's payment status

region_id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The ID of the region this order was created in.

shipping_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The ID of the shipping address associated with the order

status
required
string
Default: "pending"
Enum: "pending" "completed" "archived" "canceled" "requires_action"

The order's status

tax_rate
required
number or null
Example: 0

The order's tax rate

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

cart
object or null

The details of the cart associated with the order.

customer
object or null

The details of the customer associated with the order.

object (Address)

An address is used across the Medusa backend within other schemas and object types. For example, a customer's billing and shipping addresses both use the Address entity.

object (Address)

An address is used across the Medusa backend within other schemas and object types. For example, a customer's billing and shipping addresses both use the Address entity.

object (Region)

A region holds settings specific to a geographical location, including the currency, tax rates, and fulfillment and payment providers. A Region can consist of multiple countries to accomodate common shopping settings across countries.

object (Currency)

Currency

Array of objects (Discount)

The details of the discounts applied on the order.

Array of objects (Gift Card)

The details of the gift card used in the order.

Array of objects (Shipping Method)

The details of the shipping methods used in the order.

payments
Array of objects

The details of the payments used in the order.

fulfillments
Array of objects

The details of the fulfillments created for the order.

returns
Array of objects

The details of the returns created for the order.

claims
Array of objects

The details of the claims created for the order.

refunds
Array of objects

The details of the refunds created for the order.

swaps
Array of objects

The details of the swaps created for the order.

draft_order
object or null

The details of the draft order this order was created from.

Array of objects (Line Item)

The details of the line items that belong to the order.

edits
Array of objects

The details of the order edits done on the order.

Array of objects (Gift Card Transaction)

The gift card transactions made in the order.

sales_channel_id
string or null
Example: null

The ID of the sales channel this order belongs to.

object (Sales Channel)

A Sales Channel is a method a business offers its products for purchase for the customers. For example, a Webshop can be a sales channel, and a mobile app can be another.

shipping_total
integer
Example: 1000

The total of shipping

raw_discount_total
integer
Example: 800

The total of discount

discount_total
integer
Example: 800

The total of discount rounded

tax_total
integer
Example: 0

The total of tax

refunded_total
integer
Example: 0

The total amount refunded if the order is returned.

total
integer
Example: 8200

The total amount of the order

subtotal
integer
Example: 8000

The subtotal of the order

paid_total
integer
Example: 8000

The total amount paid

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

Array of objects (Line Item)

The details of the line items that are returnable as part of the order, swaps, or claims

Request samples

Content type
application/json
{
  • "fulfillment_id": "string",
  • "tracking_numbers": [
    ],
  • "no_notification": true
}

Response samples

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

Payment Collections

A payment collection is useful for managing additional payments, such as for Order Edits, or installment payments.

Get a Payment Collection

Retrieve a Payment Collection's details.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Payment Collection.

query Parameters
expand
string

Comma-separated relations that should be expanded in the returned payment collection.

fields
string

Comma-separated fields that should be included in the returned payment collection.

Responses

Response Schema: application/json
required
object (Payment Collection)

A payment collection allows grouping and managing a list of payments at one. This can be helpful when making additional payment for order edits or integrating installment payments.

amount
required
integer

Amount of the payment collection.

authorized_amount
required
integer or null

Authorized amount of the payment collection.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

created_by
required
string

The ID of the user that created the payment collection.

currency_code
required
string
Example: "usd"

The 3 character ISO code for the currency this payment collection is associated with.

deleted_at
required
string or null <date-time>

The date with timezone at which the resource was deleted.

description
required
string or null

Description of the payment collection

id
required
string
Example: "paycol_01G8TJSYT9M6AVS5N4EMNFS1EK"

The payment collection's ID

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

An optional key-value map with additional details

region_id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The ID of the region this payment collection is associated with.

status
required
string
Enum: "not_paid" "awaiting" "authorized" "partially_authorized" "canceled"

The type of the payment collection

type
required
string
Value: "order_edit"

The type of the payment collection

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

object (Region)

A region holds settings specific to a geographical location, including the currency, tax rates, and fulfillment and payment providers. A Region can consist of multiple countries to accomodate common shopping settings across countries.

object (Currency)

Currency

Array of objects (Payment Session)

The details of the payment sessions created as part of the payment collection.

Array of objects (Payment)

The details of the payments created as part of the payment collection.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.paymentCollections.retrieve(paymentCollectionId)
  .then(({ payment_collection }) => {
    console.log(payment_collection.id)
  })

Response samples

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

Update Payment Collection

Update a Payment Collection's details.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Payment Collection.

Request Body schema: application/json
description
string

A description to create or update the payment collection.

metadata
object

A set of key-value pairs to hold additional information.

Responses

Response Schema: application/json
required
object (Payment Collection)

A payment collection allows grouping and managing a list of payments at one. This can be helpful when making additional payment for order edits or integrating installment payments.

amount
required
integer

Amount of the payment collection.

authorized_amount
required
integer or null

Authorized amount of the payment collection.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

created_by
required
string

The ID of the user that created the payment collection.

currency_code
required
string
Example: "usd"

The 3 character ISO code for the currency this payment collection is associated with.

deleted_at
required
string or null <date-time>

The date with timezone at which the resource was deleted.

description
required
string or null

Description of the payment collection

id
required
string
Example: "paycol_01G8TJSYT9M6AVS5N4EMNFS1EK"

The payment collection's ID

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

An optional key-value map with additional details

region_id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The ID of the region this payment collection is associated with.

status
required
string
Enum: "not_paid" "awaiting" "authorized" "partially_authorized" "canceled"

The type of the payment collection

type
required
string
Value: "order_edit"

The type of the payment collection

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

object (Region)

A region holds settings specific to a geographical location, including the currency, tax rates, and fulfillment and payment providers. A Region can consist of multiple countries to accomodate common shopping settings across countries.

object (Currency)

Currency

Array of objects (Payment Session)

The details of the payment sessions created as part of the payment collection.

Array of objects (Payment)

The details of the payments created as part of the payment collection.

Request samples

Content type
application/json
{
  • "description": "string",
  • "metadata": { }
}

Response samples

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

Delete a Payment Collection

Delete a Payment Collection. Only payment collections with the statuses canceled or not_paid can be deleted.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Payment Collection.

Responses

Response Schema: application/json
id
required
string

The ID of the deleted Payment Collection.

object
required
string
Default: "payment_collection"

The type of the object that was deleted.

deleted
required
boolean
Default: true

Whether or not the Payment Collection was deleted.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.paymentCollections.delete(paymentCollectionId)
  .then(({ id, object, deleted }) => {
    console.log(id)
  })

Response samples

Content type
application/json
{
  • "id": "string",
  • "object": "payment_collection",
  • "deleted": true
}

Mark Authorized

Set the status of a Payment Collection as authorized. This will also change the authorized_amount of the payment collection.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Payment Collection.

Responses

Response Schema: application/json
required
object (Payment Collection)

A payment collection allows grouping and managing a list of payments at one. This can be helpful when making additional payment for order edits or integrating installment payments.

amount
required
integer

Amount of the payment collection.

authorized_amount
required
integer or null

Authorized amount of the payment collection.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

created_by
required
string

The ID of the user that created the payment collection.

currency_code
required
string
Example: "usd"

The 3 character ISO code for the currency this payment collection is associated with.

deleted_at
required
string or null <date-time>

The date with timezone at which the resource was deleted.

description
required
string or null

Description of the payment collection

id
required
string
Example: "paycol_01G8TJSYT9M6AVS5N4EMNFS1EK"

The payment collection's ID

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

An optional key-value map with additional details

region_id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The ID of the region this payment collection is associated with.

status
required
string
Enum: "not_paid" "awaiting" "authorized" "partially_authorized" "canceled"

The type of the payment collection

type
required
string
Value: "order_edit"

The type of the payment collection

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

object (Region)

A region holds settings specific to a geographical location, including the currency, tax rates, and fulfillment and payment providers. A Region can consist of multiple countries to accomodate common shopping settings across countries.

object (Currency)

Currency

Array of objects (Payment Session)

The details of the payment sessions created as part of the payment collection.

Array of objects (Payment)

The details of the payments created as part of the payment collection.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.paymentCollections.markAsAuthorized(paymentCollectionId)
  .then(({ payment_collection }) => {
    console.log(payment_collection.id)
  })

Response samples

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

Payments

Get Payment details

Retrieve a Payment's details.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Payment.

Responses

Response Schema: application/json
required
object (Payment)

A payment is originally created from a payment session. Once a payment session is authorized, the payment is created to represent the authorized amount with a given payment method. Payments can be captured, canceled or refunded. Payments can be made towards orders, swaps, order edits, or other resources.

amount
required
integer
Example: 100

The amount that the Payment has been authorized for.

amount_refunded
required
integer
Default: 0
Example: 0

The amount of the original Payment amount that has been refunded back to the Customer.

canceled_at
required
string or null <date-time>

The date with timezone at which the Payment was canceled.

captured_at
required
string or null <date-time>

The date with timezone at which the Payment was captured.

cart_id
required
string or null

The ID of the cart that the payment session was potentially created for.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

currency_code
required
string
Example: "usd"

The 3 character ISO currency code of the payment.

data
required
object
Example: {}

The data required for the Payment Provider to identify, modify and process the Payment. Typically this will be an object that holds an id to the external payment session, but can be an empty object if the Payment Provider doesn't hold any state.

id
required
string
Example: "pay_01G2SJNT6DEEWDFNAJ4XWDTHKE"

The payment's ID

idempotency_key
required
string or null

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

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

An optional key-value map with additional details

order_id
required
string or null
Example: "order_01G8TJSYT9M6AVS5N4EMNFS1EK"

The ID of the order that the payment session was potentially created for.

provider_id
required
string
Example: "manual"

The id of the Payment Provider that is responsible for the Payment

swap_id
required
string or null
Example: null

The ID of the swap that this payment was potentially created for.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

swap
object or null

The details of the swap that this payment was potentially created for.

cart
object or null

The details of the cart that the payment session was potentially created for.

order
object or null

The details of the order that the payment session was potentially created for.

object (Currency)

Currency

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.payments.retrieve(paymentId)
.then(({ payment }) => {
  console.log(payment.id);
});

Response samples

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

Capture a Payment

Capture a Payment.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Payment.

Responses

Response Schema: application/json
required
object (Payment)

A payment is originally created from a payment session. Once a payment session is authorized, the payment is created to represent the authorized amount with a given payment method. Payments can be captured, canceled or refunded. Payments can be made towards orders, swaps, order edits, or other resources.

amount
required
integer
Example: 100

The amount that the Payment has been authorized for.

amount_refunded
required
integer
Default: 0
Example: 0

The amount of the original Payment amount that has been refunded back to the Customer.

canceled_at
required
string or null <date-time>

The date with timezone at which the Payment was canceled.

captured_at
required
string or null <date-time>

The date with timezone at which the Payment was captured.

cart_id
required
string or null

The ID of the cart that the payment session was potentially created for.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

currency_code
required
string
Example: "usd"

The 3 character ISO currency code of the payment.

data
required
object
Example: {}

The data required for the Payment Provider to identify, modify and process the Payment. Typically this will be an object that holds an id to the external payment session, but can be an empty object if the Payment Provider doesn't hold any state.

id
required
string
Example: "pay_01G2SJNT6DEEWDFNAJ4XWDTHKE"

The payment's ID

idempotency_key
required
string or null

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

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

An optional key-value map with additional details

order_id
required
string or null
Example: "order_01G8TJSYT9M6AVS5N4EMNFS1EK"

The ID of the order that the payment session was potentially created for.

provider_id
required
string
Example: "manual"

The id of the Payment Provider that is responsible for the Payment

swap_id
required
string or null
Example: null

The ID of the swap that this payment was potentially created for.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

swap
object or null

The details of the swap that this payment was potentially created for.

cart
object or null

The details of the cart that the payment session was potentially created for.

order
object or null

The details of the order that the payment session was potentially created for.

object (Currency)

Currency

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.payments.capturePayment(paymentId)
.then(({ payment }) => {
  console.log(payment.id);
});

Response samples

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

Refund Payment

Refund a payment. The payment must be captured first.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Payment.

Request Body schema: application/json
amount
required
integer

The amount to refund.

reason
required
string

The reason for the Refund.

note
string

A note with additional details about the Refund.

Responses

Response Schema: application/json
required
object (Refund)

A refund represents an amount of money transfered back to the customer for a given reason. Refunds may occur in relation to Returns, Swaps and Claims, but can also be initiated by an admin for an order.

amount
required
integer
Example: 1000

The amount that has be refunded to the Customer.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

id
required
string
Example: "ref_01G1G5V27GYX4QXNARRQCW1N8T"

The refund's ID

idempotency_key
required
string or null

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

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

An optional key-value map with additional details

note
required
string or null
Example: "I didn't like it"

An optional note explaining why the amount was refunded.

order_id
required
string or null
Example: "order_01G8TJSYT9M6AVS5N4EMNFS1EK"

The ID of the order this refund was created for.

payment_id
required
string or null
Example: "pay_01G8ZCC5W42ZNY842124G7P5R9"

The payment's ID, if available.

reason
required
string
Enum: "discount" "return" "swap" "claim" "other"
Example: "return"

The reason given for the Refund, will automatically be set when processed as part of a Swap, Claim or Return.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

order
object or null

The details of the order this refund was created for.

payment
object or null

The details of the payment associated with the refund.

Request samples

Content type
application/json
{
  • "amount": 0,
  • "reason": "string",
  • "note": "string"
}

Response samples

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

Price Lists

A price list are special prices applied to products based on a set of conditions, such as customer group.

List Price Lists

Retrieve a list of price lists. The price lists can be filtered by fields such as q or status. The price lists can also be sorted or paginated.

Authorizations:
API TokenCookie Session ID
query Parameters
limit
number
Default: "10"

Limit the number of price lists returned.

offset
number
Default: "0"

The number of price lists to skip when retrieving the price lists.

expand
string

Comma-separated relations that should be expanded in the returned price lists.

fields
string

Comma-separated fields that should be included in the returned price lists.

order
string

A price-list field to sort-order the retrieved price lists by.

id
string

Filter by ID

q
string

term to search price lists' description, name, and customer group's name.

status
Array of strings
Items Enum: "active" "draft"

Filter by status.

name
string

Filter by name

customer_groups
Array of strings

Filter by customer-group IDs.

type
Array of strings
Items Enum: "sale" "override"

Filter by type.

object

Filter by a creation date range.

object

Filter by an update date range.

object

Filter by a deletion date range.

Responses

Response Schema: application/json
required
Array of objects (Price List)

An array of price lists details.

count
required
integer

The total number of items available

offset
required
integer

The number of price lists skipped when retrieving the price lists.

limit
required
integer

The number of items per page

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.priceLists.list()
.then(({ price_lists, limit, offset, count }) => {
  console.log(price_lists.length);
});

Response samples

Content type
application/json
{
  • "price_lists": [
    ],
  • "count": 0,
  • "offset": 0,
  • "limit": 0
}

Create a Price List

Create a Price List.

Authorizations:
API TokenCookie Session ID
Request Body schema: application/json
name
required
string

The name of the Price List.

description
required
string

The description of the Price List.

type
required
string
Enum: "sale" "override"

The type of the Price List.

required
Array of objects

The prices of the Price List.

starts_at
string <date>

The date with timezone that the Price List starts being valid.

ends_at
string <date>

The date with timezone that the Price List ends being valid.

status
string
Enum: "active" "draft"

The status of the Price List. If the status is set to draft, the prices created in the price list will not be available of the customer.

Array of objects

An array of customer groups that the Price List applies to.

includes_tax
boolean

Tax included in prices of price list

Responses

Response Schema: application/json
required
object (Price List)

A Price List represents a set of prices that override the default price for one or more product variants.

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.

description
required
string
Example: "Prices for VIP customers"

The price list's description

ends_at
required
string or null <date-time>

The date with timezone that the Price List stops being valid.

id
required
string
Example: "pl_01G8X3CKJXCG5VXVZ87H9KC09W"

The price list's ID

name
required
string
Example: "VIP Prices"

The price list's name

starts_at
required
string or null <date-time>

The date with timezone that the Price List starts being valid.

status
required
string
Default: "draft"
Enum: "active" "draft"

The status of the Price List

type
required
string
Default: "sale"
Enum: "sale" "override"

The type of Price List. This can be one of either sale or override.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

Array of objects (Customer Group)

The details of the customer groups that the Price List can apply to.

Array of objects (Money Amount)

The prices that belong to the price list, represented as a Money Amount.

includes_tax
boolean
Default: false

Whether the price list prices include tax

Request samples

Content type
application/json
{
  • "name": "string",
  • "description": "string",
  • "starts_at": "2019-08-24",
  • "ends_at": "2019-08-24",
  • "type": "sale",
  • "status": "active",
  • "prices": [
    ],
  • "customer_groups": [
    ],
  • "includes_tax": true
}

Response samples

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

Get a Price List

Retrieve a Price List's details.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Price List.

Responses

Response Schema: application/json
required
object (Price List)

A Price List represents a set of prices that override the default price for one or more product variants.

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.

description
required
string
Example: "Prices for VIP customers"

The price list's description

ends_at
required
string or null <date-time>

The date with timezone that the Price List stops being valid.

id
required
string
Example: "pl_01G8X3CKJXCG5VXVZ87H9KC09W"

The price list's ID

name
required
string
Example: "VIP Prices"

The price list's name

starts_at
required
string or null <date-time>

The date with timezone that the Price List starts being valid.

status
required
string
Default: "draft"
Enum: "active" "draft"

The status of the Price List

type
required
string
Default: "sale"
Enum: "sale" "override"

The type of Price List. This can be one of either sale or override.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

Array of objects (Customer Group)

The details of the customer groups that the Price List can apply to.

Array of objects (Money Amount)

The prices that belong to the price list, represented as a Money Amount.

includes_tax
boolean
Default: false

Whether the price list prices include tax

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.priceLists.retrieve(priceListId)
.then(({ price_list }) => {
  console.log(price_list.id);
});

Response samples

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

Update a Price List

Update a Price List's details.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Price List.

Request Body schema: application/json
name
string

The name of the Price List

description
string

The description of the Price List.

starts_at
string <date>

The date with timezone that the Price List starts being valid.

ends_at
string <date>

The date with timezone that the Price List ends being valid.

type
string
Enum: "sale" "override"

The type of the Price List.

status
string
Enum: "active" "draft"

The status of the Price List. If the status is set to draft, the prices created in the price list will not be available of the customer.

Array of objects

The prices of the Price List.

Array of objects

An array of customer groups that the Price List applies to.

includes_tax
boolean

Tax included in prices of price list

Responses

Response Schema: application/json
required
object (Price List)

A Price List represents a set of prices that override the default price for one or more product variants.

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.

description
required
string
Example: "Prices for VIP customers"

The price list's description

ends_at
required
string or null <date-time>

The date with timezone that the Price List stops being valid.

id
required
string
Example: "pl_01G8X3CKJXCG5VXVZ87H9KC09W"

The price list's ID

name
required
string
Example: "VIP Prices"

The price list's name

starts_at
required
string or null <date-time>

The date with timezone that the Price List starts being valid.

status
required
string
Default: "draft"
Enum: "active" "draft"

The status of the Price List

type
required
string
Default: "sale"
Enum: "sale" "override"

The type of Price List. This can be one of either sale or override.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

Array of objects (Customer Group)

The details of the customer groups that the Price List can apply to.

Array of objects (Money Amount)

The prices that belong to the price list, represented as a Money Amount.

includes_tax
boolean
Default: false

Whether the price list prices include tax

Request samples

Content type
application/json
{
  • "name": "string",
  • "description": "string",
  • "starts_at": "2019-08-24",
  • "ends_at": "2019-08-24",
  • "type": "sale",
  • "status": "active",
  • "prices": [
    ],
  • "customer_groups": [
    ],
  • "includes_tax": true
}

Response samples

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

Delete a Price List

Delete a Price List and its associated prices.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Price List.

Responses

Response Schema: application/json
id
required
string

The ID of the deleted Price List.

object
required
string
Default: "price-list"

The type of the object that was deleted.

deleted
required
boolean
Default: true

Whether or not the items were deleted.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.priceLists.delete(priceListId)
.then(({ id, object, deleted }) => {
  console.log(id);
});

Response samples

Content type
application/json
{
  • "id": "string",
  • "object": "price-list",
  • "deleted": true
}

Add or Update Prices

Add or update a list of prices in a Price List

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Price List.

Request Body schema: application/json
Array of objects

The prices to update or add.

override
boolean

If set to true, the prices will replace all existing prices associated with the Price List.

Responses

Response Schema: application/json
required
object (Price List)

A Price List represents a set of prices that override the default price for one or more product variants.

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.

description
required
string
Example: "Prices for VIP customers"

The price list's description

ends_at
required
string or null <date-time>

The date with timezone that the Price List stops being valid.

id
required
string
Example: "pl_01G8X3CKJXCG5VXVZ87H9KC09W"

The price list's ID

name
required
string
Example: "VIP Prices"

The price list's name

starts_at
required
string or null <date-time>

The date with timezone that the Price List starts being valid.

status
required
string
Default: "draft"
Enum: "active" "draft"

The status of the Price List

type
required
string
Default: "sale"
Enum: "sale" "override"

The type of Price List. This can be one of either sale or override.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

Array of objects (Customer Group)

The details of the customer groups that the Price List can apply to.

Array of objects (Money Amount)

The prices that belong to the price list, represented as a Money Amount.

includes_tax
boolean
Default: false

Whether the price list prices include tax

Request samples

Content type
application/json
{
  • "prices": [
    ],
  • "override": true
}

Response samples

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

Delete Prices

Delete a list of prices in a Price List

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Price List

Request Body schema: application/json
price_ids
Array of strings

The price IDs of the Money Amounts to delete.

Responses

Response Schema: application/json
ids
required
Array of strings
object
required
string
Default: "money-amount"

The type of the object that was deleted. A price is also named money-amount.

deleted
required
boolean
Default: true

Whether or not the items were deleted.

Request samples

Content type
application/json
{
  • "price_ids": [
    ]
}

Response samples

Content type
application/json
{
  • "ids": [
    ],
  • "object": "money-amount",
  • "deleted": true
}

List Products

Retrieve a price list's products. The products can be filtered by fields such as q or status. The products can also be sorted or paginated.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

ID of the price list.

query Parameters
q
string

term used to search products' title, description, product variant's title and sku, and product collection's title.

id
string

Filter by product ID

status
Array of strings
Items Enum: "draft" "proposed" "published" "rejected"

Filter by product status

collection_id
Array of strings

Filter by product collection ID. Only products in the specified collections are retrieved.

tags
Array of strings

Filter by tag IDs. Only products having the specified tags are retrieved.

title
string

Filter by title

description
string

Filter by description

handle
string

Filter by handle

is_giftcard
string

A boolean value to filter by whether the product is a gift card or not.

type
string

Filter product type.

order
string

A product field to sort-order the retrieved products by.

object

Filter by a creation date range.

object

Filter by an update date range.

object

Filter by a deletion date range.

offset
integer
Default: 0

The number of products to skip when retrieving the products.

limit
integer
Default: 50

Limit the number of products returned.

expand
string

Comma-separated relations that should be expanded in the returned products.

fields
string

Comma-separated fields that should be included in the returned products.

Responses

Response Schema: application/json
required
Array of objects (Product)

An array of products details.

count
required
integer

The total number of items available

offset
required
integer

The number of price lists skipped when retrieving the price lists.

limit
required
integer

The number of items per page

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.priceLists.listProducts(priceListId)
.then(({ products, limit, offset, count }) => {
  console.log(products.length);
});

Response samples

Content type
application/json
{
  • "products": [
    ],
  • "count": 0,
  • "offset": 0,
  • "limit": 0
}

Delete a Product's Prices

Delete all the prices related to a specific product in a price list.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Price List.

product_id
required
string

The ID of the product from which the prices will be deleted.

Responses

Response Schema: application/json
ids
required
Array of strings

The IDs of the deleted prices.

object
required
string
Default: "money-amount"

The type of the object that was deleted. A price is also named money-amount.

deleted
required
boolean
Default: true

Whether or not the items were deleted.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.priceLists.deleteProductPrices(priceListId, productId)
.then(({ ids, object, deleted }) => {
  console.log(ids.length);
});

Response samples

Content type
application/json
{
  • "ids": [
    ],
  • "object": "money-amount",
  • "deleted": true
}

Delete a Variant's Prices

Delete all the prices related to a specific variant in a price list

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Price List.

variant_id
required
string

The ID of the variant.

Responses

Response Schema: application/json
ids
required
Array of strings

The IDs of the deleted prices.

object
required
string
Default: "money-amount"

The type of the object that was deleted. A price is also named money-amount.

deleted
required
boolean
Default: true

Whether or not the items were deleted.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.priceLists.deleteVariantPrices(priceListId, variantId)
.then(({ ids, object, deleted }) => {
  console.log(ids);
});

Response samples

Content type
application/json
{
  • "ids": [
    ],
  • "object": "money-amount",
  • "deleted": true
}

Product Categories

Products can be categoriezed into categories. A product can be added into more than one category.

List Product Categories

Retrieve a list of product categories. The product categories can be filtered by fields such as q or handle. The product categories can also be paginated.

Authorizations:
API TokenCookie Session ID
query Parameters
q
string

term to search product categories' names and handles.

handle
string

Filter by handle.

is_internal
boolean

Filter by whether the category is internal or not.

is_active
boolean

Filter by whether the category is active or not.

include_descendants_tree
boolean

If set to true, all nested descendants of a category are included in the response.

parent_category_id
string

Filter by the ID of a parent category.

offset
integer
Default: 0

The number of product categories to skip when retrieving the product categories.

limit
integer
Default: 100

Limit the number of product categories returned.

expand
string

Comma-separated relations that should be expanded in the returned product categories.

fields
string

Comma-separated fields that should be included in the returned product categories.

Responses

Response Schema: application/json
required
Array of objects (Product Category)

An array of product category details.

count
required
integer

The total number of items available

offset
required
integer

The number of product categories skipped when retrieving the product categories.

limit
required
integer

The number of items per page

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.productCategories.list()
.then(({ product_categories, limit, offset, count }) => {
  console.log(product_categories.length);
});

Response samples

Content type
application/json
{
  • "product_categories": [
    ],
  • "count": 0,
  • "offset": 0,
  • "limit": 0
}

Create a Product Category

Create a Product Category.

Authorizations:
API TokenCookie Session ID
query Parameters
expand
string

Comma-separated relations that should be expanded in the returned product category.

fields
string

Comma-separated fields that should be included in the returned product category.

Request Body schema: application/json
name
required
string

The name of the product category

description
string

The description of the product category.

handle
string

The handle of the product category. If none is provided, the kebab-case version of the name will be used. This field can be used as a slug in URLs.

is_internal
boolean

If set to true, the product category will only be available to admins.

is_active
boolean

If set to false, the product category will not be available in the storefront.

parent_category_id
string

The ID of the parent product category

Responses

Response Schema: application/json
required
object (Product Category)

A product category can be used to categorize products into a hierarchy of categories.

category_children
required
Array of objects

The details of the category's children.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

handle
required
string
Example: "regular-fit"

A unique string that identifies the Product Category - can for example be used in slug structures.

id
required
string
Example: "pcat_01G2SG30J8C85S4A5CHM2S1NS2"

The product category's ID

is_active
required
boolean
Default: false

A flag to make product category visible/hidden in the store front

is_internal
required
boolean
Default: false

A flag to make product category an internal category for admins

mpath
required
string or null
Example: "pcat_id1.pcat_id2.pcat_id3"

A string for Materialized Paths - used for finding ancestors and descendents

name
required
string
Example: "Regular Fit"

The product category's name

parent_category_id
required
string or null
Default: null

The ID of the parent category.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

rank
integer
Default: 0

An integer that depicts the rank of category in a tree node

parent_category
object or null

The details of the parent of this category.

products
Array of objects

The details of the products that belong to this category.

Request samples

Content type
application/json
{
  • "name": "string",
  • "description": "string",
  • "handle": "string",
  • "is_internal": true,
  • "is_active": true,
  • "parent_category_id": "string"
}

Response samples

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

Get a Product Category

Retrieve a Product Category's details.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Product Category

query Parameters
expand
string

Comma-separated relations that should be expanded in the returned product category.

fields
string

Comma-separated fields that should be included in the returned product category.

Responses

Response Schema: application/json
required
object (Product Category)

A product category can be used to categorize products into a hierarchy of categories.

category_children
required
Array of objects

The details of the category's children.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

handle
required
string
Example: "regular-fit"

A unique string that identifies the Product Category - can for example be used in slug structures.

id
required
string
Example: "pcat_01G2SG30J8C85S4A5CHM2S1NS2"

The product category's ID

is_active
required
boolean
Default: false

A flag to make product category visible/hidden in the store front

is_internal
required
boolean
Default: false

A flag to make product category an internal category for admins

mpath
required
string or null
Example: "pcat_id1.pcat_id2.pcat_id3"

A string for Materialized Paths - used for finding ancestors and descendents

name
required
string
Example: "Regular Fit"

The product category's name

parent_category_id
required
string or null
Default: null

The ID of the parent category.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

rank
integer
Default: 0

An integer that depicts the rank of category in a tree node

parent_category
object or null

The details of the parent of this category.

products
Array of objects

The details of the products that belong to this category.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.productCategories.retrieve(productCategoryId)
.then(({ product_category }) => {
  console.log(product_category.id);
});

Response samples

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

Update a Product Category

Updates a Product Category.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Product Category.

query Parameters
expand
string

(Comma separated) Which fields should be expanded in each product category.

fields
string

(Comma separated) Which fields should be retrieved in each product category.

Request Body schema: application/json
name
string

The name to identify the Product Category by.

description
string

An optional text field to describe the Product Category by.

handle
string

A handle to be used in slugs.

is_internal
boolean

A flag to make product category an internal category for admins

is_active
boolean

A flag to make product category visible/hidden in the store front

parent_category_id
string

The ID of the parent product category

rank
number

The rank of the category in the tree node (starting from 0)

Responses

Response Schema: application/json
required
object (Product Category)

A product category can be used to categorize products into a hierarchy of categories.

category_children
required
Array of objects

The details of the category's children.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

handle
required
string
Example: "regular-fit"

A unique string that identifies the Product Category - can for example be used in slug structures.

id
required
string
Example: "pcat_01G2SG30J8C85S4A5CHM2S1NS2"

The product category's ID

is_active
required
boolean
Default: false

A flag to make product category visible/hidden in the store front

is_internal
required
boolean
Default: false

A flag to make product category an internal category for admins

mpath
required
string or null
Example: "pcat_id1.pcat_id2.pcat_id3"

A string for Materialized Paths - used for finding ancestors and descendents

name
required
string
Example: "Regular Fit"

The product category's name

parent_category_id
required
string or null
Default: null

The ID of the parent category.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

rank
integer
Default: 0

An integer that depicts the rank of category in a tree node

parent_category
object or null

The details of the parent of this category.

products
Array of objects

The details of the products that belong to this category.

Request samples

Content type
application/json
{
  • "name": "string",
  • "description": "string",
  • "handle": "string",
  • "is_internal": true,
  • "is_active": true,
  • "parent_category_id": "string",
  • "rank": 0
}

Response samples

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

Delete a Product Category

Delete a Product Category. This does not delete associated products.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Product Category

Responses

Response Schema: application/json
id
required
string

The ID of the deleted product category

object
required
string
Default: "product-category"

The type of the object that was deleted.

deleted
required
boolean
Default: true

Whether or not the items were deleted.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.productCategories.delete(productCategoryId)
.then(({ id, object, deleted }) => {
  console.log(id);
});

Response samples

Content type
application/json
{
  • "id": "string",
  • "object": "product-category",
  • "deleted": true
}

Add Products to a Category

Add a list of products to a product category.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Product Category.

query Parameters
expand
string

Comma-separated relations that should be expanded in the returned product category.

fields
string

Comma-separated fields that should be included in the returned product category.

Request Body schema: application/json
required
Array of objects

The IDs of the products to add to the Product Category

Array
id
required
string

The ID of the product

Responses

Response Schema: application/json
required
object (Product Category)

A product category can be used to categorize products into a hierarchy of categories.

category_children
required
Array of objects

The details of the category's children.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

handle
required
string
Example: "regular-fit"

A unique string that identifies the Product Category - can for example be used in slug structures.

id
required
string
Example: "pcat_01G2SG30J8C85S4A5CHM2S1NS2"

The product category's ID

is_active
required
boolean
Default: false

A flag to make product category visible/hidden in the store front

is_internal
required
boolean
Default: false

A flag to make product category an internal category for admins

mpath
required
string or null
Example: "pcat_id1.pcat_id2.pcat_id3"

A string for Materialized Paths - used for finding ancestors and descendents

name
required
string
Example: "Regular Fit"

The product category's name

parent_category_id
required
string or null
Default: null

The ID of the parent category.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

rank
integer
Default: 0

An integer that depicts the rank of category in a tree node

parent_category
object or null

The details of the parent of this category.

products
Array of objects

The details of the products that belong to this category.

Request samples

Content type
application/json
{
  • "product_ids": [
    ]
}

Response samples

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

Remove Products from Category

Remove a list of products from a product category.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Product Category.

query Parameters
expand
string

Comma-separated relations that should be expanded in the returned product category.

fields
string

Comma-separated fields that should be included in the returned product category.

Request Body schema: application/json
required
Array of objects

The IDs of the products to delete from the Product Category.

Array
id
required
string

The ID of a product

Responses

Response Schema: application/json
required
object (Product Category)

A product category can be used to categorize products into a hierarchy of categories.

category_children
required
Array of objects

The details of the category's children.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

handle
required
string
Example: "regular-fit"

A unique string that identifies the Product Category - can for example be used in slug structures.

id
required
string
Example: "pcat_01G2SG30J8C85S4A5CHM2S1NS2"

The product category's ID

is_active
required
boolean
Default: false

A flag to make product category visible/hidden in the store front

is_internal
required
boolean
Default: false

A flag to make product category an internal category for admins

mpath
required
string or null
Example: "pcat_id1.pcat_id2.pcat_id3"

A string for Materialized Paths - used for finding ancestors and descendents

name
required
string
Example: "Regular Fit"

The product category's name

parent_category_id
required
string or null
Default: null

The ID of the parent category.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

rank
integer
Default: 0

An integer that depicts the rank of category in a tree node

parent_category
object or null

The details of the parent of this category.

products
Array of objects

The details of the products that belong to this category.

Request samples

Content type
application/json
{
  • "product_ids": [
    ]
}

Response samples

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

Product Collections

A product collection is used to organize products for different purposes such as marketing or discount purposes. For example, you can create a Summer Collection.

List Collections

Retrieve a list of Product Collection. The product collections can be filtered by fields such as handle or title. The collections can also be sorted or paginated.

Authorizations:
API TokenCookie Session ID
query Parameters
limit
integer
Default: 10

The number of collections to return.

offset
integer
Default: 0

The number of collections to skip when retrieving the collections.

title
string

Filter collections by their title.

handle
string

Filter collections by their handle.

q
string

a term to search collections by their title or handle.

discount_condition_id
string

Filter collections by a discount condition ID associated with them.

object

Filter by a creation date range.

object

Filter by an update date range.

object

Filter by a deletion date range.

Responses

Response Schema: application/json
required
Array of objects (Product Collection)

an array of collection details

count
required
integer

The total number of items available

offset
required
integer

The number of product collections skipped when retrieving the product collections.

limit
required
integer

The number of items per page

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.collections.list()
.then(({ collections, limit, offset, count }) => {
  console.log(collections.length);
});

Response samples

Content type
application/json
{
  • "collections": [
    ],
  • "count": 0,
  • "offset": 0,
  • "limit": 0
}

Create a Collection

Create a Product Collection.

Authorizations:
API TokenCookie Session ID
Request Body schema: application/json
title
required
string

The title of the collection.

handle
string

An optional handle to be used in slugs. If none is provided, the kebab-case version of the title will be used.

metadata
object

An optional set of key-value pairs to hold additional information.

Responses

Response Schema: application/json
required
object (Product Collection)

A Product Collection allows grouping together products for promotional purposes. For example, an admin can create a Summer collection, add products to it, and showcase it on the storefront.

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.

handle
required
string or null
Example: "summer-collection"

A unique string that identifies the Product Collection - can for example be used in slug structures.

id
required
string
Example: "pcol_01F0YESBFAZ0DV6V831JXWH0BG"

The product collection's ID

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

An optional key-value map with additional details

title
required
string
Example: "Summer Collection"

The title that the Product Collection is identified by.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

products
Array of objects

The details of the products that belong to this product collection.

Request samples

Content type
application/json
{
  • "title": "string",
  • "handle": "string",
  • "metadata": { }
}

Response samples

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

Get a Collection

Retrieve a Product Collection by its ID. The products associated with it are expanded and returned as well.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Product Collection

Responses

Response Schema: application/json
required
object (Product Collection)

A Product Collection allows grouping together products for promotional purposes. For example, an admin can create a Summer collection, add products to it, and showcase it on the storefront.

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.

handle
required
string or null
Example: "summer-collection"

A unique string that identifies the Product Collection - can for example be used in slug structures.

id
required
string
Example: "pcol_01F0YESBFAZ0DV6V831JXWH0BG"

The product collection's ID

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

An optional key-value map with additional details

title
required
string
Example: "Summer Collection"

The title that the Product Collection is identified by.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

products
Array of objects

The details of the products that belong to this product collection.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.collections.retrieve(collectionId)
.then(({ collection }) => {
  console.log(collection.id);
});

Response samples

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

Update a Collection

Update a Product Collection's details.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Collection.

Request Body schema: application/json
title
string

The title of the collection.

handle
string

An optional handle to be used in slugs. If none is provided, the kebab-case version of the title will be used.

metadata
object

An optional set of key-value pairs to hold additional information.

Responses

Response Schema: application/json
required
object (Product Collection)

A Product Collection allows grouping together products for promotional purposes. For example, an admin can create a Summer collection, add products to it, and showcase it on the storefront.

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.

handle
required
string or null
Example: "summer-collection"

A unique string that identifies the Product Collection - can for example be used in slug structures.

id
required
string
Example: "pcol_01F0YESBFAZ0DV6V831JXWH0BG"

The product collection's ID

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

An optional key-value map with additional details

title
required
string
Example: "Summer Collection"

The title that the Product Collection is identified by.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

products
Array of objects

The details of the products that belong to this product collection.

Request samples

Content type
application/json
{
  • "title": "string",
  • "handle": "string",
  • "metadata": { }
}

Response samples

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

Delete a Collection

Delete a Product Collection. This does not delete associated products.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Collection.

Responses

Response Schema: application/json
id
required
string

The ID of the deleted Collection

object
required
string
Default: "product-collection"

The type of the object that was deleted.

deleted
required
boolean
Default: true

Whether the collection was deleted successfully or not.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.collections.delete(collectionId)
.then(({ id, object, deleted }) => {
  console.log(id);
});

Response samples

Content type
application/json
{
  • "id": "string",
  • "object": "product-collection",
  • "deleted": true
}

Add Products to Collection

Add products to a product collection.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the product collection.

Request Body schema: application/json
product_ids
required
Array of strings

An array of Product IDs to add to the Product Collection.

Responses

Response Schema: application/json
required
object (Product Collection)

A Product Collection allows grouping together products for promotional purposes. For example, an admin can create a Summer collection, add products to it, and showcase it on the storefront.

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.

handle
required
string or null
Example: "summer-collection"

A unique string that identifies the Product Collection - can for example be used in slug structures.

id
required
string
Example: "pcol_01F0YESBFAZ0DV6V831JXWH0BG"

The product collection's ID

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

An optional key-value map with additional details

title
required
string
Example: "Summer Collection"

The title that the Product Collection is identified by.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

products
Array of objects

The details of the products that belong to this product collection.

Request samples

Content type
application/json
{
  • "product_ids": [
    ]
}

Response samples

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

Remove Products from Collection

Remove a list of products from a collection. This would not delete the product, only the association between the product and the collection.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Product Collection.

Request Body schema: application/json
product_ids
required
Array of strings

An array of Product IDs to remove from the Product Collection.

Responses

Response Schema: application/json
id
required
string

The ID of the collection

object
required
string
Default: "product-collection"

The type of object the removal was executed on

removed_products
required
Array of strings

The IDs of the products removed from the collection

Request samples

Content type
application/json
{
  • "product_ids": [
    ]
}

Response samples

Content type
application/json
{
  • "id": "string",
  • "object": "product-collection",
  • "removed_products": [
    ]
}

Product Tags

Product tags are string values created when you create or update a product with a new tag. Products can have more than one tag, and products can share tags. This allows admins to associate products to similar tags that can be used to filter products.

List Product Tags

Retrieve a list of product tags. The product tags can be filtered by fields such as q or value. The product tags can also be sorted or paginated.

Authorizations:
API TokenCookie Session ID
query Parameters
limit
integer
Default: 10

Limit the number of product tags returned.

offset
integer
Default: 0

The number of product tags to skip when retrieving the product tags.

order
string

A product tag field to sort-order the retrieved product tags by.

discount_condition_id
string

Filter by the ID of a discount condition. Only product tags that this discount condition is applied to will be retrieved.

value
Array of strings

Filter by tag value.

q
string

term to search product tags' values.

id
Array of strings

Filter by tag IDs.

object

Filter by a creation date range.

object

Filter by an update date range.

Responses

Response Schema: application/json
required
Array of objects (Product Tag)

An array of product tag details.

count
required
integer

The total number of items available

offset
required
integer

The number of product tags skipped when retrieving the product tags.

limit
required
integer

The number of items per page

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.productTags.list()
.then(({ product_tags }) => {
  console.log(product_tags.length);
});

Response samples

Content type
application/json
{
  • "product_tags": [
    ],
  • "count": 0,
  • "offset": 0,
  • "limit": 0
}

Product Types

Product types are string values created when you create or update a product with a new type. Products can have one type, and products can share types. This allows admins to associate products with a type that can be used to filter products.

List Product Types

Retrieve a list of product types. The product types can be filtered by fields such as q or value. The product types can also be sorted or paginated.

Authorizations:
API TokenCookie Session ID
query Parameters
limit
integer
Default: 20

Limit the number of product types returned.

offset
integer
Default: 0

The number of product types to skip when retrieving the product types.

order
string

A product type field to sort-order the retrieved product types by.

discount_condition_id
string

Filter by the ID of a discount condition. Only product types that this discount condition is applied to will be retrieved.

value
Array of strings

Filter by value.

id
Array of strings

Filter by product type IDs.

q
string

term to search product types' values.

object

Filter by a creation date range.

object

Filter by an update date range.

Responses

Response Schema: application/json
required
Array of objects (Product Type)

An array of product types details.

count
required
integer

The total number of items available

offset
required
integer

The number of product types skipped when retrieving the product types.

limit
required
integer

The number of items per page

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.productTypes.list()
.then(({ product_types }) => {
  console.log(product_types.length);
});

Response samples

Content type
application/json
{
  • "product_types": [
    ],
  • "count": 0,
  • "offset": 0,
  • "limit": 0
}

Product Variants

Product variants are the actual salable item in your store. Each variant is a combination of the different option values available on the product. Product variants can be managed through the Products endpoints.

List Product Variants

Retrieve a list of Product Variants. The product variant can be filtered by fields such as id or title. The product variant can also be paginated.

Authorizations:
API TokenCookie Session ID
query Parameters
string or Array of strings

Filter by product variant IDs.

expand
string

"Comma-separated relations that should be expanded in the returned product variants."

fields
string

"Comma-separated fields that should be included in the returned product variants."

offset
number
Default: "0"

The number of product variants to skip when retrieving the product variants.

limit
number
Default: "100"

Limit the number of product variants returned.

cart_id
string

The ID of the cart to use for the price selection context.

region_id
string

The ID of the region to use for the price selection context.

currency_code
string

The 3 character ISO currency code to use for the price selection context.

customer_id
string

The ID of the customer to use for the price selection context.

string or Array of strings

Filter by title.

number or object

Filter by available inventory quantity

Responses

Response Schema: application/json
required
Array of objects (Priced Product Variant)

An array of product variant details.

count
required
integer

The total number of items available

offset
required
integer

The number of product variants skipped when retrieving the product variants.

limit
required
integer

The number of items per page

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.variants.list()
.then(({ variants, limit, offset, count }) => {
  console.log(variants.length);
});

Response samples

Content type
application/json
{
  • "variants": [
    ],
  • "count": 0,
  • "offset": 0,
  • "limit": 0
}

Get a Product variant

Retrieve a product variant's details.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the product variant.

query Parameters
expand
string

"Comma-separated relations that should be expanded in the returned product variant."

fields
string

"Comma-separated fields that should be included in the returned product variant."

Responses

Response Schema: application/json
required
object (Priced Product Variant)

A Product Variant represents a Product with a specific set of Product Option configurations. The maximum number of Product Variants that a Product can have is given by the number of available Product Option combinations. A product must at least have one product variant.

allow_backorder
required
boolean
Default: false

Whether the Product Variant should be purchasable when inventory_quantity is 0.

barcode
required
string or null
Example: null

A generic field for a GTIN number that can be used to identify the Product Variant.

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.

ean
required
string or null
Example: null

An EAN barcode number that can be used to identify the Product Variant.

height
required
number or null
Example: null

The height of the Product Variant. May be used in shipping rate calculations.

hs_code
required
string or null
Example: null

The Harmonized System code of the Product Variant. May be used by Fulfillment Providers to pass customs information to shipping carriers.

id
required
string
Example: "variant_01G1G5V2MRX2V3PVSR2WXYPFB6"

The product variant's ID

inventory_quantity
required
integer
Example: 100

The current quantity of the item that is stocked.

length
required
number or null
Example: null

The length of the Product Variant. May be used in shipping rate calculations.

manage_inventory
required
boolean
Default: true

Whether Medusa should manage inventory for the Product Variant.

material
required
string or null
Example: null

The material and composition that the Product Variant is made of, May be used by Fulfillment Providers to pass customs information to shipping carriers.

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

An optional key-value map with additional details

mid_code
required
string or null
Example: null

The Manufacturers Identification code that identifies the manufacturer of the Product Variant. May be used by Fulfillment Providers to pass customs information to shipping carriers.

origin_country
required
string or null
Example: null

The country in which the Product Variant was produced. May be used by Fulfillment Providers to pass customs information to shipping carriers.

product_id
required
string
Example: "prod_01G1G5V2MBA328390B5AXJ610F"

The ID of the product that the product variant belongs to.

sku
required
string or null
Example: "shirt-123"

The unique stock keeping unit used to identify the Product Variant. This will usually be a unqiue identifer for the item that is to be shipped, and can be referenced across multiple systems.

title
required
string
Example: "Small"

A title that can be displayed for easy identification of the Product Variant.

upc
required
string or null
Example: null

A UPC barcode number that can be used to identify the Product Variant.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

weight
required
number or null
Example: null

The weight of the Product Variant. May be used in shipping rate calculations.

width
required
number or null
Example: null

The width of the Product Variant. May be used in shipping rate calculations.

product
object or null

The details of the product that the product variant belongs to.

Array of objects (Money Amount)

The details of the prices of the Product Variant, each represented as a Money Amount. Each Money Amount represents a price in a given currency or a specific Region.

variant_rank
number or null
Default: 0

The ranking of this variant

Array of objects (Product Option Value)

The details of the product options that this product variant defines values for.

Array of objects (Product Variant Inventory Item)

The details inventory items of the product variant.

purchasable
boolean

Only used with the inventory modules. A boolean value indicating whether the Product Variant is purchasable. A variant is purchasable if:

  • inventory is not managed
  • it has no inventory items
  • it is in stock
  • it is backorderable.
original_price
number

The original price of the variant without any discounted prices applied.

calculated_price
number

The calculated price of the variant. Can be a discounted price.

original_price_incl_tax
number

The original price of the variant including taxes.

calculated_price_incl_tax
number

The calculated price of the variant including taxes.

original_tax
number

The taxes applied on the original price.

calculated_tax
number

The taxes applied on the calculated price.

Array of objects

An array of applied tax rates

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.variants.retrieve(variantId)
.then(({ variant }) => {
  console.log(variant.id);
});

Response samples

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

Get Variant's Inventory

Retrieve the available inventory of a Product Variant.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The Product Variant ID.

Responses

Response Schema: application/json
object (AdminGetVariantsVariantInventoryRes)
object (VariantInventory)
id
required
string

the ID of the variant

required
object (ResponseInventoryItem)
required
Array of objects

An array of details about the variant's inventory availability in sales channels.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.variants.list()
.then(({ variants, limit, offset, count }) => {
  console.log(variants.length)
})

Response samples

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

Products

Products are saleable items in a store. This also includes saleable gift cards in a store.

List Products

Retrieve a list of products. The products can be filtered by fields such as q or status. The products can also be sorted or paginated.

Authorizations:
API TokenCookie Session ID
query Parameters
q
string

term to search products' title, description, variants' title and sku, and collections' title.

discount_condition_id
string

Filter by the ID of a discount condition. Only products that this discount condition is applied to will be retrieved.

string or Array of strings

Filter by product IDs.

status
Array of strings
Items Enum: "draft" "proposed" "published" "rejected"

Filter by status.

collection_id
Array of strings

Filter by product collection IDs. Only products that are associated with the specified collections will be retrieved.

tags
Array of strings

Filter by product tag IDs. Only products that are associated with the specified tags will be retrieved.

price_list_id
Array of strings

Filter by IDs of price lists. Only products that these price lists are applied to will be retrieved.

sales_channel_id
Array of strings

Filter by sales channel IDs. Only products that are available in the specified sales channels will be retrieved.

type_id
Array of strings

Filter by product type IDs. Only products that are associated with the specified types will be retrieved.

category_id
Array of strings

Filter by product category IDs. Only products that are associated with the specified categories will be retrieved.

include_category_children
boolean

whether to include product category children when filtering by category_id

title
string

Filter by title.

description
string

Filter by description.

handle
string

Filter by handle.

is_giftcard
boolean

Whether to retrieve gift cards or regular products.

object

Filter by a creation date range.

object

Filter by an update date range.

object

Filter by a deletion date range.

offset
integer
Default: 0

The number of products to skip when retrieving the products.

limit
integer
Default: 50

Limit the number of products returned.

expand
string

Comma-separated relations that should be expanded in the returned products.

fields
string

Comma-separated fields that should be included in the returned products.

order
string

A product field to sort-order the retrieved products by.

Responses

Response Schema: application/json
required
Array of objects (Priced Product)

An array of products details.

count
required
integer

The total number of items available

offset
required
integer

The number of products skipped when retrieving the products.

limit
required
integer

The number of items per page

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.products.list()
.then(({ products, limit, offset, count }) => {
  console.log(products.length);
});

Response samples

Content type
application/json
{
  • "products": [
    ],
  • "count": 0,
  • "offset": 0,
  • "limit": 0
}

Create a Product

Create a new Product. This endpoint can also be used to create a gift card if the is_giftcard field is set to true.

Authorizations:
API TokenCookie Session ID
Request Body schema: application/json
title
required
string

The title of the Product

subtitle
string

The subtitle of the Product

description
string

The description of the Product.

is_giftcard
boolean
Default: false

A flag to indicate if the Product represents a Gift Card. Purchasing Products with this flag set to true will result in a Gift Card being created.

discountable
boolean
Default: true

A flag to indicate if discounts can be applied to the Line Items generated from this Product

images
Array of strings

An array of images of the Product. Each value in the array is a URL to the image. You can use the upload endpoints to upload the image and obtain a URL.

thumbnail
string

The thumbnail to use for the Product. The value is a URL to the thumbnail. You can use the upload endpoints to upload the thumbnail and obtain a URL.

handle
string

A unique handle to identify the Product by. If not provided, the kebab-case version of the product title will be used. This can be used as a slug in URLs.

status
string
Default: "draft"
Enum: "draft" "proposed" "published" "rejected"

The status of the product. The product is shown to the customer only if its status is published.

object

The Product Type to associate the Product with.

collection_id
string

The ID of the Product Collection the Product belongs to.

Array of objects

Product Tags to associate the Product with.

Array of objects

Sales channels to associate the Product with.

Array of objects

Product categories to add the Product to.

Array of objects

The Options that the Product should have. A new product option will be created for every item in the array.

Array of objects

An array of Product Variants to create with the Product. Each product variant must have a unique combination of Product Option values.

weight
number

The weight of the Product.

length
number

The length of the Product.

height
number

The height of the Product.

width
number

The width of the Product.

hs_code
string

The Harmonized System code of the Product.

origin_country
string

The country of origin of the Product.

mid_code
string

The Manufacturer Identification code of the Product.

material
string

The material composition of the Product.

metadata
object

An optional set of key-value pairs with additional information.

Responses

Response Schema: application/json
required
object (Priced Product)

A product is a saleable item that holds general information such as name or description. It must include at least one Product Variant, where each product variant defines different options to purchase the product with (for example, different sizes or colors). The prices and inventory of the product are defined on the variant level.

collection_id
required
string or null
Example: "pcol_01F0YESBFAZ0DV6V831JXWH0BG"

The ID of the product collection that the product belongs to.

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.

description
required
string or null
Example: "Every programmer's best friend."

A short description of the Product.

discountable
required
boolean
Default: true

Whether the Product can be discounted. Discounts will not apply to Line Items of this Product when this flag is set to false.

external_id
required
string or null
Example: null

The external ID of the product

handle
required
string or null
Example: "coffee-mug"

A unique identifier for the Product (e.g. for slug structure).

height
required
number or null
Example: null

The height of the Product Variant. May be used in shipping rate calculations.

hs_code
required
string or null
Example: null

The Harmonized System code of the Product Variant. May be used by Fulfillment Providers to pass customs information to shipping carriers.

id
required
string
Example: "prod_01G1G5V2MBA328390B5AXJ610F"

The product's ID

is_giftcard
required
boolean
Default: false

Whether the Product represents a Gift Card. Products that represent Gift Cards will automatically generate a redeemable Gift Card code once they are purchased.

length
required
number or null
Example: null

The length of the Product Variant. May be used in shipping rate calculations.

material
required
string or null
Example: null

The material and composition that the Product Variant is made of, May be used by Fulfillment Providers to pass customs information to shipping carriers.

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

An optional key-value map with additional details

mid_code
required
string or null
Example: null

The Manufacturers Identification code that identifies the manufacturer of the Product Variant. May be used by Fulfillment Providers to pass customs information to shipping carriers.

origin_country
required
string or null
Example: null

The country in which the Product Variant was produced. May be used by Fulfillment Providers to pass customs information to shipping carriers.

profile_id
required
string
Example: "sp_01G1G5V239ENSZ5MV4JAR737BM"

The ID of the shipping profile that the product belongs to. The shipping profile has a set of defined shipping options that can be used to fulfill the product.

status
required
string
Default: "draft"
Enum: "draft" "proposed" "published" "rejected"

The status of the product

subtitle
required
string or null

An optional subtitle that can be used to further specify the Product.

type_id
required
string or null
Example: "ptyp_01G8X9A7ESKAJXG2H0E6F1MW7A"

The ID of the product type that the product belongs to.

thumbnail
required
string or null <uri>

A URL to an image file that can be used to identify the Product.

title
required
string
Example: "Medusa Coffee Mug"

A title that can be displayed for easy identification of the Product.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

weight
required
number or null
Example: null

The weight of the Product Variant. May be used in shipping rate calculations.

width
required
number or null
Example: null

The width of the Product Variant. May be used in shipping rate calculations.

Array of objects (Image)

The details of the product's images.

Array of objects (Product Option)

The details of the Product Options that are defined for the Product. The product's variants will have a unique combination of values of the product's options.

Array of objects (Product Variant)

The details of the Product Variants that belong to the Product. Each will have a unique combination of values of the product's options.

Array of objects (Product Category)

The details of the product categories that this product belongs to.

object (Shipping Profile)

A Shipping Profile has a set of defined Shipping Options that can be used to fulfill a given set of Products. For example, gift cards are shipped differently than physical products, so a shipping profile with the type gift_card groups together the shipping options that can only be used for gift cards.

Array of objects or null (Shipping Profile)

Available if the relation profiles is expanded.

object (Product Collection)

A Product Collection allows grouping together products for promotional purposes. For example, an admin can create a Summer collection, add products to it, and showcase it on the storefront.

object (Product Type)

A Product Type can be added to Products for filtering and reporting purposes.

Array of objects (Product Tag)

The details of the product tags used in this product.

Array of objects (Sales Channel)

The details of the sales channels this product is available in.

Request samples

Content type
application/json
{
  • "title": "string",
  • "subtitle": "string",
  • "description": "string",
  • "is_giftcard": false,
  • "discountable": true,
  • "images": [
    ],
  • "thumbnail": "string",
  • "handle": "string",
  • "status": "draft",
  • "type": {
    },
  • "collection_id": "string",
  • "tags": [
    ],
  • "sales_channels": [
    ],
  • "categories": [
    ],
  • "options": [
    ],
  • "variants": [
    ],
  • "weight": 0,
  • "length": 0,
  • "height": 0,
  • "width": 0,
  • "hs_code": "string",
  • "origin_country": "string",
  • "mid_code": "string",
  • "material": "string",
  • "metadata": { }
}

Response samples

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

List Tags Usage Number

Retrieve a list of Product Tags with how many times each is used in products.

Authorizations:
API TokenCookie Session ID

Responses

Response Schema: application/json
required
Array of objects

An array of product tags details.

Array
id
required
string

The ID of the tag.

usage_count
required
string

The number of products that use this tag.

value
required
string

The value of the tag.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.products.listTags()
.then(({ tags }) => {
  console.log(tags.length);
});

Response samples

Content type
application/json
{
  • "tags": [
    ]
}

List Product Types Deprecated

Retrieve a list of Product Types.

Authorizations:
API TokenCookie Session ID

Responses

Response Schema: application/json
required
Array of objects (Product Type)

An array of product types details.

Array
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.

id
required
string
Example: "ptyp_01G8X9A7ESKAJXG2H0E6F1MW7A"

The product type's ID

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

An optional key-value map with additional details

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

value
required
string
Example: "Clothing"

The value that the Product Type represents.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.products.listTypes()
.then(({ types }) => {
  console.log(types.length);
});

Response samples

Content type
application/json
{
  • "types": [
    ]
}

Get a Product

Retrieve a Product's details.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Product.

Responses

Response Schema: application/json
required
object (Priced Product)

A product is a saleable item that holds general information such as name or description. It must include at least one Product Variant, where each product variant defines different options to purchase the product with (for example, different sizes or colors). The prices and inventory of the product are defined on the variant level.

collection_id
required
string or null
Example: "pcol_01F0YESBFAZ0DV6V831JXWH0BG"

The ID of the product collection that the product belongs to.

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.

description
required
string or null
Example: "Every programmer's best friend."

A short description of the Product.

discountable
required
boolean
Default: true

Whether the Product can be discounted. Discounts will not apply to Line Items of this Product when this flag is set to false.

external_id
required
string or null
Example: null

The external ID of the product

handle
required
string or null
Example: "coffee-mug"

A unique identifier for the Product (e.g. for slug structure).

height
required
number or null
Example: null

The height of the Product Variant. May be used in shipping rate calculations.

hs_code
required
string or null
Example: null

The Harmonized System code of the Product Variant. May be used by Fulfillment Providers to pass customs information to shipping carriers.

id
required
string
Example: "prod_01G1G5V2MBA328390B5AXJ610F"

The product's ID

is_giftcard
required
boolean
Default: false

Whether the Product represents a Gift Card. Products that represent Gift Cards will automatically generate a redeemable Gift Card code once they are purchased.

length
required
number or null
Example: null

The length of the Product Variant. May be used in shipping rate calculations.

material
required
string or null
Example: null

The material and composition that the Product Variant is made of, May be used by Fulfillment Providers to pass customs information to shipping carriers.

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

An optional key-value map with additional details

mid_code
required
string or null
Example: null

The Manufacturers Identification code that identifies the manufacturer of the Product Variant. May be used by Fulfillment Providers to pass customs information to shipping carriers.

origin_country
required
string or null
Example: null

The country in which the Product Variant was produced. May be used by Fulfillment Providers to pass customs information to shipping carriers.

profile_id
required
string
Example: "sp_01G1G5V239ENSZ5MV4JAR737BM"

The ID of the shipping profile that the product belongs to. The shipping profile has a set of defined shipping options that can be used to fulfill the product.

status
required
string
Default: "draft"
Enum: "draft" "proposed" "published" "rejected"

The status of the product

subtitle
required
string or null

An optional subtitle that can be used to further specify the Product.

type_id
required
string or null
Example: "ptyp_01G8X9A7ESKAJXG2H0E6F1MW7A"

The ID of the product type that the product belongs to.

thumbnail
required
string or null <uri>

A URL to an image file that can be used to identify the Product.

title
required
string
Example: "Medusa Coffee Mug"

A title that can be displayed for easy identification of the Product.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

weight
required
number or null
Example: null

The weight of the Product Variant. May be used in shipping rate calculations.

width
required
number or null
Example: null

The width of the Product Variant. May be used in shipping rate calculations.

Array of objects (Image)

The details of the product's images.

Array of objects (Product Option)

The details of the Product Options that are defined for the Product. The product's variants will have a unique combination of values of the product's options.

Array of objects (Product Variant)

The details of the Product Variants that belong to the Product. Each will have a unique combination of values of the product's options.

Array of objects (Product Category)

The details of the product categories that this product belongs to.

object (Shipping Profile)

A Shipping Profile has a set of defined Shipping Options that can be used to fulfill a given set of Products. For example, gift cards are shipped differently than physical products, so a shipping profile with the type gift_card groups together the shipping options that can only be used for gift cards.

Array of objects or null (Shipping Profile)

Available if the relation profiles is expanded.

object (Product Collection)

A Product Collection allows grouping together products for promotional purposes. For example, an admin can create a Summer collection, add products to it, and showcase it on the storefront.

object (Product Type)

A Product Type can be added to Products for filtering and reporting purposes.

Array of objects (Product Tag)

The details of the product tags used in this product.

Array of objects (Sales Channel)

The details of the sales channels this product is available in.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.products.retrieve(productId)
.then(({ product }) => {
  console.log(product.id);
});

Response samples

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

Update a Product

Update a Product's details.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Product.

Request Body schema: application/json
title
string

The title of the Product

subtitle
string

The subtitle of the Product

description
string

The description of the Product.

discountable
boolean

A flag to indicate if discounts can be applied to the Line Items generated from this Product

images
Array of strings

An array of images of the Product. Each value in the array is a URL to the image. You can use the upload endpoints to upload the image and obtain a URL.

thumbnail
string

The thumbnail to use for the Product. The value is a URL to the thumbnail. You can use the upload endpoints to upload the thumbnail and obtain a URL.

handle
string

A unique handle to identify the Product by. If not provided, the kebab-case version of the product title will be used. This can be used as a slug in URLs.

status
string
Enum: "draft" "proposed" "published" "rejected"

The status of the product. The product is shown to the customer only if its status is published.

object

The Product Type to associate the Product with.

collection_id
string

The ID of the Product Collection the Product belongs to.

Array of objects

Product Tags to associate the Product with.

Array of objects

Sales channels to associate the Product with.

Array of objects

Product categories to add the Product to.

Array of objects

An array of Product Variants to create with the Product. Each product variant must have a unique combination of Product Option values.

weight
number

The weight of the Product.

length
number

The length of the Product.

height
number

The height of the Product.

width
number

The width of the Product.

origin_country
string

The country of origin of the Product.

mid_code
string

The Manufacturer Identification code of the Product.

material
string

The material composition of the Product.

metadata
object

An optional set of key-value pairs with additional information.

Responses

Response Schema: application/json
required
object (Priced Product)

A product is a saleable item that holds general information such as name or description. It must include at least one Product Variant, where each product variant defines different options to purchase the product with (for example, different sizes or colors). The prices and inventory of the product are defined on the variant level.

collection_id
required
string or null
Example: "pcol_01F0YESBFAZ0DV6V831JXWH0BG"

The ID of the product collection that the product belongs to.

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.

description
required
string or null
Example: "Every programmer's best friend."

A short description of the Product.

discountable
required
boolean
Default: true

Whether the Product can be discounted. Discounts will not apply to Line Items of this Product when this flag is set to false.

external_id
required
string or null
Example: null

The external ID of the product

handle
required
string or null
Example: "coffee-mug"

A unique identifier for the Product (e.g. for slug structure).

height
required
number or null
Example: null

The height of the Product Variant. May be used in shipping rate calculations.

hs_code
required
string or null
Example: null

The Harmonized System code of the Product Variant. May be used by Fulfillment Providers to pass customs information to shipping carriers.

id
required
string
Example: "prod_01G1G5V2MBA328390B5AXJ610F"

The product's ID

is_giftcard
required
boolean
Default: false

Whether the Product represents a Gift Card. Products that represent Gift Cards will automatically generate a redeemable Gift Card code once they are purchased.

length
required
number or null
Example: null

The length of the Product Variant. May be used in shipping rate calculations.

material
required
string or null
Example: null

The material and composition that the Product Variant is made of, May be used by Fulfillment Providers to pass customs information to shipping carriers.

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

An optional key-value map with additional details

mid_code
required
string or null
Example: null

The Manufacturers Identification code that identifies the manufacturer of the Product Variant. May be used by Fulfillment Providers to pass customs information to shipping carriers.

origin_country
required
string or null
Example: null

The country in which the Product Variant was produced. May be used by Fulfillment Providers to pass customs information to shipping carriers.

profile_id
required
string
Example: "sp_01G1G5V239ENSZ5MV4JAR737BM"

The ID of the shipping profile that the product belongs to. The shipping profile has a set of defined shipping options that can be used to fulfill the product.

status
required
string
Default: "draft"
Enum: "draft" "proposed" "published" "rejected"

The status of the product

subtitle
required
string or null

An optional subtitle that can be used to further specify the Product.

type_id
required
string or null
Example: "ptyp_01G8X9A7ESKAJXG2H0E6F1MW7A"

The ID of the product type that the product belongs to.

thumbnail
required
string or null <uri>

A URL to an image file that can be used to identify the Product.

title
required
string
Example: "Medusa Coffee Mug"

A title that can be displayed for easy identification of the Product.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

weight
required
number or null
Example: null

The weight of the Product Variant. May be used in shipping rate calculations.

width
required
number or null
Example: null

The width of the Product Variant. May be used in shipping rate calculations.

Array of objects (Image)

The details of the product's images.

Array of objects (Product Option)

The details of the Product Options that are defined for the Product. The product's variants will have a unique combination of values of the product's options.

Array of objects (Product Variant)

The details of the Product Variants that belong to the Product. Each will have a unique combination of values of the product's options.

Array of objects (Product Category)

The details of the product categories that this product belongs to.

object (Shipping Profile)

A Shipping Profile has a set of defined Shipping Options that can be used to fulfill a given set of Products. For example, gift cards are shipped differently than physical products, so a shipping profile with the type gift_card groups together the shipping options that can only be used for gift cards.

Array of objects or null (Shipping Profile)

Available if the relation profiles is expanded.

object (Product Collection)

A Product Collection allows grouping together products for promotional purposes. For example, an admin can create a Summer collection, add products to it, and showcase it on the storefront.

object (Product Type)

A Product Type can be added to Products for filtering and reporting purposes.

Array of objects (Product Tag)

The details of the product tags used in this product.

Array of objects (Sales Channel)

The details of the sales channels this product is available in.

Request samples

Content type
application/json
{
  • "title": "string",
  • "subtitle": "string",
  • "description": "string",
  • "discountable": true,
  • "images": [
    ],
  • "thumbnail": "string",
  • "handle": "string",
  • "status": "draft",
  • "type": {
    },
  • "collection_id": "string",
  • "tags": [
    ],
  • "sales_channels": [
    ],
  • "categories": [
    ],
  • "variants": [
    ],
  • "weight": 0,
  • "length": 0,
  • "height": 0,
  • "width": 0,
  • "origin_country": "string",
  • "mid_code": "string",
  • "material": "string",
  • "metadata": { }
}

Response samples

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

Delete a Product

Delete a Product and its associated product variants and options.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Product.

Responses

Response Schema: application/json
id
required
string

The ID of the deleted Product.

object
required
string
Default: "product"

The type of the object that was deleted.

deleted
required
boolean
Default: true

Whether or not the items were deleted.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.products.delete(productId)
.then(({ id, object, deleted }) => {
  console.log(id);
});

Response samples

Content type
application/json
{
  • "id": "string",
  • "object": "product",
  • "deleted": true
}

Set Metadata

Set the metadata of a Product. It can be any key-value pair, which allows adding custom data to a product.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Product.

Request Body schema: application/json
key
required
string

The metadata key

value
required
string

The metadata value

Responses

Response Schema: application/json
required
object (Priced Product)

A product is a saleable item that holds general information such as name or description. It must include at least one Product Variant, where each product variant defines different options to purchase the product with (for example, different sizes or colors). The prices and inventory of the product are defined on the variant level.

collection_id
required
string or null
Example: "pcol_01F0YESBFAZ0DV6V831JXWH0BG"

The ID of the product collection that the product belongs to.

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.

description
required
string or null
Example: "Every programmer's best friend."

A short description of the Product.

discountable
required
boolean
Default: true

Whether the Product can be discounted. Discounts will not apply to Line Items of this Product when this flag is set to false.

external_id
required
string or null
Example: null

The external ID of the product

handle
required
string or null
Example: "coffee-mug"

A unique identifier for the Product (e.g. for slug structure).

height
required
number or null
Example: null

The height of the Product Variant. May be used in shipping rate calculations.

hs_code
required
string or null
Example: null

The Harmonized System code of the Product Variant. May be used by Fulfillment Providers to pass customs information to shipping carriers.

id
required
string
Example: "prod_01G1G5V2MBA328390B5AXJ610F"

The product's ID

is_giftcard
required
boolean
Default: false

Whether the Product represents a Gift Card. Products that represent Gift Cards will automatically generate a redeemable Gift Card code once they are purchased.

length
required
number or null
Example: null

The length of the Product Variant. May be used in shipping rate calculations.

material
required
string or null
Example: null

The material and composition that the Product Variant is made of, May be used by Fulfillment Providers to pass customs information to shipping carriers.

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

An optional key-value map with additional details

mid_code
required
string or null
Example: null

The Manufacturers Identification code that identifies the manufacturer of the Product Variant. May be used by Fulfillment Providers to pass customs information to shipping carriers.

origin_country
required
string or null
Example: null

The country in which the Product Variant was produced. May be used by Fulfillment Providers to pass customs information to shipping carriers.

profile_id
required
string
Example: "sp_01G1G5V239ENSZ5MV4JAR737BM"

The ID of the shipping profile that the product belongs to. The shipping profile has a set of defined shipping options that can be used to fulfill the product.

status
required
string
Default: "draft"
Enum: "draft" "proposed" "published" "rejected"

The status of the product

subtitle
required
string or null

An optional subtitle that can be used to further specify the Product.

type_id
required
string or null
Example: "ptyp_01G8X9A7ESKAJXG2H0E6F1MW7A"

The ID of the product type that the product belongs to.

thumbnail
required
string or null <uri>

A URL to an image file that can be used to identify the Product.

title
required
string
Example: "Medusa Coffee Mug"

A title that can be displayed for easy identification of the Product.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

weight
required
number or null
Example: null

The weight of the Product Variant. May be used in shipping rate calculations.

width
required
number or null
Example: null

The width of the Product Variant. May be used in shipping rate calculations.

Array of objects (Image)

The details of the product's images.

Array of objects (Product Option)

The details of the Product Options that are defined for the Product. The product's variants will have a unique combination of values of the product's options.

Array of objects (Product Variant)

The details of the Product Variants that belong to the Product. Each will have a unique combination of values of the product's options.

Array of objects (Product Category)

The details of the product categories that this product belongs to.

object (Shipping Profile)

A Shipping Profile has a set of defined Shipping Options that can be used to fulfill a given set of Products. For example, gift cards are shipped differently than physical products, so a shipping profile with the type gift_card groups together the shipping options that can only be used for gift cards.

Array of objects or null (Shipping Profile)

Available if the relation profiles is expanded.

object (Product Collection)

A Product Collection allows grouping together products for promotional purposes. For example, an admin can create a Summer collection, add products to it, and showcase it on the storefront.

object (Product Type)

A Product Type can be added to Products for filtering and reporting purposes.

Array of objects (Product Tag)

The details of the product tags used in this product.

Array of objects (Sales Channel)

The details of the sales channels this product is available in.

Request samples

Content type
application/json
{
  • "key": "string",
  • "value": "string"
}

Response samples

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

Add a Product Option

Add a Product Option to a Product.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Product.

Request Body schema: application/json
title
required
string
Example: "Size"

The title the Product Option.

Responses

Response Schema: application/json
required
object (Priced Product)

A product is a saleable item that holds general information such as name or description. It must include at least one Product Variant, where each product variant defines different options to purchase the product with (for example, different sizes or colors). The prices and inventory of the product are defined on the variant level.

collection_id
required
string or null
Example: "pcol_01F0YESBFAZ0DV6V831JXWH0BG"

The ID of the product collection that the product belongs to.

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.

description
required
string or null
Example: "Every programmer's best friend."

A short description of the Product.

discountable
required
boolean
Default: true

Whether the Product can be discounted. Discounts will not apply to Line Items of this Product when this flag is set to false.

external_id
required
string or null
Example: null

The external ID of the product

handle
required
string or null
Example: "coffee-mug"

A unique identifier for the Product (e.g. for slug structure).

height
required
number or null
Example: null

The height of the Product Variant. May be used in shipping rate calculations.

hs_code
required
string or null
Example: null

The Harmonized System code of the Product Variant. May be used by Fulfillment Providers to pass customs information to shipping carriers.

id
required
string
Example: "prod_01G1G5V2MBA328390B5AXJ610F"

The product's ID

is_giftcard
required
boolean
Default: false

Whether the Product represents a Gift Card. Products that represent Gift Cards will automatically generate a redeemable Gift Card code once they are purchased.

length
required
number or null
Example: null

The length of the Product Variant. May be used in shipping rate calculations.

material
required
string or null
Example: null

The material and composition that the Product Variant is made of, May be used by Fulfillment Providers to pass customs information to shipping carriers.

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

An optional key-value map with additional details

mid_code
required
string or null
Example: null

The Manufacturers Identification code that identifies the manufacturer of the Product Variant. May be used by Fulfillment Providers to pass customs information to shipping carriers.

origin_country
required
string or null
Example: null

The country in which the Product Variant was produced. May be used by Fulfillment Providers to pass customs information to shipping carriers.

profile_id
required
string
Example: "sp_01G1G5V239ENSZ5MV4JAR737BM"

The ID of the shipping profile that the product belongs to. The shipping profile has a set of defined shipping options that can be used to fulfill the product.

status
required
string
Default: "draft"
Enum: "draft" "proposed" "published" "rejected"

The status of the product

subtitle
required
string or null

An optional subtitle that can be used to further specify the Product.

type_id
required
string or null
Example: "ptyp_01G8X9A7ESKAJXG2H0E6F1MW7A"

The ID of the product type that the product belongs to.

thumbnail
required
string or null <uri>

A URL to an image file that can be used to identify the Product.

title
required
string
Example: "Medusa Coffee Mug"

A title that can be displayed for easy identification of the Product.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

weight
required
number or null
Example: null

The weight of the Product Variant. May be used in shipping rate calculations.

width
required
number or null
Example: null

The width of the Product Variant. May be used in shipping rate calculations.

Array of objects (Image)

The details of the product's images.

Array of objects (Product Option)

The details of the Product Options that are defined for the Product. The product's variants will have a unique combination of values of the product's options.

Array of objects (Product Variant)

The details of the Product Variants that belong to the Product. Each will have a unique combination of values of the product's options.

Array of objects (Product Category)

The details of the product categories that this product belongs to.

object (Shipping Profile)

A Shipping Profile has a set of defined Shipping Options that can be used to fulfill a given set of Products. For example, gift cards are shipped differently than physical products, so a shipping profile with the type gift_card groups together the shipping options that can only be used for gift cards.

Array of objects or null (Shipping Profile)

Available if the relation profiles is expanded.

object (Product Collection)

A Product Collection allows grouping together products for promotional purposes. For example, an admin can create a Summer collection, add products to it, and showcase it on the storefront.

object (Product Type)

A Product Type can be added to Products for filtering and reporting purposes.

Array of objects (Product Tag)

The details of the product tags used in this product.

Array of objects (Sales Channel)

The details of the sales channels this product is available in.

Request samples

Content type
application/json
{
  • "title": "Size"
}

Response samples

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

Update a Product Option

Update a Product Option's details.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Product.

option_id
required
string

The ID of the Product Option.

Request Body schema: application/json
title
required
string

The title of the Product Option

Responses

Response Schema: application/json
required
object (Priced Product)

A product is a saleable item that holds general information such as name or description. It must include at least one Product Variant, where each product variant defines different options to purchase the product with (for example, different sizes or colors). The prices and inventory of the product are defined on the variant level.

collection_id
required
string or null
Example: "pcol_01F0YESBFAZ0DV6V831JXWH0BG"

The ID of the product collection that the product belongs to.

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.

description
required
string or null
Example: "Every programmer's best friend."

A short description of the Product.

discountable
required
boolean
Default: true

Whether the Product can be discounted. Discounts will not apply to Line Items of this Product when this flag is set to false.

external_id
required
string or null
Example: null

The external ID of the product

handle
required
string or null
Example: "coffee-mug"

A unique identifier for the Product (e.g. for slug structure).

height
required
number or null
Example: null

The height of the Product Variant. May be used in shipping rate calculations.

hs_code
required
string or null
Example: null

The Harmonized System code of the Product Variant. May be used by Fulfillment Providers to pass customs information to shipping carriers.

id
required
string
Example: "prod_01G1G5V2MBA328390B5AXJ610F"

The product's ID

is_giftcard
required
boolean
Default: false

Whether the Product represents a Gift Card. Products that represent Gift Cards will automatically generate a redeemable Gift Card code once they are purchased.

length
required
number or null
Example: null

The length of the Product Variant. May be used in shipping rate calculations.

material
required
string or null
Example: null

The material and composition that the Product Variant is made of, May be used by Fulfillment Providers to pass customs information to shipping carriers.

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

An optional key-value map with additional details

mid_code
required
string or null
Example: null

The Manufacturers Identification code that identifies the manufacturer of the Product Variant. May be used by Fulfillment Providers to pass customs information to shipping carriers.

origin_country
required
string or null
Example: null

The country in which the Product Variant was produced. May be used by Fulfillment Providers to pass customs information to shipping carriers.

profile_id
required
string
Example: "sp_01G1G5V239ENSZ5MV4JAR737BM"

The ID of the shipping profile that the product belongs to. The shipping profile has a set of defined shipping options that can be used to fulfill the product.

status
required
string
Default: "draft"
Enum: "draft" "proposed" "published" "rejected"

The status of the product

subtitle
required
string or null

An optional subtitle that can be used to further specify the Product.

type_id
required
string or null
Example: "ptyp_01G8X9A7ESKAJXG2H0E6F1MW7A"

The ID of the product type that the product belongs to.

thumbnail
required
string or null <uri>

A URL to an image file that can be used to identify the Product.

title
required
string
Example: "Medusa Coffee Mug"

A title that can be displayed for easy identification of the Product.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

weight
required
number or null
Example: null

The weight of the Product Variant. May be used in shipping rate calculations.

width
required
number or null
Example: null

The width of the Product Variant. May be used in shipping rate calculations.

Array of objects (Image)

The details of the product's images.

Array of objects (Product Option)

The details of the Product Options that are defined for the Product. The product's variants will have a unique combination of values of the product's options.

Array of objects (Product Variant)

The details of the Product Variants that belong to the Product. Each will have a unique combination of values of the product's options.

Array of objects (Product Category)

The details of the product categories that this product belongs to.

object (Shipping Profile)

A Shipping Profile has a set of defined Shipping Options that can be used to fulfill a given set of Products. For example, gift cards are shipped differently than physical products, so a shipping profile with the type gift_card groups together the shipping options that can only be used for gift cards.

Array of objects or null (Shipping Profile)

Available if the relation profiles is expanded.

object (Product Collection)

A Product Collection allows grouping together products for promotional purposes. For example, an admin can create a Summer collection, add products to it, and showcase it on the storefront.

object (Product Type)

A Product Type can be added to Products for filtering and reporting purposes.

Array of objects (Product Tag)

The details of the product tags used in this product.

Array of objects (Sales Channel)

The details of the sales channels this product is available in.

Request samples

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

Response samples

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

Delete a Product Option

Delete a Product Option. If there are product variants that use this product option, they must be deleted before deleting the product option.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Product.

option_id
required
string

The ID of the Product Option.

Responses

Response Schema: application/json
option_id
required
string

The ID of the deleted Product Option

object
required
string
Default: "option"

The type of the object that was deleted.

deleted
required
boolean
Default: true

Whether or not the items were deleted.

required
object (Priced Product)

A product is a saleable item that holds general information such as name or description. It must include at least one Product Variant, where each product variant defines different options to purchase the product with (for example, different sizes or colors). The prices and inventory of the product are defined on the variant level.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.products.deleteOption(productId, optionId)
.then(({ option_id, object, deleted, product }) => {
  console.log(product.id);
});

Response samples

Content type
application/json
{
  • "option_id": "string",
  • "object": "option",
  • "deleted": true,
  • "product": {
    }
}

List a Product's Variants

Retrieve a list of Product Variants associated with a Product. The variants can be paginated.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

ID of the product.

query Parameters
fields
string

Comma-separated fields that should be included in the returned product variants.

expand
string

Comma-separated relations that should be expanded in the returned product variants.

offset
integer
Default: 0

The number of product variants to skip when retrieving the product variants.

limit
integer
Default: 100

Limit the number of product variants returned.

Responses

Response Schema: application/json
required
Array of objects (Product Variant)

An array of product variants details.

count
required
integer

The total number of items available

offset
required
integer

The number of product variants skipped when retrieving the product variants.

limit
required
integer

The number of items per page

Request samples

curl 'https://medusa-url.com/admin/products/{id}/variants' \
-H 'Authorization: Bearer {api_token}'

Response samples

Content type
application/json
{
  • "variants": [
    ],
  • "count": 0,
  • "offset": 0,
  • "limit": 0
}

Create a Product Variant

Create a Product Variant associated with a Product. Each product variant must have a unique combination of Product Option values.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Product.

Request Body schema: application/json
title
required
string

The title of the product variant.

required
Array of objects

An array of product variant prices. A product variant can have different prices for each region or currency code.

required
Array of objects

An array of Product Option values that the variant corresponds to.

sku
string

The unique SKU of the product variant.

ean
string

The EAN number of the product variant.

upc
string

The UPC number of the product variant.

barcode
string

A generic GTIN field of the product variant.

hs_code
string

The Harmonized System code of the product variant.

inventory_quantity
integer
Default: 0

The amount of stock kept of the product variant.

allow_backorder
boolean

Whether the product variant can be purchased when out of stock.

manage_inventory
boolean
Default: true

Whether Medusa should keep track of the inventory of this product variant.

weight
number

The wieght of the product variant.

length
number

The length of the product variant.

height
number

The height of the product variant.

width
number

The width of the product variant.

origin_country
string

The country of origin of the product variant.

mid_code
string

The Manufacturer Identification code of the product variant.

material
string

The material composition of the product variant.

metadata
object

An optional set of key-value pairs with additional information.

Responses

Response Schema: application/json
required
object (Priced Product)

A product is a saleable item that holds general information such as name or description. It must include at least one Product Variant, where each product variant defines different options to purchase the product with (for example, different sizes or colors). The prices and inventory of the product are defined on the variant level.

collection_id
required
string or null
Example: "pcol_01F0YESBFAZ0DV6V831JXWH0BG"

The ID of the product collection that the product belongs to.

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.

description
required
string or null
Example: "Every programmer's best friend."

A short description of the Product.

discountable
required
boolean
Default: true

Whether the Product can be discounted. Discounts will not apply to Line Items of this Product when this flag is set to false.

external_id
required
string or null
Example: null

The external ID of the product

handle
required
string or null
Example: "coffee-mug"

A unique identifier for the Product (e.g. for slug structure).

height
required
number or null
Example: null

The height of the Product Variant. May be used in shipping rate calculations.

hs_code
required
string or null
Example: null

The Harmonized System code of the Product Variant. May be used by Fulfillment Providers to pass customs information to shipping carriers.

id
required
string
Example: "prod_01G1G5V2MBA328390B5AXJ610F"

The product's ID

is_giftcard
required
boolean
Default: false

Whether the Product represents a Gift Card. Products that represent Gift Cards will automatically generate a redeemable Gift Card code once they are purchased.

length
required
number or null
Example: null

The length of the Product Variant. May be used in shipping rate calculations.

material
required
string or null
Example: null

The material and composition that the Product Variant is made of, May be used by Fulfillment Providers to pass customs information to shipping carriers.

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

An optional key-value map with additional details

mid_code
required
string or null
Example: null

The Manufacturers Identification code that identifies the manufacturer of the Product Variant. May be used by Fulfillment Providers to pass customs information to shipping carriers.

origin_country
required
string or null
Example: null

The country in which the Product Variant was produced. May be used by Fulfillment Providers to pass customs information to shipping carriers.

profile_id
required
string
Example: "sp_01G1G5V239ENSZ5MV4JAR737BM"

The ID of the shipping profile that the product belongs to. The shipping profile has a set of defined shipping options that can be used to fulfill the product.

status
required
string
Default: "draft"
Enum: "draft" "proposed" "published" "rejected"

The status of the product

subtitle
required
string or null

An optional subtitle that can be used to further specify the Product.

type_id
required
string or null
Example: "ptyp_01G8X9A7ESKAJXG2H0E6F1MW7A"

The ID of the product type that the product belongs to.

thumbnail
required
string or null <uri>

A URL to an image file that can be used to identify the Product.

title
required
string
Example: "Medusa Coffee Mug"

A title that can be displayed for easy identification of the Product.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

weight
required
number or null
Example: null

The weight of the Product Variant. May be used in shipping rate calculations.

width
required
number or null
Example: null

The width of the Product Variant. May be used in shipping rate calculations.

Array of objects (Image)

The details of the product's images.

Array of objects (Product Option)

The details of the Product Options that are defined for the Product. The product's variants will have a unique combination of values of the product's options.

Array of objects (Product Variant)

The details of the Product Variants that belong to the Product. Each will have a unique combination of values of the product's options.

Array of objects (Product Category)

The details of the product categories that this product belongs to.

object (Shipping Profile)

A Shipping Profile has a set of defined Shipping Options that can be used to fulfill a given set of Products. For example, gift cards are shipped differently than physical products, so a shipping profile with the type gift_card groups together the shipping options that can only be used for gift cards.

Array of objects or null (Shipping Profile)

Available if the relation profiles is expanded.

object (Product Collection)

A Product Collection allows grouping together products for promotional purposes. For example, an admin can create a Summer collection, add products to it, and showcase it on the storefront.

object (Product Type)

A Product Type can be added to Products for filtering and reporting purposes.

Array of objects (Product Tag)

The details of the product tags used in this product.

Array of objects (Sales Channel)

The details of the sales channels this product is available in.

Request samples

Content type
application/json
{
  • "title": "string",
  • "sku": "string",
  • "ean": "string",
  • "upc": "string",
  • "barcode": "string",
  • "hs_code": "string",
  • "inventory_quantity": 0,
  • "allow_backorder": true,
  • "manage_inventory": true,
  • "weight": 0,
  • "length": 0,
  • "height": 0,
  • "width": 0,
  • "origin_country": "string",
  • "mid_code": "string",
  • "material": "string",
  • "metadata": { },
  • "prices": [
    ],
  • "options": [
    ]
}

Response samples

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

Update a Product Variant

Update a Product Variant's details.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Product.

variant_id
required
string

The ID of the Product Variant.

Request Body schema: application/json
title
string

The title of the product variant.

sku
string

The unique SKU of the product variant.

ean
string

The EAN number of the item.

upc
string

The UPC number of the item.

barcode
string

A generic GTIN field of the product variant.

hs_code
string

The Harmonized System code of the product variant.

inventory_quantity
integer

The amount of stock kept of the product variant.

allow_backorder
boolean

Whether the product variant can be purchased when out of stock.

manage_inventory
boolean

Whether Medusa should keep track of the inventory of this product variant.

weight
number

The weight of the product variant.

length
number

The length of the product variant.

height
number

The height of the product variant.

width
number

The width of the product variant.

origin_country
string

The country of origin of the product variant.

mid_code
string

The Manufacturer Identification code of the product variant.

material
string

The material composition of the product variant.

metadata
object

An optional set of key-value pairs with additional information.

Array of objects

An array of product variant prices. A product variant can have different prices for each region or currency code.

Array of objects

An array of Product Option values that the variant corresponds to.

Responses

Response Schema: application/json
required
object (Priced Product)

A product is a saleable item that holds general information such as name or description. It must include at least one Product Variant, where each product variant defines different options to purchase the product with (for example, different sizes or colors). The prices and inventory of the product are defined on the variant level.

collection_id
required
string or null
Example: "pcol_01F0YESBFAZ0DV6V831JXWH0BG"

The ID of the product collection that the product belongs to.

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.

description
required
string or null
Example: "Every programmer's best friend."

A short description of the Product.

discountable
required
boolean
Default: true

Whether the Product can be discounted. Discounts will not apply to Line Items of this Product when this flag is set to false.

external_id
required
string or null
Example: null

The external ID of the product

handle
required
string or null
Example: "coffee-mug"

A unique identifier for the Product (e.g. for slug structure).

height
required
number or null
Example: null

The height of the Product Variant. May be used in shipping rate calculations.

hs_code
required
string or null
Example: null

The Harmonized System code of the Product Variant. May be used by Fulfillment Providers to pass customs information to shipping carriers.

id
required
string
Example: "prod_01G1G5V2MBA328390B5AXJ610F"

The product's ID

is_giftcard
required
boolean
Default: false

Whether the Product represents a Gift Card. Products that represent Gift Cards will automatically generate a redeemable Gift Card code once they are purchased.

length
required
number or null
Example: null

The length of the Product Variant. May be used in shipping rate calculations.

material
required
string or null
Example: null

The material and composition that the Product Variant is made of, May be used by Fulfillment Providers to pass customs information to shipping carriers.

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

An optional key-value map with additional details

mid_code
required
string or null
Example: null

The Manufacturers Identification code that identifies the manufacturer of the Product Variant. May be used by Fulfillment Providers to pass customs information to shipping carriers.

origin_country
required
string or null
Example: null

The country in which the Product Variant was produced. May be used by Fulfillment Providers to pass customs information to shipping carriers.

profile_id
required
string
Example: "sp_01G1G5V239ENSZ5MV4JAR737BM"

The ID of the shipping profile that the product belongs to. The shipping profile has a set of defined shipping options that can be used to fulfill the product.

status
required
string
Default: "draft"
Enum: "draft" "proposed" "published" "rejected"

The status of the product

subtitle
required
string or null

An optional subtitle that can be used to further specify the Product.

type_id
required
string or null
Example: "ptyp_01G8X9A7ESKAJXG2H0E6F1MW7A"

The ID of the product type that the product belongs to.

thumbnail
required
string or null <uri>

A URL to an image file that can be used to identify the Product.

title
required
string
Example: "Medusa Coffee Mug"

A title that can be displayed for easy identification of the Product.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

weight
required
number or null
Example: null

The weight of the Product Variant. May be used in shipping rate calculations.

width
required
number or null
Example: null

The width of the Product Variant. May be used in shipping rate calculations.

Array of objects (Image)

The details of the product's images.

Array of objects (Product Option)

The details of the Product Options that are defined for the Product. The product's variants will have a unique combination of values of the product's options.

Array of objects (Product Variant)

The details of the Product Variants that belong to the Product. Each will have a unique combination of values of the product's options.

Array of objects (Product Category)

The details of the product categories that this product belongs to.

object (Shipping Profile)

A Shipping Profile has a set of defined Shipping Options that can be used to fulfill a given set of Products. For example, gift cards are shipped differently than physical products, so a shipping profile with the type gift_card groups together the shipping options that can only be used for gift cards.

Array of objects or null (Shipping Profile)

Available if the relation profiles is expanded.

object (Product Collection)

A Product Collection allows grouping together products for promotional purposes. For example, an admin can create a Summer collection, add products to it, and showcase it on the storefront.

object (Product Type)

A Product Type can be added to Products for filtering and reporting purposes.

Array of objects (Product Tag)

The details of the product tags used in this product.

Array of objects (Sales Channel)

The details of the sales channels this product is available in.

Request samples

Content type
application/json
{
  • "title": "string",
  • "sku": "string",
  • "ean": "string",
  • "upc": "string",
  • "barcode": "string",
  • "hs_code": "string",
  • "inventory_quantity": 0,
  • "allow_backorder": true,
  • "manage_inventory": true,
  • "weight": 0,
  • "length": 0,
  • "height": 0,
  • "width": 0,
  • "origin_country": "string",
  • "mid_code": "string",
  • "material": "string",
  • "metadata": { },
  • "prices": [
    ],
  • "options": [
    ]
}

Response samples

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

Delete a Product Variant

Delete a Product Variant.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Product.

variant_id
required
string

The ID of the Product Variant.

Responses

Response Schema: application/json
variant_id
required
string

The ID of the deleted Product Variant.

object
required
string
Default: "product-variant"

The type of the object that was deleted.

deleted
required
boolean
Default: true

Whether or not the items were deleted.

required
object (Priced Product)

A product is a saleable item that holds general information such as name or description. It must include at least one Product Variant, where each product variant defines different options to purchase the product with (for example, different sizes or colors). The prices and inventory of the product are defined on the variant level.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.products.deleteVariant(productId, variantId)
.then(({ variant_id, object, deleted, product }) => {
  console.log(product.id);
});

Response samples

Content type
application/json
{
  • "variant_id": "string",
  • "object": "product-variant",
  • "deleted": true,
  • "product": {
    }
}

Publishable Api Keys

Update Publishable API Key

Update a Publishable API Key's details.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Publishable API Key.

Request Body schema: application/json
title
string

The title of the Publishable API Key.

Responses

Response Schema: application/json
required
object (Publishable API key)

A Publishable API key defines scopes that resources are available in. Then, it can be used in request to infer the resources without having to directly pass them. For example, a publishable API key can be associated with one or more sales channels. Then, when the publishable API key is passed in the header of a request, it is inferred what sales channel is being used without having to pass the sales channel as a query or body parameter of the request. Publishable API keys can only be used with sales channels, at the moment.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

created_by
required
string or null
Example: "usr_01G1G5V26F5TB3GPAPNJ8X1S3V"

The unique identifier of the user that created the key.

id
required
string
Example: "pk_01G1G5V27GYX4QXNARRQCW1N8T"

The key's ID

revoked_by
required
string or null
Example: "usr_01G1G5V26F5TB3GPAPNJ8X1S3V"

The unique identifier of the user that revoked the key.

revoked_at
required
string or null <date-time>

The date with timezone at which the key was revoked.

title
required
string

The key's title.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

Request samples

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

Response samples

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

List Publishable API keys

Retrieve a list of publishable API keys. The publishable API keys can be filtered by fields such as q. The publishable API keys can also be paginated.

Authorizations:
API TokenCookie Session ID
query Parameters
q
string

term to search publishable API keys' titles.

limit
number
Default: "20"

Limit the number of publishable API keys returned.

offset
number
Default: "0"

The number of publishable API keys to skip when retrieving the publishable API keys.

expand
string

Comma-separated relations that should be expanded in the returned publishable API keys.

fields
string

Comma-separated fields that should be included in the returned publishable API keys.

Responses

Response Schema: application/json
required
Array of objects (Publishable API key)

An array of publishable API keys details.

count
required
integer

The total number of items available

offset
required
integer

The number of publishable API keys skipped when retrieving the publishable API keys.

limit
required
integer

The number of items per page

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.publishableApiKeys.list()
  .then(({ publishable_api_keys, count, limit, offset }) => {
    console.log(publishable_api_keys)
  })

Response samples

Content type
application/json
{
  • "publishable_api_keys": [
    ],
  • "count": 0,
  • "offset": 0,
  • "limit": 0
}

Create Publishable API Key

Creates a Publishable API Key.

Authorizations:
API TokenCookie Session ID
Request Body schema: application/json
title
required
string

The title of the publishable API key

Responses

Response Schema: application/json
required
object (Publishable API key)

A Publishable API key defines scopes that resources are available in. Then, it can be used in request to infer the resources without having to directly pass them. For example, a publishable API key can be associated with one or more sales channels. Then, when the publishable API key is passed in the header of a request, it is inferred what sales channel is being used without having to pass the sales channel as a query or body parameter of the request. Publishable API keys can only be used with sales channels, at the moment.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

created_by
required
string or null
Example: "usr_01G1G5V26F5TB3GPAPNJ8X1S3V"

The unique identifier of the user that created the key.

id
required
string
Example: "pk_01G1G5V27GYX4QXNARRQCW1N8T"

The key's ID

revoked_by
required
string or null
Example: "usr_01G1G5V26F5TB3GPAPNJ8X1S3V"

The unique identifier of the user that revoked the key.

revoked_at
required
string or null <date-time>

The date with timezone at which the key was revoked.

title
required
string

The key's title.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

Request samples

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

Response samples

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

Get a Publishable API Key

Retrieve a publishable API key's details.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Publishable API Key.

Responses

Response Schema: application/json
required
object (Publishable API key)

A Publishable API key defines scopes that resources are available in. Then, it can be used in request to infer the resources without having to directly pass them. For example, a publishable API key can be associated with one or more sales channels. Then, when the publishable API key is passed in the header of a request, it is inferred what sales channel is being used without having to pass the sales channel as a query or body parameter of the request. Publishable API keys can only be used with sales channels, at the moment.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

created_by
required
string or null
Example: "usr_01G1G5V26F5TB3GPAPNJ8X1S3V"

The unique identifier of the user that created the key.

id
required
string
Example: "pk_01G1G5V27GYX4QXNARRQCW1N8T"

The key's ID

revoked_by
required
string or null
Example: "usr_01G1G5V26F5TB3GPAPNJ8X1S3V"

The unique identifier of the user that revoked the key.

revoked_at
required
string or null <date-time>

The date with timezone at which the key was revoked.

title
required
string

The key's title.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.publishableApiKeys.retrieve(publishableApiKeyId)
.then(({ publishable_api_key }) => {
  console.log(publishable_api_key.id)
})

Response samples

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

Delete Publishable API Key

Delete a Publishable API Key. Associated resources, such as sales channels, are not deleted.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Publishable API Key to delete.

Responses

Response Schema: application/json
id
required
string

The ID of the deleted publishable API key.

object
required
string
Default: "publishable_api_key"

The type of the object that was deleted.

deleted
required
boolean
Default: true

Whether the publishable API key was deleted.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.publishableApiKeys.delete(publishableApiKeyId)
.then(({ id, object, deleted }) => {
  console.log(id)
})

Response samples

Content type
application/json
{
  • "id": "string",
  • "object": "publishable_api_key",
  • "deleted": true
}

Revoke a Publishable API Key

Revoke a Publishable API Key. Revoking the publishable API Key can't be undone, and the key can't be used in future requests.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Publishable API Key.

Responses

Response Schema: application/json
required
object (Publishable API key)

A Publishable API key defines scopes that resources are available in. Then, it can be used in request to infer the resources without having to directly pass them. For example, a publishable API key can be associated with one or more sales channels. Then, when the publishable API key is passed in the header of a request, it is inferred what sales channel is being used without having to pass the sales channel as a query or body parameter of the request. Publishable API keys can only be used with sales channels, at the moment.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

created_by
required
string or null
Example: "usr_01G1G5V26F5TB3GPAPNJ8X1S3V"

The unique identifier of the user that created the key.

id
required
string
Example: "pk_01G1G5V27GYX4QXNARRQCW1N8T"

The key's ID

revoked_by
required
string or null
Example: "usr_01G1G5V26F5TB3GPAPNJ8X1S3V"

The unique identifier of the user that revoked the key.

revoked_at
required
string or null <date-time>

The date with timezone at which the key was revoked.

title
required
string

The key's title.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.publishableApiKeys.revoke(publishableApiKeyId)
  .then(({ publishable_api_key }) => {
    console.log(publishable_api_key.id)
  })

Response samples

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

List Sales Channels

List the sales channels associated with a publishable API key. The sales channels can be filtered by fields such as q.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the publishable API key.

query Parameters
q
string

query to search sales channels' names and descriptions.

Responses

Response Schema: application/json
required
Array of objects (Sales Channel)

An array of sales channels details.

Array
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.

description
required
string or null
Example: "Multi-vendor market"

The description of the sales channel.

id
required
string
Example: "sc_01G8X9A7ESKAJXG2H0E6F1MW7A"

The sales channel's ID

is_disabled
required
boolean
Default: false

Specify if the sales channel is enabled or disabled.

name
required
string
Example: "Market"

The name of the sales channel.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

Array of objects (Sales Channel Stock Location)

The details of the stock locations related to the sales channel.

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

An optional key-value map with additional details

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.publishableApiKeys.listSalesChannels()
  .then(({ sales_channels }) => {
    console.log(sales_channels.length)
  })

Response samples

Content type
application/json
{
  • "sales_channels": [
    ]
}

Add Sales Channels

Assign a list of sales channels to a publishable API key.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Publishable Api Key.

Request Body schema: application/json
required
Array of objects

The IDs of the sales channels to add to the publishable API key

Array
id
required
string

The ID of the sales channel

Responses

Response Schema: application/json
required
object (Publishable API key)

A Publishable API key defines scopes that resources are available in. Then, it can be used in request to infer the resources without having to directly pass them. For example, a publishable API key can be associated with one or more sales channels. Then, when the publishable API key is passed in the header of a request, it is inferred what sales channel is being used without having to pass the sales channel as a query or body parameter of the request. Publishable API keys can only be used with sales channels, at the moment.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

created_by
required
string or null
Example: "usr_01G1G5V26F5TB3GPAPNJ8X1S3V"

The unique identifier of the user that created the key.

id
required
string
Example: "pk_01G1G5V27GYX4QXNARRQCW1N8T"

The key's ID

revoked_by
required
string or null
Example: "usr_01G1G5V26F5TB3GPAPNJ8X1S3V"

The unique identifier of the user that revoked the key.

revoked_at
required
string or null <date-time>

The date with timezone at which the key was revoked.

title
required
string

The key's title.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

Request samples

Content type
application/json
{
  • "sales_channel_ids": [
    ]
}

Response samples

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

Remove Sales Channels

Remove a list of sales channels from a publishable API key. This doesn't delete the sales channels and only removes the association between them and the publishable API key.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Publishable API Key.

Request Body schema: application/json
required
Array of objects

The IDs of the sales channels to remove from the publishable API key

Array
id
required
string

The ID of the sales channel

Responses

Response Schema: application/json
required
object (Publishable API key)

A Publishable API key defines scopes that resources are available in. Then, it can be used in request to infer the resources without having to directly pass them. For example, a publishable API key can be associated with one or more sales channels. Then, when the publishable API key is passed in the header of a request, it is inferred what sales channel is being used without having to pass the sales channel as a query or body parameter of the request. Publishable API keys can only be used with sales channels, at the moment.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

created_by
required
string or null
Example: "usr_01G1G5V26F5TB3GPAPNJ8X1S3V"

The unique identifier of the user that created the key.

id
required
string
Example: "pk_01G1G5V27GYX4QXNARRQCW1N8T"

The key's ID

revoked_by
required
string or null
Example: "usr_01G1G5V26F5TB3GPAPNJ8X1S3V"

The unique identifier of the user that revoked the key.

revoked_at
required
string or null <date-time>

The date with timezone at which the key was revoked.

title
required
string

The key's title.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

Request samples

Content type
application/json
{
  • "sales_channel_ids": [
    ]
}

Response samples

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

Publishable API Keys

Publishable API Keys can be used to scope Store API calls with an API key, determining what resources are retrieved when querying the API. For example, a publishable API key can be associated with one or more sales channels. When it is passed in the header of a request to the List Product store endpoint, the sales channels are inferred from the key and only products associated with those sales channels are retrieved. Admins can manage publishable API keys and their associated resources. Currently, only Sales Channels are supported as a resource.

Regions

Regions are different countries or geographical regions that the commerce store serves customers in. Admins can manage these regions, their providers, and more.

List Regions

Retrieve a list of Regions. The regions can be filtered by fields such as created_at. The regions can also be paginated

Authorizations:
API TokenCookie Session ID
query Parameters
limit
integer
Default: 50

Limit the number of regions returned.

offset
integer
Default: 0

The number of regions to skip when retrieving the regions.

object

Filter by a creation date range.

object

Filter by an update date range.

object

Filter by a deletion date range.

Responses

Response Schema: application/json
required
Array of objects (Region)

An array of regions details.

count
required
integer

The total number of items available

offset
required
integer

The number of regions skipped when retrieving the regions.

limit
required
integer

The number of items per page

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.regions.list()
.then(({ regions, limit, offset, count }) => {
  console.log(regions.length);
});

Response samples

Content type
application/json
{
  • "regions": [
    ],
  • "count": 0,
  • "offset": 0,
  • "limit": 0
}

Create a Region

Create a Region.

Authorizations:
API TokenCookie Session ID
Request Body schema: application/json
name
required
string

The name of the Region

currency_code
required
string

The 3 character ISO currency code to use in the Region.

tax_rate
required
number

The tax rate to use in the Region.

payment_providers
required
Array of strings

A list of Payment Provider IDs that can be used in the Region

fulfillment_providers
required
Array of strings

A list of Fulfillment Provider IDs that can be used in the Region

countries
required
Array of strings
Example: ["US"]

A list of countries' 2 ISO characters that should be included in the Region.

tax_code
string

The tax code of the Region.

includes_tax
boolean

Whether taxes are included in the prices of the region.

Responses

Response Schema: application/json
required
object (Region)

A region holds settings specific to a geographical location, including the currency, tax rates, and fulfillment and payment providers. A Region can consist of multiple countries to accomodate common shopping settings across countries.

automatic_taxes
required
boolean
Default: true

Whether taxes should be automated in this region.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

currency_code
required
string
Example: "usd"

The 3 character currency code used in the region.

deleted_at
required
string or null <date-time>

The date with timezone at which the resource was deleted.

gift_cards_taxable
required
boolean
Default: true

Whether the gift cards are taxable or not in this region.

id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The region's ID

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

An optional key-value map with additional details

name
required
string
Example: "EU"

The name of the region as displayed to the customer. If the Region only has one country it is recommended to write the country name.

tax_code
required
string or null
Example: null

The tax code used on purchases in the Region. This may be used by other systems for accounting purposes.

tax_provider_id
required
string or null
Example: null

The ID of the tax provider used in this region

tax_rate
required
number
Example: 0

The tax rate that should be charged on purchases in the Region.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

object (Currency)

Currency

Array of objects (Tax Rate)

The details of the tax rates used in the region, aside from the default rate.

Array of objects (Country)

The details of the countries included in this region.

object (Tax Provider)

A tax provider represents a tax service installed in the Medusa backend, either through a plugin or backend customizations. It holds the tax service's installation status.

Array of objects (Payment Provider)

The details of the payment providers that can be used to process payments in the region.

Array of objects (Fulfillment Provider)

The details of the fulfillment providers that can be used to fulfill items of orders and similar resources in the region.

includes_tax
boolean
Default: false

Whether the prices for the region include tax

Request samples

Content type
application/json
{
  • "name": "string",
  • "currency_code": "string",
  • "tax_code": "string",
  • "tax_rate": 0,
  • "payment_providers": [
    ],
  • "fulfillment_providers": [
    ],
  • "countries": [
    ],
  • "includes_tax": true
}

Response samples

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

Get a Region

Retrieve a Region's details.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Region.

Responses

Response Schema: application/json
required
object (Region)

A region holds settings specific to a geographical location, including the currency, tax rates, and fulfillment and payment providers. A Region can consist of multiple countries to accomodate common shopping settings across countries.

automatic_taxes
required
boolean
Default: true

Whether taxes should be automated in this region.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

currency_code
required
string
Example: "usd"

The 3 character currency code used in the region.

deleted_at
required
string or null <date-time>

The date with timezone at which the resource was deleted.

gift_cards_taxable
required
boolean
Default: true

Whether the gift cards are taxable or not in this region.

id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The region's ID

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

An optional key-value map with additional details

name
required
string
Example: "EU"

The name of the region as displayed to the customer. If the Region only has one country it is recommended to write the country name.

tax_code
required
string or null
Example: null

The tax code used on purchases in the Region. This may be used by other systems for accounting purposes.

tax_provider_id
required
string or null
Example: null

The ID of the tax provider used in this region

tax_rate
required
number
Example: 0

The tax rate that should be charged on purchases in the Region.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

object (Currency)

Currency

Array of objects (Tax Rate)

The details of the tax rates used in the region, aside from the default rate.

Array of objects (Country)

The details of the countries included in this region.

object (Tax Provider)

A tax provider represents a tax service installed in the Medusa backend, either through a plugin or backend customizations. It holds the tax service's installation status.

Array of objects (Payment Provider)

The details of the payment providers that can be used to process payments in the region.

Array of objects (Fulfillment Provider)

The details of the fulfillment providers that can be used to fulfill items of orders and similar resources in the region.

includes_tax
boolean
Default: false

Whether the prices for the region include tax

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.regions.retrieve(regionId)
.then(({ region }) => {
  console.log(region.id);
});

Response samples

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

Update a Region

Update a Region's details.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Region.

Request Body schema: application/json
name
string

The name of the Region

currency_code
string

The 3 character ISO currency code to use in the Region.

automatic_taxes
boolean

If set to true, the Medusa backend will automatically calculate taxes for carts in this region. If set to false, the taxes must be calculated manually.

gift_cards_taxable
boolean

If set to true, taxes will be applied on gift cards.

tax_provider_id
string

The ID of the tax provider to use. If none provided, the system tax provider is used.

tax_code
string

The tax code of the Region.

tax_rate
number

The tax rate to use in the Region.

includes_tax
boolean

Whether taxes are included in the prices of the region.

payment_providers
Array of strings

A list of Payment Provider IDs that can be used in the Region

fulfillment_providers
Array of strings

A list of Fulfillment Provider IDs that can be used in the Region

countries
Array of strings

A list of countries' 2 ISO characters that should be included in the Region.

Responses

Response Schema: application/json
required
object (Region)

A region holds settings specific to a geographical location, including the currency, tax rates, and fulfillment and payment providers. A Region can consist of multiple countries to accomodate common shopping settings across countries.

automatic_taxes
required
boolean
Default: true

Whether taxes should be automated in this region.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

currency_code
required
string
Example: "usd"

The 3 character currency code used in the region.

deleted_at
required
string or null <date-time>

The date with timezone at which the resource was deleted.

gift_cards_taxable
required
boolean
Default: true

Whether the gift cards are taxable or not in this region.

id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The region's ID

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

An optional key-value map with additional details

name
required
string
Example: "EU"

The name of the region as displayed to the customer. If the Region only has one country it is recommended to write the country name.

tax_code
required
string or null
Example: null

The tax code used on purchases in the Region. This may be used by other systems for accounting purposes.

tax_provider_id
required
string or null
Example: null

The ID of the tax provider used in this region

tax_rate
required
number
Example: 0

The tax rate that should be charged on purchases in the Region.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

object (Currency)

Currency

Array of objects (Tax Rate)

The details of the tax rates used in the region, aside from the default rate.

Array of objects (Country)

The details of the countries included in this region.

object (Tax Provider)

A tax provider represents a tax service installed in the Medusa backend, either through a plugin or backend customizations. It holds the tax service's installation status.

Array of objects (Payment Provider)

The details of the payment providers that can be used to process payments in the region.

Array of objects (Fulfillment Provider)

The details of the fulfillment providers that can be used to fulfill items of orders and similar resources in the region.

includes_tax
boolean
Default: false

Whether the prices for the region include tax

Request samples

Content type
application/json
{
  • "name": "string",
  • "currency_code": "string",
  • "automatic_taxes": true,
  • "gift_cards_taxable": true,
  • "tax_provider_id": "string",
  • "tax_code": "string",
  • "tax_rate": 0,
  • "includes_tax": true,
  • "payment_providers": [
    ],
  • "fulfillment_providers": [
    ],
  • "countries": [
    ]
}

Response samples

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

Delete a Region

Delete a Region. Associated resources, such as providers or currencies are not deleted. Associated tax rates are deleted.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Region.

Responses

Response Schema: application/json
id
required
string

The ID of the deleted Region.

object
required
string
Default: "region"

The type of the object that was deleted.

deleted
required
boolean
Default: true

Whether or not the items were deleted.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.regions.delete(regionId)
.then(({ id, object, deleted }) => {
  console.log(id);
});

Response samples

Content type
application/json
{
  • "id": "string",
  • "object": "region",
  • "deleted": true
}

Add Country

Add a Country to the list of Countries in a Region

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Region.

Request Body schema: application/json
country_code
required
string

The 2 character ISO code for the Country.

Responses

Response Schema: application/json
required
object (Region)

A region holds settings specific to a geographical location, including the currency, tax rates, and fulfillment and payment providers. A Region can consist of multiple countries to accomodate common shopping settings across countries.

automatic_taxes
required
boolean
Default: true

Whether taxes should be automated in this region.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

currency_code
required
string
Example: "usd"

The 3 character currency code used in the region.

deleted_at
required
string or null <date-time>

The date with timezone at which the resource was deleted.

gift_cards_taxable
required
boolean
Default: true

Whether the gift cards are taxable or not in this region.

id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The region's ID

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

An optional key-value map with additional details

name
required
string
Example: "EU"

The name of the region as displayed to the customer. If the Region only has one country it is recommended to write the country name.

tax_code
required
string or null
Example: null

The tax code used on purchases in the Region. This may be used by other systems for accounting purposes.

tax_provider_id
required
string or null
Example: null

The ID of the tax provider used in this region

tax_rate
required
number
Example: 0

The tax rate that should be charged on purchases in the Region.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

object (Currency)

Currency

Array of objects (Tax Rate)

The details of the tax rates used in the region, aside from the default rate.

Array of objects (Country)

The details of the countries included in this region.

object (Tax Provider)

A tax provider represents a tax service installed in the Medusa backend, either through a plugin or backend customizations. It holds the tax service's installation status.

Array of objects (Payment Provider)

The details of the payment providers that can be used to process payments in the region.

Array of objects (Fulfillment Provider)

The details of the fulfillment providers that can be used to fulfill items of orders and similar resources in the region.

includes_tax
boolean
Default: false

Whether the prices for the region include tax

Request samples

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

Response samples

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

Remove Country

Remove a Country from the list of Countries in a Region. The country will still be available in the system, and it can be used in other regions.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Region.

country_code
required
string

The 2 character ISO code for the Country.

Responses

Response Schema: application/json
required
object (Region)

A region holds settings specific to a geographical location, including the currency, tax rates, and fulfillment and payment providers. A Region can consist of multiple countries to accomodate common shopping settings across countries.

automatic_taxes
required
boolean
Default: true

Whether taxes should be automated in this region.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

currency_code
required
string
Example: "usd"

The 3 character currency code used in the region.

deleted_at
required
string or null <date-time>

The date with timezone at which the resource was deleted.

gift_cards_taxable
required
boolean
Default: true

Whether the gift cards are taxable or not in this region.

id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The region's ID

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

An optional key-value map with additional details

name
required
string
Example: "EU"

The name of the region as displayed to the customer. If the Region only has one country it is recommended to write the country name.

tax_code
required
string or null
Example: null

The tax code used on purchases in the Region. This may be used by other systems for accounting purposes.

tax_provider_id
required
string or null
Example: null

The ID of the tax provider used in this region

tax_rate
required
number
Example: 0

The tax rate that should be charged on purchases in the Region.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

object (Currency)

Currency

Array of objects (Tax Rate)

The details of the tax rates used in the region, aside from the default rate.

Array of objects (Country)

The details of the countries included in this region.

object (Tax Provider)

A tax provider represents a tax service installed in the Medusa backend, either through a plugin or backend customizations. It holds the tax service's installation status.

Array of objects (Payment Provider)

The details of the payment providers that can be used to process payments in the region.

Array of objects (Fulfillment Provider)

The details of the fulfillment providers that can be used to fulfill items of orders and similar resources in the region.

includes_tax
boolean
Default: false

Whether the prices for the region include tax

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.regions.deleteCountry(regionId, "dk")
.then(({ region }) => {
  console.log(region.id);
});

Response samples

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

List Fulfillment Options

Retrieve a list of fulfillment options available in a Region.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Region.

Responses

Response Schema: application/json
required
Array of objects

Fulfillment providers details.

Array
provider_id
required
string

ID of the fulfillment provider

options
required
Array of objects
Example: [[{"id":"manual-fulfillment"},{"id":"manual-fulfillment-return","is_return":true}]]

fulfillment provider options

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.regions.retrieveFulfillmentOptions(regionId)
.then(({ fulfillment_options }) => {
  console.log(fulfillment_options.length);
});

Response samples

Content type
application/json
{
  • "fulfillment_options": [
    ]
}

Add Fulfillment Provider

Add a Fulfillment Provider to the list of fulfullment providers in a Region.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Region.

Request Body schema: application/json
provider_id
required
string

The ID of the Fulfillment Provider.

Responses

Response Schema: application/json
required
object (Region)

A region holds settings specific to a geographical location, including the currency, tax rates, and fulfillment and payment providers. A Region can consist of multiple countries to accomodate common shopping settings across countries.

automatic_taxes
required
boolean
Default: true

Whether taxes should be automated in this region.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

currency_code
required
string
Example: "usd"

The 3 character currency code used in the region.

deleted_at
required
string or null <date-time>

The date with timezone at which the resource was deleted.

gift_cards_taxable
required
boolean
Default: true

Whether the gift cards are taxable or not in this region.

id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The region's ID

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

An optional key-value map with additional details

name
required
string
Example: "EU"

The name of the region as displayed to the customer. If the Region only has one country it is recommended to write the country name.

tax_code
required
string or null
Example: null

The tax code used on purchases in the Region. This may be used by other systems for accounting purposes.

tax_provider_id
required
string or null
Example: null

The ID of the tax provider used in this region

tax_rate
required
number
Example: 0

The tax rate that should be charged on purchases in the Region.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

object (Currency)

Currency

Array of objects (Tax Rate)

The details of the tax rates used in the region, aside from the default rate.

Array of objects (Country)

The details of the countries included in this region.

object (Tax Provider)

A tax provider represents a tax service installed in the Medusa backend, either through a plugin or backend customizations. It holds the tax service's installation status.

Array of objects (Payment Provider)

The details of the payment providers that can be used to process payments in the region.

Array of objects (Fulfillment Provider)

The details of the fulfillment providers that can be used to fulfill items of orders and similar resources in the region.

includes_tax
boolean
Default: false

Whether the prices for the region include tax

Request samples

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

Response samples

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

Remove Fulfillment Provider

Remove a Fulfillment Provider from a Region. The fulfillment provider will still be available for usage in other regions.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Region.

provider_id
required
string

The ID of the Fulfillment Provider.

Responses

Response Schema: application/json
required
object (Region)

A region holds settings specific to a geographical location, including the currency, tax rates, and fulfillment and payment providers. A Region can consist of multiple countries to accomodate common shopping settings across countries.

automatic_taxes
required
boolean
Default: true

Whether taxes should be automated in this region.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

currency_code
required
string
Example: "usd"

The 3 character currency code used in the region.

deleted_at
required
string or null <date-time>

The date with timezone at which the resource was deleted.

gift_cards_taxable
required
boolean
Default: true

Whether the gift cards are taxable or not in this region.

id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The region's ID

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

An optional key-value map with additional details

name
required
string
Example: "EU"

The name of the region as displayed to the customer. If the Region only has one country it is recommended to write the country name.

tax_code
required
string or null
Example: null

The tax code used on purchases in the Region. This may be used by other systems for accounting purposes.

tax_provider_id
required
string or null
Example: null

The ID of the tax provider used in this region

tax_rate
required
number
Example: 0

The tax rate that should be charged on purchases in the Region.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

object (Currency)

Currency

Array of objects (Tax Rate)

The details of the tax rates used in the region, aside from the default rate.

Array of objects (Country)

The details of the countries included in this region.

object (Tax Provider)

A tax provider represents a tax service installed in the Medusa backend, either through a plugin or backend customizations. It holds the tax service's installation status.

Array of objects (Payment Provider)

The details of the payment providers that can be used to process payments in the region.

Array of objects (Fulfillment Provider)

The details of the fulfillment providers that can be used to fulfill items of orders and similar resources in the region.

includes_tax
boolean
Default: false

Whether the prices for the region include tax

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.regions.deleteFulfillmentProvider(regionId, "manual")
.then(({ region }) => {
  console.log(region.id);
});

Response samples

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

Add Payment Provider

Add a Payment Provider to the list of payment providers in a Region.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Region.

Request Body schema: application/json
provider_id
required
string

The ID of the Payment Provider.

Responses

Response Schema: application/json
required
object (Region)

A region holds settings specific to a geographical location, including the currency, tax rates, and fulfillment and payment providers. A Region can consist of multiple countries to accomodate common shopping settings across countries.

automatic_taxes
required
boolean
Default: true

Whether taxes should be automated in this region.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

currency_code
required
string
Example: "usd"

The 3 character currency code used in the region.

deleted_at
required
string or null <date-time>

The date with timezone at which the resource was deleted.

gift_cards_taxable
required
boolean
Default: true

Whether the gift cards are taxable or not in this region.

id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The region's ID

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

An optional key-value map with additional details

name
required
string
Example: "EU"

The name of the region as displayed to the customer. If the Region only has one country it is recommended to write the country name.

tax_code
required
string or null
Example: null

The tax code used on purchases in the Region. This may be used by other systems for accounting purposes.

tax_provider_id
required
string or null
Example: null

The ID of the tax provider used in this region

tax_rate
required
number
Example: 0

The tax rate that should be charged on purchases in the Region.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

object (Currency)

Currency

Array of objects (Tax Rate)

The details of the tax rates used in the region, aside from the default rate.

Array of objects (Country)

The details of the countries included in this region.

object (Tax Provider)

A tax provider represents a tax service installed in the Medusa backend, either through a plugin or backend customizations. It holds the tax service's installation status.

Array of objects (Payment Provider)

The details of the payment providers that can be used to process payments in the region.

Array of objects (Fulfillment Provider)

The details of the fulfillment providers that can be used to fulfill items of orders and similar resources in the region.

includes_tax
boolean
Default: false

Whether the prices for the region include tax

Request samples

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

Response samples

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

Remove Payment Provider

Remove a Payment Provider from a Region. The payment provider will still be available for usage in other regions.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Region.

provider_id
required
string

The ID of the Payment Provider.

Responses

Response Schema: application/json
required
object (Region)

A region holds settings specific to a geographical location, including the currency, tax rates, and fulfillment and payment providers. A Region can consist of multiple countries to accomodate common shopping settings across countries.

automatic_taxes
required
boolean
Default: true

Whether taxes should be automated in this region.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

currency_code
required
string
Example: "usd"

The 3 character currency code used in the region.

deleted_at
required
string or null <date-time>

The date with timezone at which the resource was deleted.

gift_cards_taxable
required
boolean
Default: true

Whether the gift cards are taxable or not in this region.

id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The region's ID

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

An optional key-value map with additional details

name
required
string
Example: "EU"

The name of the region as displayed to the customer. If the Region only has one country it is recommended to write the country name.

tax_code
required
string or null
Example: null

The tax code used on purchases in the Region. This may be used by other systems for accounting purposes.

tax_provider_id
required
string or null
Example: null

The ID of the tax provider used in this region

tax_rate
required
number
Example: 0

The tax rate that should be charged on purchases in the Region.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

object (Currency)

Currency

Array of objects (Tax Rate)

The details of the tax rates used in the region, aside from the default rate.

Array of objects (Country)

The details of the countries included in this region.

object (Tax Provider)

A tax provider represents a tax service installed in the Medusa backend, either through a plugin or backend customizations. It holds the tax service's installation status.

Array of objects (Payment Provider)

The details of the payment providers that can be used to process payments in the region.

Array of objects (Fulfillment Provider)

The details of the fulfillment providers that can be used to fulfill items of orders and similar resources in the region.

includes_tax
boolean
Default: false

Whether the prices for the region include tax

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.regions.deletePaymentProvider(regionId, "manual")
.then(({ region }) => {
  console.log(region.id);
});

Response samples

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

Reservations

Reservations, provided by the Inventory Module, are quantities of an item that are reserved, typically when an order is placed but not yet fulfilled. Reservations can be associated with any resources, but commonly with line items of an order.

List Reservations

Retrieve a list of Reservations. The reservations can be filtered by fields such as location_id or quantity. The reservations can also be paginated.

Authorizations:
API TokenCookie Session ID
query Parameters
location_id
Array of strings

Filter by location ID

inventory_item_id
Array of strings

Filter by inventory item ID.

line_item_id
Array of strings

Filter by line item ID.

object

Filter by reservation quantity

string or object

Filter by description.

object

Filter by a creation date range.

offset
integer
Default: 0

The number of reservations to skip when retrieving the reservations.

limit
integer
Default: 20

Limit the number of reservations returned.

expand
string

Comma-separated relations that should be expanded in the returned reservations.

fields
string

Comma-separated fields that should be included in the returned reservations.

Responses

Response Schema: application/json
required
Array of objects (ExtendedReservationItem)

An array of reservations details.

count
required
integer

The total number of items available

offset
required
integer

The number of reservations skipped when retrieving the reservations.

limit
required
integer

The number of items per page

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.reservations.list()
.then(({ reservations, count, limit, offset }) => {
  console.log(reservations.length)
})

Response samples

Content type
application/json
{
  • "reservations": [
    ],
  • "count": 0,
  • "offset": 0,
  • "limit": 0
}

Create a Reservation

Create a Reservation which can be associated with any resource, such as an order's line item.

Authorizations:
API TokenCookie Session ID
Request Body schema: application/json
location_id
required
string

The ID of the location of the reservation.

inventory_item_id
required
string

The ID of the inventory item the reservation is associated with.

quantity
required
number

The quantity to reserve.

line_item_id
string

The ID of the line item of the reservation.

metadata
object

An optional set of key-value pairs with additional information.

Responses

Response Schema: application/json
required
object (Reservation item)

Represents a reservation of an inventory item at a stock location

id
required
string

The id of the reservation item

location_id
required
string

The id of the location of the reservation

inventory_item_id
required
string

The id of the inventory item the reservation relates to

quantity
required
number

The id of the reservation item

description
string

Description of the reservation item

created_by
string

UserId of user who created the reservation item

metadata
object
Example: {"car":"white"}

An optional key-value map with additional details

created_at
string <date-time>

The date with timezone at which the resource was created.

updated_at
string <date-time>

The date with timezone at which the resource was updated.

deleted_at
string <date-time>

The date with timezone at which the resource was deleted.

Request samples

Content type
application/json
{
  • "line_item_id": "string",
  • "location_id": "string",
  • "inventory_item_id": "string",
  • "quantity": 0,
  • "metadata": { }
}

Response samples

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

Get a Reservation

Retrieve a reservation's details.'

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the reservation.

Responses

Response Schema: application/json
required
object (Reservation item)

Represents a reservation of an inventory item at a stock location

id
required
string

The id of the reservation item

location_id
required
string

The id of the location of the reservation

inventory_item_id
required
string

The id of the inventory item the reservation relates to

quantity
required
number

The id of the reservation item

description
string

Description of the reservation item

created_by
string

UserId of user who created the reservation item

metadata
object
Example: {"car":"white"}

An optional key-value map with additional details

created_at
string <date-time>

The date with timezone at which the resource was created.

updated_at
string <date-time>

The date with timezone at which the resource was updated.

deleted_at
string <date-time>

The date with timezone at which the resource was deleted.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.reservations.retrieve(reservationId)
.then(({ reservation }) => {
  console.log(reservation.id);
});

Response samples

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

Update a Reservation

Update a Reservation's details.'

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Reservation.

Request Body schema: application/json
location_id
string

The ID of the location associated with the reservation.

quantity
number

The quantity to reserve.

metadata
object

An optional set of key-value pairs with additional information.

Responses

Response Schema: application/json
required
object (Reservation item)

Represents a reservation of an inventory item at a stock location

id
required
string

The id of the reservation item

location_id
required
string

The id of the location of the reservation

inventory_item_id
required
string

The id of the inventory item the reservation relates to

quantity
required
number

The id of the reservation item

description
string

Description of the reservation item

created_by
string

UserId of user who created the reservation item

metadata
object
Example: {"car":"white"}

An optional key-value map with additional details

created_at
string <date-time>

The date with timezone at which the resource was created.

updated_at
string <date-time>

The date with timezone at which the resource was updated.

deleted_at
string <date-time>

The date with timezone at which the resource was deleted.

Request samples

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

Response samples

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

Delete a Reservation

Delete a Reservation. Associated resources, such as the line item, will not be deleted.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Reservation to delete.

Responses

Response Schema: application/json
id
required
string

The ID of the deleted Reservation.

object
required
string
Default: "reservation"

The type of the object that was deleted.

deleted
required
boolean
Default: true

Whether or not the Reservation was deleted.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.reservations.delete(reservationId)
.then(({ id, object, deleted }) => {
  console.log(id);
});

Response samples

Content type
application/json
{
  • "id": "string",
  • "object": "reservation",
  • "deleted": true
}

Return Reasons

Return reasons are key-value pairs that are used to specify why an order return is being created. Admins can manage available return reasons, and they can be used by both admins and customers when creating a return.

List Return Reasons

Retrieve a list of Return Reasons.

Authorizations:
API TokenCookie Session ID

Responses

Response Schema: application/json
required
Array of objects (Return Reason)
Array
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.

description
required
string or null
Example: "Items that are damaged"

A description of the Reason.

id
required
string
Example: "rr_01G8X82GCCV2KSQHDBHSSAH5TQ"

The return reason's ID

label
required
string
Example: "Damaged goods"

A text that can be displayed to the Customer as a reason.

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

An optional key-value map with additional details

parent_return_reason_id
required
string or null
Example: null

The ID of the parent reason.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

value
required
string
Example: "damaged"

The value to identify the reason by.

parent_return_reason
object or null

The details of the parent reason.

return_reason_children
object

The details of the child reasons.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.returnReasons.list()
.then(({ return_reasons }) => {
  console.log(return_reasons.length);
});

Response samples

Content type
application/json
{
  • "return_reasons": [
    ]
}

Create a Return Reason

Create a Return Reason.

Authorizations:
API TokenCookie Session ID
Request Body schema: application/json
label
required
string

The label to display to the Customer.

value
required
string

A unique value of the return reason.

parent_return_reason_id
string

The ID of the parent return reason.

description
string

The description of the Reason.

metadata
object

An optional set of key-value pairs with additional information.

Responses

Response Schema: application/json
required
object (Return Reason)

A Return Reason is a value defined by an admin. It can be used on Return Items in order to indicate why a Line Item was returned.

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.

description
required
string or null
Example: "Items that are damaged"

A description of the Reason.

id
required
string
Example: "rr_01G8X82GCCV2KSQHDBHSSAH5TQ"

The return reason's ID

label
required
string
Example: "Damaged goods"

A text that can be displayed to the Customer as a reason.

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

An optional key-value map with additional details

parent_return_reason_id
required
string or null
Example: null

The ID of the parent reason.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

value
required
string
Example: "damaged"

The value to identify the reason by.

parent_return_reason
object or null

The details of the parent reason.

return_reason_children
object

The details of the child reasons.

Request samples

Content type
application/json
{
  • "label": "string",
  • "value": "string",
  • "parent_return_reason_id": "string",
  • "description": "string",
  • "metadata": { }
}

Response samples

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

Get a Return Reason

Retrieve a Return Reason's details.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Return Reason.

Responses

Response Schema: application/json
required
object (Return Reason)

A Return Reason is a value defined by an admin. It can be used on Return Items in order to indicate why a Line Item was returned.

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.

description
required
string or null
Example: "Items that are damaged"

A description of the Reason.

id
required
string
Example: "rr_01G8X82GCCV2KSQHDBHSSAH5TQ"

The return reason's ID

label
required
string
Example: "Damaged goods"

A text that can be displayed to the Customer as a reason.

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

An optional key-value map with additional details

parent_return_reason_id
required
string or null
Example: null

The ID of the parent reason.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

value
required
string
Example: "damaged"

The value to identify the reason by.

parent_return_reason
object or null

The details of the parent reason.

return_reason_children
object

The details of the child reasons.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.returnReasons.retrieve(returnReasonId)
.then(({ return_reason }) => {
  console.log(return_reason.id);
});

Response samples

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

Update a Return Reason

Update a Return Reason's details.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Return Reason.

Request Body schema: application/json
label
string

The label to display to the Customer.

value
string

A unique value of the return reason.

description
string

The description of the Reason.

metadata
object

An optional set of key-value pairs with additional information.

Responses

Response Schema: application/json
required
object (Return Reason)

A Return Reason is a value defined by an admin. It can be used on Return Items in order to indicate why a Line Item was returned.

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.

description
required
string or null
Example: "Items that are damaged"

A description of the Reason.

id
required
string
Example: "rr_01G8X82GCCV2KSQHDBHSSAH5TQ"

The return reason's ID

label
required
string
Example: "Damaged goods"

A text that can be displayed to the Customer as a reason.

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

An optional key-value map with additional details

parent_return_reason_id
required
string or null
Example: null

The ID of the parent reason.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

value
required
string
Example: "damaged"

The value to identify the reason by.

parent_return_reason
object or null

The details of the parent reason.

return_reason_children
object

The details of the child reasons.

Request samples

Content type
application/json
{
  • "label": "string",
  • "value": "string",
  • "description": "string",
  • "metadata": { }
}

Response samples

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

Delete a Return Reason

Delete a return reason.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the return reason

Responses

Response Schema: application/json
id
required
string

The ID of the deleted return reason

object
required
string
Default: "return_reason"

The type of the object that was deleted.

deleted
required
boolean
Default: true

Whether or not the items were deleted.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.returnReasons.delete(returnReasonId)
.then(({ id, object, deleted }) => {
  console.log(id);
});

Response samples

Content type
application/json
{
  • "id": "string",
  • "object": "return_reason",
  • "deleted": true
}

Returns

A return can be created by a customer or an admin to return items in an order. Admins can manage these returns and change their state.

List Returns

Retrieve a list of Returns. The returns can be paginated.

Authorizations:
API TokenCookie Session ID
query Parameters
limit
number
Default: "50"

Limit the number of Returns returned.

offset
number
Default: "0"

The number of Returns to skip when retrieving the Returns.

Responses

Response Schema: application/json
required
Array of objects (Return)

An array of returns details.

count
required
integer

The total number of items available

offset
required
integer

The number of returns skipped when retrieving the returns.

limit
required
integer

The number of items per page

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.returns.list()
.then(({ returns, limit, offset, count }) => {
  console.log(returns.length);
});

Response samples

Content type
application/json
{
  • "returns": [
    ],
  • "count": 0,
  • "offset": 0,
  • "limit": 0
}

Cancel a Return

Registers a Return as canceled. The return can be associated with an order, claim, or swap.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Return.

Responses

Response Schema: application/json
required
object (Order)

An order is a purchase made by a customer. It holds details about payment and fulfillment of the order. An order may also be created from a draft order, which is created by an admin user.

billing_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The ID of the billing address associated with the order

canceled_at
required
string or null <date-time>

The date the order was canceled on.

cart_id
required
string or null
Example: "cart_01G8ZH853Y6TFXWPG5EYE81X63"

The ID of the cart associated with the order

created_at
required
string <date-time>

The date with timezone at which the resource was created.

currency_code
required
string
Example: "usd"

The 3 character currency code that is used in the order

customer_id
required
string
Example: "cus_01G2SG30J8C85S4A5CHM2S1NS2"

The ID of the customer associated with the order

draft_order_id
required
string or null
Example: null

The ID of the draft order this order was created from.

display_id
required
integer
Example: 2

The order's display ID

email
required
string <email>

The email associated with the order

external_id
required
string or null
Example: null

The ID of an external order.

fulfillment_status
required
string
Default: "not_fulfilled"
Enum: "not_fulfilled" "partially_fulfilled" "fulfilled" "partially_shipped" "shipped" "partially_returned" "returned" "canceled" "requires_action"

The order's fulfillment status

id
required
string
Example: "order_01G8TJSYT9M6AVS5N4EMNFS1EK"

The order's ID

idempotency_key
required
string or null

Randomly generated key used to continue the processing of the order in case of failure.

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

An optional key-value map with additional details

no_notification
required
boolean or null
Example: false

Flag for describing whether or not notifications related to this should be send.

payment_status
required
string
Default: "not_paid"
Enum: "not_paid" "awaiting" "captured" "partially_refunded" "refunded" "canceled" "requires_action"

The order's payment status

region_id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The ID of the region this order was created in.

shipping_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The ID of the shipping address associated with the order

status
required
string
Default: "pending"
Enum: "pending" "completed" "archived" "canceled" "requires_action"

The order's status

tax_rate
required
number or null
Example: 0

The order's tax rate

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

cart
object or null

The details of the cart associated with the order.

customer
object or null

The details of the customer associated with the order.

object (Address)

An address is used across the Medusa backend within other schemas and object types. For example, a customer's billing and shipping addresses both use the Address entity.

object (Address)

An address is used across the Medusa backend within other schemas and object types. For example, a customer's billing and shipping addresses both use the Address entity.

object (Region)

A region holds settings specific to a geographical location, including the currency, tax rates, and fulfillment and payment providers. A Region can consist of multiple countries to accomodate common shopping settings across countries.

object (Currency)

Currency

Array of objects (Discount)

The details of the discounts applied on the order.

Array of objects (Gift Card)

The details of the gift card used in the order.

Array of objects (Shipping Method)

The details of the shipping methods used in the order.

payments
Array of objects

The details of the payments used in the order.

fulfillments
Array of objects

The details of the fulfillments created for the order.

returns
Array of objects

The details of the returns created for the order.

claims
Array of objects

The details of the claims created for the order.

refunds
Array of objects

The details of the refunds created for the order.

swaps
Array of objects

The details of the swaps created for the order.

draft_order
object or null

The details of the draft order this order was created from.

Array of objects (Line Item)

The details of the line items that belong to the order.

edits
Array of objects

The details of the order edits done on the order.

Array of objects (Gift Card Transaction)

The gift card transactions made in the order.

sales_channel_id
string or null
Example: null

The ID of the sales channel this order belongs to.

object (Sales Channel)

A Sales Channel is a method a business offers its products for purchase for the customers. For example, a Webshop can be a sales channel, and a mobile app can be another.

shipping_total
integer
Example: 1000

The total of shipping

raw_discount_total
integer
Example: 800

The total of discount

discount_total
integer
Example: 800

The total of discount rounded

tax_total
integer
Example: 0

The total of tax

refunded_total
integer
Example: 0

The total amount refunded if the order is returned.

total
integer
Example: 8200

The total amount of the order

subtotal
integer
Example: 8000

The subtotal of the order

paid_total
integer
Example: 8000

The total amount paid

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

Array of objects (Line Item)

The details of the line items that are returnable as part of the order, swaps, or claims

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.returns.cancel(returnId)
.then(({ order }) => {
  console.log(order.id);
});

Response samples

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

Receive a Return

Mark a Return as received. This also updates the status of associated order, claim, or swap accordingly.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Return.

Request Body schema: application/json
required
Array of objects

The Line Items that have been received.

refund
number

The amount to refund.

Responses

Response Schema: application/json
required
object (Return)

A Return holds information about Line Items that a Customer wishes to send back, along with how the items will be returned. Returns can also be used as part of a Swap or a Claim.

claim_order_id
required
string or null
Example: null

The ID of the claim that the return may belong to.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

id
required
string
Example: "ret_01F0YET7XPCMF8RZ0Y151NZV2V"

The return's ID

idempotency_key
required
string or null

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

location_id
required
string or null
Example: "sloc_01G8TJSYT9M6AVS5N4EMNFS1EK"

The ID of the stock location the return will be added back.

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

An optional key-value map with additional details

no_notification
required
boolean or null
Example: false

When set to true, no notification will be sent related to this return.

order_id
required
string or null
Example: "order_01G8TJSYT9M6AVS5N4EMNFS1EK"

The ID of the order that the return was created for.

received_at
required
string or null <date-time>

The date with timezone at which the return was received.

refund_amount
required
integer
Example: 1000

The amount that should be refunded as a result of the return.

shipping_data
required
object or null
Example: {}

Data about the return shipment as provided by the Fulfilment Provider that handles the return shipment.

status
required
string
Default: "requested"
Enum: "requested" "received" "requires_action" "canceled"

Status of the Return.

swap_id
required
string or null
Example: null

The ID of the swap that the return may belong to.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

Array of objects (Return Item)

The details of the items that the customer is returning.

swap
object or null

The details of the swap that the return may belong to.

claim_order
object or null

The details of the claim that the return may belong to.

order
object or null

The details of the order that the return was created for.

object (Shipping Method)

A Shipping Method represents a way in which an Order or Return can be shipped. Shipping Methods are created from a Shipping Option, but may contain additional details that can be necessary for the Fulfillment Provider to handle the shipment. If the shipping method is created for a return, it may be associated with a claim or a swap that the return is part of.

Request samples

Content type
application/json
{
  • "items": [
    ],
  • "refund": 0
}

Response samples

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

Sales Channels

A sales channel indicates a channel where products can be sold in. For example, a webshop or a mobile app. Admins can manage sales channels and the products available in them.

List Sales Channels

Retrieve a list of sales channels. The sales channels can be filtered by fields such as q or name. The sales channels can also be sorted or paginated.

Authorizations:
API TokenCookie Session ID
query Parameters
id
string

Filter by a sales channel ID.

name
string

Filter by name.

description
string

Filter by description.

q
string

term used to search sales channels' names and descriptions.

order
string

A sales-channel field to sort-order the retrieved sales channels by.

object

Filter by a creation date range.

object

Filter by an update date range.

object

Filter by a deletion date range.

offset
integer
Default: 0

The number of sales channels to skip when retrieving the sales channels.

limit
integer
Default: 20

Limit the number of sales channels returned.

expand
string

Comma-separated relations that should be expanded in the returned sales channels.

fields
string

Comma-separated fields that should be included in the returned sales channels.

Responses

Response Schema: application/json
required
Array of objects (Sales Channel)

An array of sales channels details.

count
required
integer

The total number of items available

offset
required
integer

The number of items skipped before the returned results

limit
required
integer

The number of items per page

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.salesChannels.list()
.then(({ sales_channels, limit, offset, count }) => {
  console.log(sales_channels.length);
});

Response samples

Content type
application/json
{
  • "sales_channels": [
    ],
  • "count": 0,
  • "offset": 0,
  • "limit": 0
}

Create a Sales Channel

Create a Sales Channel.

Authorizations:
API TokenCookie Session ID
Request Body schema: application/json
name
required
string

The name of the Sales Channel

description
string

The description of the Sales Channel

is_disabled
boolean

Whether the Sales Channel is disabled.

Responses

Response Schema: application/json
required
object (Sales Channel)

A Sales Channel is a method a business offers its products for purchase for the customers. For example, a Webshop can be a sales channel, and a mobile app can be another.

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.

description
required
string or null
Example: "Multi-vendor market"

The description of the sales channel.

id
required
string
Example: "sc_01G8X9A7ESKAJXG2H0E6F1MW7A"

The sales channel's ID

is_disabled
required
boolean
Default: false

Specify if the sales channel is enabled or disabled.

name
required
string
Example: "Market"

The name of the sales channel.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

Array of objects (Sales Channel Stock Location)

The details of the stock locations related to the sales channel.

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

An optional key-value map with additional details

Request samples

Content type
application/json
{
  • "name": "string",
  • "description": "string",
  • "is_disabled": true
}

Response samples

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

Get a Sales Channel

Retrieve a sales channel's details.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Sales channel.

Responses

Response Schema: application/json
required
object (Sales Channel)

A Sales Channel is a method a business offers its products for purchase for the customers. For example, a Webshop can be a sales channel, and a mobile app can be another.

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.

description
required
string or null
Example: "Multi-vendor market"

The description of the sales channel.

id
required
string
Example: "sc_01G8X9A7ESKAJXG2H0E6F1MW7A"

The sales channel's ID

is_disabled
required
boolean
Default: false

Specify if the sales channel is enabled or disabled.

name
required
string
Example: "Market"

The name of the sales channel.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

Array of objects (Sales Channel Stock Location)

The details of the stock locations related to the sales channel.

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

An optional key-value map with additional details

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.salesChannels.retrieve(salesChannelId)
.then(({ sales_channel }) => {
  console.log(sales_channel.id);
});

Response samples

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

Update a Sales Channel

Update a Sales Channel's details.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Sales Channel.

Request Body schema: application/json
name
string

The name of the sales channel

description
string

The description of the sales channel.

is_disabled
boolean

Whether the Sales Channel is disabled.

Responses

Response Schema: application/json
required
object (Sales Channel)

A Sales Channel is a method a business offers its products for purchase for the customers. For example, a Webshop can be a sales channel, and a mobile app can be another.

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.

description
required
string or null
Example: "Multi-vendor market"

The description of the sales channel.

id
required
string
Example: "sc_01G8X9A7ESKAJXG2H0E6F1MW7A"

The sales channel's ID

is_disabled
required
boolean
Default: false

Specify if the sales channel is enabled or disabled.

name
required
string
Example: "Market"

The name of the sales channel.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

Array of objects (Sales Channel Stock Location)

The details of the stock locations related to the sales channel.

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

An optional key-value map with additional details

Request samples

Content type
application/json
{
  • "name": "string",
  • "description": "string",
  • "is_disabled": true
}

Response samples

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

Delete a Sales Channel

Delete a sales channel. Associated products, stock locations, and other resources are not deleted.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Sales channel.

Responses

Response Schema: application/json
id
required
string

The ID of the deleted sales channel

object
required
string
Default: "sales-channel"

The type of the object that was deleted.

deleted
required
boolean
Default: true

Whether or not the items were deleted.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.salesChannels.delete(salesChannelId)
.then(({ id, object, deleted }) => {
  console.log(id);
});

Response samples

Content type
application/json
{
  • "id": "string",
  • "object": "sales-channel",
  • "deleted": true
}

Add Products to Sales Channel

Add a list of products to a sales channel.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Sales channel.

Request Body schema: application/json
required
Array of objects

The IDs of the products to add to the Sales Channel

Array
id
required
string

The ID of the product

Responses

Response Schema: application/json
required
object (Sales Channel)

A Sales Channel is a method a business offers its products for purchase for the customers. For example, a Webshop can be a sales channel, and a mobile app can be another.

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.

description
required
string or null
Example: "Multi-vendor market"

The description of the sales channel.

id
required
string
Example: "sc_01G8X9A7ESKAJXG2H0E6F1MW7A"

The sales channel's ID

is_disabled
required
boolean
Default: false

Specify if the sales channel is enabled or disabled.

name
required
string
Example: "Market"

The name of the sales channel.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

Array of objects (Sales Channel Stock Location)

The details of the stock locations related to the sales channel.

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

An optional key-value map with additional details

Request samples

Content type
application/json
{
  • "product_ids": [
    ]
}

Response samples

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

Remove Products from Sales Channel

Remove a list of products from a sales channel. This does not delete the product. It only removes the association between the product and the sales channel.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Sales Channel

Request Body schema: application/json
required
Array of objects

The IDs of the products to remove from the Sales Channel.

Array
id
required
string

The ID of a product

Responses

Response Schema: application/json
required
object (Sales Channel)

A Sales Channel is a method a business offers its products for purchase for the customers. For example, a Webshop can be a sales channel, and a mobile app can be another.

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.

description
required
string or null
Example: "Multi-vendor market"

The description of the sales channel.

id
required
string
Example: "sc_01G8X9A7ESKAJXG2H0E6F1MW7A"

The sales channel's ID

is_disabled
required
boolean
Default: false

Specify if the sales channel is enabled or disabled.

name
required
string
Example: "Market"

The name of the sales channel.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

Array of objects (Sales Channel Stock Location)

The details of the stock locations related to the sales channel.

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

An optional key-value map with additional details

Request samples

Content type
application/json
{
  • "product_ids": [
    ]
}

Response samples

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

Associate a Stock Location

Associate a stock location with a Sales Channel.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Sales Channel.

Request Body schema: application/json
location_id
required
string

The ID of the stock location

Responses

Response Schema: application/json
required
object (Sales Channel)

A Sales Channel is a method a business offers its products for purchase for the customers. For example, a Webshop can be a sales channel, and a mobile app can be another.

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.

description
required
string or null
Example: "Multi-vendor market"

The description of the sales channel.

id
required
string
Example: "sc_01G8X9A7ESKAJXG2H0E6F1MW7A"

The sales channel's ID

is_disabled
required
boolean
Default: false

Specify if the sales channel is enabled or disabled.

name
required
string
Example: "Market"

The name of the sales channel.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

Array of objects (Sales Channel Stock Location)

The details of the stock locations related to the sales channel.

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

An optional key-value map with additional details

Request samples

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

Response samples

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

Remove Stock Location from Sales Channels.

Remove a stock location from a Sales Channel. This only removes the association between the stock location and the sales channel. It does not delete the stock location.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Sales Channel.

Request Body schema: application/json
location_id
required
string

The ID of the stock location

Responses

Response Schema: application/json
id
required
string

The ID of the removed stock location from a sales channel

object
required
string
Default: "stock-location"

The type of the object that was removed.

deleted
required
boolean
Default: true

Whether or not the items were deleted.

Request samples

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

Response samples

Content type
application/json
{
  • "id": "string",
  • "object": "stock-location",
  • "deleted": true
}

Shipping Options

A shipping option is used to define the available shipping methods during checkout or when creating a return. Admins can create an unlimited number of shipping options, each associated with a shipping profile and fulfillment provider, among other resources.

List Shipping Options

Retrieve a list of Shipping Options. The shipping options can be filtered by fields such as region_id or is_return.

Authorizations:
API TokenCookie Session ID
query Parameters
region_id
string

Filter by a region ID.

is_return
boolean

Filter by whether the shipping option is used for returns or orders.

admin_only
boolean

Filter by whether the shipping option is used only by admins or not.

Responses

Response Schema: application/json
required
Array of objects (Shipping Option)

An array of shipping options details.

count
required
integer

The total number of items available

offset
required
integer

The number of shipping options skipped when retrieving the shipping options.

limit
required
integer

The number of items per page

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.shippingOptions.list()
.then(({ shipping_options, count }) => {
  console.log(shipping_options.length);
});

Response samples

Content type
application/json
{
  • "shipping_options": [
    ],
  • "count": 0,
  • "offset": 0,
  • "limit": 0
}

Create Shipping Option

Create a Shipping Option.

Authorizations:
API TokenCookie Session ID
Request Body schema: application/json
name
required
string

The name of the Shipping Option

region_id
required
string

The ID of the Region in which the Shipping Option will be available.

provider_id
required
string

The ID of the Fulfillment Provider that handles the Shipping Option.

data
required
object

The data needed for the Fulfillment Provider to handle shipping with this Shipping Option.

price_type
required
string
Enum: "flat_rate" "calculated"

The type of the Shipping Option price. flat_rate indicates fixed pricing, whereas calculated indicates that the price will be calculated each time by the fulfillment provider.

profile_id
number

The ID of the Shipping Profile to add the Shipping Option to.

amount
integer

The amount to charge for the Shipping Option. If the price_type is set to calculated, this amount will not actually be used.

Array of objects

The requirements that must be satisfied for the Shipping Option to be available.

is_return
boolean
Default: false

Whether the Shipping Option can be used for returns or during checkout.

admin_only
boolean
Default: false

If set to true, the shipping option can only be used when creating draft orders.

metadata
object

An optional set of key-value pairs with additional information.

includes_tax
boolean

Tax included in prices of shipping option

Responses

Response Schema: application/json
required
object (Shipping Option)

A Shipping Option represents a way in which an Order or Return can be shipped. Shipping Options have an associated Fulfillment Provider that will be used when the fulfillment of an Order is initiated. Shipping Options themselves cannot be added to Carts, but serve as a template for Shipping Methods. This distinction makes it possible to customize individual Shipping Methods with additional information.

admin_only
required
boolean
Default: false

Flag to indicate if the Shipping Option usage is restricted to admin users.

amount
required
integer or null
Example: 200

The amount to charge for shipping when the Shipping Option price type is flat_rate.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

data
required
object
Example: {}

The data needed for the Fulfillment Provider to identify the Shipping Option.

deleted_at
required
string or null <date-time>

The date with timezone at which the resource was deleted.

id
required
string
Example: "so_01G1G5V27GYX4QXNARRQCW1N8T"

The shipping option's ID

is_return
required
boolean
Default: false

Flag to indicate if the Shipping Option can be used for Return shipments.

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

An optional key-value map with additional details

name
required
string
Example: "PostFake Standard"

The name given to the Shipping Option - this may be displayed to the Customer.

price_type
required
string
Enum: "flat_rate" "calculated"
Example: "flat_rate"

The type of pricing calculation that is used when creatin Shipping Methods from the Shipping Option. Can be flat_rate for fixed prices or calculated if the Fulfillment Provider can provide price calulations.

profile_id
required
string
Example: "sp_01G1G5V239ENSZ5MV4JAR737BM"

The ID of the Shipping Profile that the shipping option belongs to.

provider_id
required
string
Example: "manual"

The ID of the fulfillment provider that will be used to later to process the shipping method created from this shipping option and its fulfillments.

region_id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The ID of the region this shipping option can be used in.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

region
object or null

The details of the region this shipping option can be used in.

object (Shipping Profile)

A Shipping Profile has a set of defined Shipping Options that can be used to fulfill a given set of Products. For example, gift cards are shipped differently than physical products, so a shipping profile with the type gift_card groups together the shipping options that can only be used for gift cards.

object (Fulfillment Provider)

A fulfillment provider represents a fulfillment service installed in the Medusa backend, either through a plugin or backend customizations. It holds the fulfillment service's installation status.

Array of objects (Shipping Option Requirement)

The details of the requirements that must be satisfied for the Shipping Option to be available for usage in a Cart.

includes_tax
boolean
Default: false

Whether the shipping option price include tax

Request samples

Content type
application/json
{
  • "name": "string",
  • "region_id": "string",
  • "provider_id": "string",
  • "profile_id": 0,
  • "data": { },
  • "price_type": "flat_rate",
  • "amount": 0,
  • "requirements": [
    ],
  • "is_return": false,
  • "admin_only": false,
  • "metadata": { },
  • "includes_tax": true
}

Response samples

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

Get a Shipping Option

Retrieve a Shipping Option's details.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Shipping Option.

Responses

Response Schema: application/json
required
object (Shipping Option)

A Shipping Option represents a way in which an Order or Return can be shipped. Shipping Options have an associated Fulfillment Provider that will be used when the fulfillment of an Order is initiated. Shipping Options themselves cannot be added to Carts, but serve as a template for Shipping Methods. This distinction makes it possible to customize individual Shipping Methods with additional information.

admin_only
required
boolean
Default: false

Flag to indicate if the Shipping Option usage is restricted to admin users.

amount
required
integer or null
Example: 200

The amount to charge for shipping when the Shipping Option price type is flat_rate.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

data
required
object
Example: {}

The data needed for the Fulfillment Provider to identify the Shipping Option.

deleted_at
required
string or null <date-time>

The date with timezone at which the resource was deleted.

id
required
string
Example: "so_01G1G5V27GYX4QXNARRQCW1N8T"

The shipping option's ID

is_return
required
boolean
Default: false

Flag to indicate if the Shipping Option can be used for Return shipments.

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

An optional key-value map with additional details

name
required
string
Example: "PostFake Standard"

The name given to the Shipping Option - this may be displayed to the Customer.

price_type
required
string
Enum: "flat_rate" "calculated"
Example: "flat_rate"

The type of pricing calculation that is used when creatin Shipping Methods from the Shipping Option. Can be flat_rate for fixed prices or calculated if the Fulfillment Provider can provide price calulations.

profile_id
required
string
Example: "sp_01G1G5V239ENSZ5MV4JAR737BM"

The ID of the Shipping Profile that the shipping option belongs to.

provider_id
required
string
Example: "manual"

The ID of the fulfillment provider that will be used to later to process the shipping method created from this shipping option and its fulfillments.

region_id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The ID of the region this shipping option can be used in.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

region
object or null

The details of the region this shipping option can be used in.

object (Shipping Profile)

A Shipping Profile has a set of defined Shipping Options that can be used to fulfill a given set of Products. For example, gift cards are shipped differently than physical products, so a shipping profile with the type gift_card groups together the shipping options that can only be used for gift cards.

object (Fulfillment Provider)

A fulfillment provider represents a fulfillment service installed in the Medusa backend, either through a plugin or backend customizations. It holds the fulfillment service's installation status.

Array of objects (Shipping Option Requirement)

The details of the requirements that must be satisfied for the Shipping Option to be available for usage in a Cart.

includes_tax
boolean
Default: false

Whether the shipping option price include tax

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.shippingOptions.retrieve(optionId)
.then(({ shipping_option }) => {
  console.log(shipping_option.id);
});

Response samples

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

Update Shipping Option

Update a Shipping Option's details.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Shipping Option.

Request Body schema: application/json
required
Array of objects

The requirements that must be satisfied for the Shipping Option to be available.

name
string

The name of the Shipping Option

amount
integer

The amount to charge for the Shipping Option. If the price_type of the shipping option is calculated, this amount will not actually be used.

admin_only
boolean

If set to true, the shipping option can only be used when creating draft orders.

metadata
object

An optional set of key-value pairs with additional information.

includes_tax
boolean

Tax included in prices of shipping option

Responses

Response Schema: application/json
required
object (Shipping Option)

A Shipping Option represents a way in which an Order or Return can be shipped. Shipping Options have an associated Fulfillment Provider that will be used when the fulfillment of an Order is initiated. Shipping Options themselves cannot be added to Carts, but serve as a template for Shipping Methods. This distinction makes it possible to customize individual Shipping Methods with additional information.

admin_only
required
boolean
Default: false

Flag to indicate if the Shipping Option usage is restricted to admin users.

amount
required
integer or null
Example: 200

The amount to charge for shipping when the Shipping Option price type is flat_rate.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

data
required
object
Example: {}

The data needed for the Fulfillment Provider to identify the Shipping Option.

deleted_at
required
string or null <date-time>

The date with timezone at which the resource was deleted.

id
required
string
Example: "so_01G1G5V27GYX4QXNARRQCW1N8T"

The shipping option's ID

is_return
required
boolean
Default: false

Flag to indicate if the Shipping Option can be used for Return shipments.

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

An optional key-value map with additional details

name
required
string
Example: "PostFake Standard"

The name given to the Shipping Option - this may be displayed to the Customer.

price_type
required
string
Enum: "flat_rate" "calculated"
Example: "flat_rate"

The type of pricing calculation that is used when creatin Shipping Methods from the Shipping Option. Can be flat_rate for fixed prices or calculated if the Fulfillment Provider can provide price calulations.

profile_id
required
string
Example: "sp_01G1G5V239ENSZ5MV4JAR737BM"

The ID of the Shipping Profile that the shipping option belongs to.

provider_id
required
string
Example: "manual"

The ID of the fulfillment provider that will be used to later to process the shipping method created from this shipping option and its fulfillments.

region_id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The ID of the region this shipping option can be used in.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

region
object or null

The details of the region this shipping option can be used in.

object (Shipping Profile)

A Shipping Profile has a set of defined Shipping Options that can be used to fulfill a given set of Products. For example, gift cards are shipped differently than physical products, so a shipping profile with the type gift_card groups together the shipping options that can only be used for gift cards.

object (Fulfillment Provider)

A fulfillment provider represents a fulfillment service installed in the Medusa backend, either through a plugin or backend customizations. It holds the fulfillment service's installation status.

Array of objects (Shipping Option Requirement)

The details of the requirements that must be satisfied for the Shipping Option to be available for usage in a Cart.

includes_tax
boolean
Default: false

Whether the shipping option price include tax

Request samples

Content type
application/json
{
  • "name": "string",
  • "amount": 0,
  • "admin_only": true,
  • "metadata": { },
  • "requirements": [
    ],
  • "includes_tax": true
}

Response samples

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

Delete Shipping Option

Delete a Shipping Option. Once deleted, it can't be used when creating orders or returns.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Shipping Option.

Responses

Response Schema: application/json
id
required
string

The ID of the deleted Shipping Option.

object
required
string
Default: "shipping-option"

The type of the object that was deleted.

deleted
required
boolean
Default: true

Whether or not the items were deleted.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.shippingOptions.delete(optionId)
.then(({ id, object, deleted }) => {
  console.log(id);
});

Response samples

Content type
application/json
{
  • "id": "string",
  • "object": "shipping-option",
  • "deleted": true
}

Shipping Profiles

A shipping profile is used to group products that can be shipped in the same manner. They are created by the admin and they're not associated with a fulfillment provider.

List Shipping Profiles

Retrieve a list of Shipping Profiles.

Authorizations:
API TokenCookie Session ID

Responses

Response Schema: application/json
required
Array of objects (Shipping Profile)

An array of shipping profiles details.

Array
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.

id
required
string
Example: "sp_01G1G5V239ENSZ5MV4JAR737BM"

The shipping profile's ID

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

An optional key-value map with additional details

name
required
string
Example: "Default Shipping Profile"

The name given to the Shipping profile - this may be displayed to the Customer.

type
required
string
Enum: "default" "gift_card" "custom"
Example: "default"

The type of the Shipping Profile, may be default, gift_card or custom.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

products
Array of objects

The details of the products that the Shipping Profile defines Shipping Options for. Available if the relation products is expanded.

shipping_options
Array of objects

The details of the shipping options that can be used to create shipping methods for the Products in the Shipping Profile.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.shippingProfiles.list()
.then(({ shipping_profiles }) => {
  console.log(shipping_profiles.length);
});

Response samples

Content type
application/json
{
  • "shipping_profiles": [
    ]
}

Create a Shipping Profile

Create a Shipping Profile.

Authorizations:
API TokenCookie Session ID
Request Body schema: application/json
name
required
string

The name of the Shipping Profile

type
required
string
Enum: "default" "gift_card" "custom"

The type of the Shipping Profile

Responses

Response Schema: application/json
required
object (Shipping Profile)

A Shipping Profile has a set of defined Shipping Options that can be used to fulfill a given set of Products. For example, gift cards are shipped differently than physical products, so a shipping profile with the type gift_card groups together the shipping options that can only be used for gift cards.

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.

id
required
string
Example: "sp_01G1G5V239ENSZ5MV4JAR737BM"

The shipping profile's ID

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

An optional key-value map with additional details

name
required
string
Example: "Default Shipping Profile"

The name given to the Shipping profile - this may be displayed to the Customer.

type
required
string
Enum: "default" "gift_card" "custom"
Example: "default"

The type of the Shipping Profile, may be default, gift_card or custom.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

products
Array of objects

The details of the products that the Shipping Profile defines Shipping Options for. Available if the relation products is expanded.

shipping_options
Array of objects

The details of the shipping options that can be used to create shipping methods for the Products in the Shipping Profile.

Request samples

Content type
application/json
{
  • "name": "string",
  • "type": "default"
}

Response samples

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

Get a Shipping Profile

Retrieve a Shipping Profile's details.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Shipping Profile.

Responses

Response Schema: application/json
required
object (Shipping Profile)

A Shipping Profile has a set of defined Shipping Options that can be used to fulfill a given set of Products. For example, gift cards are shipped differently than physical products, so a shipping profile with the type gift_card groups together the shipping options that can only be used for gift cards.

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.

id
required
string
Example: "sp_01G1G5V239ENSZ5MV4JAR737BM"

The shipping profile's ID

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

An optional key-value map with additional details

name
required
string
Example: "Default Shipping Profile"

The name given to the Shipping profile - this may be displayed to the Customer.

type
required
string
Enum: "default" "gift_card" "custom"
Example: "default"

The type of the Shipping Profile, may be default, gift_card or custom.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

products
Array of objects

The details of the products that the Shipping Profile defines Shipping Options for. Available if the relation products is expanded.

shipping_options
Array of objects

The details of the shipping options that can be used to create shipping methods for the Products in the Shipping Profile.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.shippingProfiles.retrieve(profileId)
.then(({ shipping_profile }) => {
  console.log(shipping_profile.id);
});

Response samples

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

Update a Shipping Profile

Update a Shipping Profile's details.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Shipping Profile.

Request Body schema: application/json
name
string

The name of the Shipping Profile

metadata
object

An optional set of key-value pairs with additional information.

type
string
Enum: "default" "gift_card" "custom"

The type of the Shipping Profile

products
Array of arrays

product IDs to associate with the Shipping Profile

shipping_options
Array of arrays

Shipping option IDs to associate with the Shipping Profile

Responses

Response Schema: application/json
required
object (Shipping Profile)

A Shipping Profile has a set of defined Shipping Options that can be used to fulfill a given set of Products. For example, gift cards are shipped differently than physical products, so a shipping profile with the type gift_card groups together the shipping options that can only be used for gift cards.

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.

id
required
string
Example: "sp_01G1G5V239ENSZ5MV4JAR737BM"

The shipping profile's ID

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

An optional key-value map with additional details

name
required
string
Example: "Default Shipping Profile"

The name given to the Shipping profile - this may be displayed to the Customer.

type
required
string
Enum: "default" "gift_card" "custom"
Example: "default"

The type of the Shipping Profile, may be default, gift_card or custom.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

products
Array of objects

The details of the products that the Shipping Profile defines Shipping Options for. Available if the relation products is expanded.

shipping_options
Array of objects

The details of the shipping options that can be used to create shipping methods for the Products in the Shipping Profile.

Request samples

Content type
application/json
{
  • "name": "string",
  • "metadata": { },
  • "type": "default",
  • "products": [ ],
  • "shipping_options": [ ]
}

Response samples

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

Delete a Shipping Profile

Delete a Shipping Profile. Associated shipping options are deleted as well.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Shipping Profile.

Responses

Response Schema: application/json
id
required
string

The ID of the deleted Shipping Profile.

object
required
string
Default: "shipping_profile"

The type of the object that was deleted.

deleted
required
boolean
Default: true

Whether or not the items were deleted.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.shippingProfiles.delete(profileId)
.then(({ id, object, deleted }) => {
  console.log(id);
});

Response samples

Content type
application/json
{
  • "id": "string",
  • "object": "shipping_profile",
  • "deleted": true
}

Stock Locations

A stock location, provided by the Stock Location module, indicates a physical address that stock-kept items, such as physical products, can be stored in. An admin can create and manage available stock locations.

List Stock Locations

Retrieve a list of stock locations. The stock locations can be filtered by fields such as name or created_at. The stock locations can also be sorted or paginated.

Authorizations:
API TokenCookie Session ID
query Parameters
id
string

Filter by ID.

name
string

Filter by name.

order
string

A stock-location field to sort-order the retrieved stock locations by.

object

Filter by a creation date range.

object

Filter by an update date range.

object

Filter by a deletion date range.

offset
integer
Default: 0

The number of stock locations to skip when retrieving the stock locations.

limit
integer
Default: 20

Limit the number of stock locations returned.

expand
string

Comma-separated relations that should be expanded in the returned stock locations.

fields
string

Comma-separated fields that should be included in the returned stock locations.

Responses

Response Schema: application/json
required
Array of objects (StockLocationExpandedDTO)
count
required
integer

The total number of items available

offset
required
integer

The number of stock locations skipped when retrieving the stock locations.

limit
required
integer

The number of items per page

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.stockLocations.list()
.then(({ stock_locations, limit, offset, count }) => {
  console.log(stock_locations.length);
});

Response samples

Content type
application/json
{
  • "stock_locations": [
    ],
  • "count": 0,
  • "offset": 0,
  • "limit": 0
}

Create a Stock Location

Create a Stock Location.

Authorizations:
API TokenCookie Session ID
query Parameters
expand
string

Comma-separated relations that should be expanded in the returned stock location.

fields
string

Comma-separated fields that should be included in the returned stock location.

Request Body schema: application/json
name
required
string

the name of the stock location

address_id
string

the ID of an existing stock location address to associate with the stock location. Only required if address is not provided.

metadata
object
Example: {"car":"white"}

An optional key-value map with additional details

object (Stock Location Address Input)

Represents a Stock Location Address Input

Responses

Response Schema: application/json
required
object (StockLocationExpandedDTO)

Represents a Stock Location

id
required
string
Example: "sloc_51G4ZW853Y6TFXWPG5ENJ81X42"

The stock location's ID

name
required
string
Example: "Main Warehouse"

The name of the stock location

address_id
required
string
Example: "laddr_05B2ZE853Y6FTXWPW85NJ81A44"

Stock location address' ID

created_at
required
string <date-time>

The date with timezone at which the resource was created.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

object (Stock Location Address)

The Address of the Stock Location

metadata
object
Example: {"car":"white"}

An optional key-value map with additional details

deleted_at
string <date-time>

The date with timezone at which the resource was deleted.

object (Sales Channel)

A Sales Channel is a method a business offers its products for purchase for the customers. For example, a Webshop can be a sales channel, and a mobile app can be another.

Request samples

Content type
application/json
{
  • "name": "string",
  • "address_id": "string",
  • "metadata": {
    },
  • "address": {
    }
}

Response samples

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

Get a Stock Location

Retrieve a Stock Location's details.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Stock Location.

query Parameters
expand
string

Comma-separated relations that should be expanded in the returned stock location.

fields
string

Comma-separated fields that should be included in the returned stock location.

Responses

Response Schema: application/json
required
object (StockLocationExpandedDTO)

Represents a Stock Location

id
required
string
Example: "sloc_51G4ZW853Y6TFXWPG5ENJ81X42"

The stock location's ID

name
required
string
Example: "Main Warehouse"

The name of the stock location

address_id
required
string
Example: "laddr_05B2ZE853Y6FTXWPW85NJ81A44"

Stock location address' ID

created_at
required
string <date-time>

The date with timezone at which the resource was created.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

object (Stock Location Address)

The Address of the Stock Location

metadata
object
Example: {"car":"white"}

An optional key-value map with additional details

deleted_at
string <date-time>

The date with timezone at which the resource was deleted.

object (Sales Channel)

A Sales Channel is a method a business offers its products for purchase for the customers. For example, a Webshop can be a sales channel, and a mobile app can be another.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.stockLocations.retrieve(stockLocationId)
.then(({ stock_location }) => {
  console.log(stock_location.id);
});

Response samples

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

Update a Stock Location

Update a Stock Location's details.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Stock Location.

query Parameters
expand
string

Comma-separated relations that should be expanded in the returned stock location.

fields
string

Comma-separated fields that should be included in the returned stock location.

Request Body schema: application/json
name
string

the name of the stock location

address_id
string

the stock location address ID

metadata
object
Example: {"car":"white"}

An optional key-value map with additional details

object (Stock Location Address Input)

Represents a Stock Location Address Input

Responses

Response Schema: application/json
required
object (StockLocationExpandedDTO)

Represents a Stock Location

id
required
string
Example: "sloc_51G4ZW853Y6TFXWPG5ENJ81X42"

The stock location's ID

name
required
string
Example: "Main Warehouse"

The name of the stock location

address_id
required
string
Example: "laddr_05B2ZE853Y6FTXWPW85NJ81A44"

Stock location address' ID

created_at
required
string <date-time>

The date with timezone at which the resource was created.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

object (Stock Location Address)

The Address of the Stock Location

metadata
object
Example: {"car":"white"}

An optional key-value map with additional details

deleted_at
string <date-time>

The date with timezone at which the resource was deleted.

object (Sales Channel)

A Sales Channel is a method a business offers its products for purchase for the customers. For example, a Webshop can be a sales channel, and a mobile app can be another.

Request samples

Content type
application/json
{
  • "name": "string",
  • "address_id": "string",
  • "metadata": {
    },
  • "address": {
    }
}

Response samples

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

Delete a Stock Location

Delete a Stock Location.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Stock Location.

Responses

Response Schema: application/json
id
required
string

The ID of the deleted Stock Location.

object
required
string
Default: "stock_location"

The type of the object that was deleted.

deleted
required
boolean
Default: true

Whether or not the items were deleted.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.stockLocations.delete(stockLocationId)
.then(({ id, object, deleted }) => {
  console.log(id)
})

Response samples

Content type
application/json
{
  • "id": "string",
  • "object": "stock_location",
  • "deleted": true
}

Store

A store indicates the general configurations and details about the commerce store. By default, there's only one store in the Medusa backend. Admins can manage the store and its details or configurations.

Get Store details

Retrieve the Store's details.

Authorizations:
API TokenCookie Session ID

Responses

Response Schema: application/json
required
object (ExtendedStoreDTO)

A store holds the main settings of the commerce shop. By default, only one store is created and used within the Medusa backend. It holds settings related to the name of the store, available currencies, and more.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

default_currency_code
required
string
Example: "usd"

The 3 character currency code that is the default of the store.

default_location_id
required
string or null
Example: null

The location ID the store is associated with.

id
required
string
Example: "store_01G1G5V21KADXNGH29BJMAJ4B4"

The store's ID

invite_link_template
required
string or null
Example: null

A template to generate Invite links from

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

An optional key-value map with additional details

name
required
string
Example: "Medusa Store"

The name of the Store - this may be displayed to the Customer.

payment_link_template
required
string or null
Example: null

A template to generate Payment links from. Use {{cart_id}} to include the payment's cart_id in the link.

swap_link_template
required
string or null
Example: null

A template to generate Swap links from. Use {{cart_id}} to include the Swap's cart_id in the link.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

required
object (Payment Provider)

A payment provider represents a payment service installed in the Medusa backend, either through a plugin or backend customizations. It holds the payment service's installation status.

required
object (Fulfillment Provider)

A fulfillment provider represents a fulfillment service installed in the Medusa backend, either through a plugin or backend customizations. It holds the fulfillment service's installation status.

required
Array of objects (FeatureFlagsResponse)
required
Array of objects (ModulesResponse)
object (Currency)

Currency

Array of objects (Currency)

The details of the enabled currencies in the store.

default_sales_channel_id
string or null
Example: null

The ID of the store's default sales channel.

object (Sales Channel)

A Sales Channel is a method a business offers its products for purchase for the customers. For example, a Webshop can be a sales channel, and a mobile app can be another.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.store.retrieve()
.then(({ store }) => {
  console.log(store.id);
});

Response samples

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

Update Store Details

Update the Store's details.

Authorizations:
API TokenCookie Session ID
Request Body schema: application/json
name
string

The name of the Store

swap_link_template
string
Example: "http://example.com/swaps/{{cart_id}}"

A template for Swap links - use {{cart_id}} to insert the Swap Cart ID

payment_link_template
string
Example: "http://example.com/payments/{{cart_id}}"

A template for payment links - use {{cart_id}} to insert the Cart ID

invite_link_template
string
Example: "http://example.com/invite?token={{invite_token}}"

A template for invite links - use {{invite_token}} to insert the invite token

default_currency_code
string

The default currency code of the Store.

currencies
Array of strings

Array of available currencies in the store. Each currency is in 3 character ISO code format.

metadata
object

An optional set of key-value pairs with additional information.

Responses

Response Schema: application/json
required
object (Store)

A store holds the main settings of the commerce shop. By default, only one store is created and used within the Medusa backend. It holds settings related to the name of the store, available currencies, and more.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

default_currency_code
required
string
Example: "usd"

The 3 character currency code that is the default of the store.

default_location_id
required
string or null
Example: null

The location ID the store is associated with.

id
required
string
Example: "store_01G1G5V21KADXNGH29BJMAJ4B4"

The store's ID

invite_link_template
required
string or null
Example: null

A template to generate Invite links from

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

An optional key-value map with additional details

name
required
string
Example: "Medusa Store"

The name of the Store - this may be displayed to the Customer.

payment_link_template
required
string or null
Example: null

A template to generate Payment links from. Use {{cart_id}} to include the payment's cart_id in the link.

swap_link_template
required
string or null
Example: null

A template to generate Swap links from. Use {{cart_id}} to include the Swap's cart_id in the link.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

object (Currency)

Currency

Array of objects (Currency)

The details of the enabled currencies in the store.

default_sales_channel_id
string or null
Example: null

The ID of the store's default sales channel.

object (Sales Channel)

A Sales Channel is a method a business offers its products for purchase for the customers. For example, a Webshop can be a sales channel, and a mobile app can be another.

Request samples

Content type
application/json
{}

Response samples

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

Add a Currency Code

Add a Currency Code to the available currencies in a store. This does not create new currencies, as currencies are defined within the Medusa backend. To create a currency, you can create a migration that inserts the currency into the database.

Authorizations:
API TokenCookie Session ID
path Parameters
code
required
string

The 3 character ISO currency code.

Responses

Response Schema: application/json
required
object (Store)

A store holds the main settings of the commerce shop. By default, only one store is created and used within the Medusa backend. It holds settings related to the name of the store, available currencies, and more.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

default_currency_code
required
string
Example: "usd"

The 3 character currency code that is the default of the store.

default_location_id
required
string or null
Example: null

The location ID the store is associated with.

id
required
string
Example: "store_01G1G5V21KADXNGH29BJMAJ4B4"

The store's ID

invite_link_template
required
string or null
Example: null

A template to generate Invite links from

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

An optional key-value map with additional details

name
required
string
Example: "Medusa Store"

The name of the Store - this may be displayed to the Customer.

payment_link_template
required
string or null
Example: null

A template to generate Payment links from. Use {{cart_id}} to include the payment's cart_id in the link.

swap_link_template
required
string or null
Example: null

A template to generate Swap links from. Use {{cart_id}} to include the Swap's cart_id in the link.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

object (Currency)

Currency

Array of objects (Currency)

The details of the enabled currencies in the store.

default_sales_channel_id
string or null
Example: null

The ID of the store's default sales channel.

object (Sales Channel)

A Sales Channel is a method a business offers its products for purchase for the customers. For example, a Webshop can be a sales channel, and a mobile app can be another.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.store.addCurrency("eur")
.then(({ store }) => {
  console.log(store.currencies);
});

Response samples

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

Remove a Currency

Remove a Currency Code from the available currencies in a store. This does not completely delete the currency and it can be added again later to the store.

Authorizations:
API TokenCookie Session ID
path Parameters
code
required
string

The 3 character ISO currency code.

Responses

Response Schema: application/json
required
object (Store)

A store holds the main settings of the commerce shop. By default, only one store is created and used within the Medusa backend. It holds settings related to the name of the store, available currencies, and more.

created_at
required
string <date-time>

The date with timezone at which the resource was created.

default_currency_code
required
string
Example: "usd"

The 3 character currency code that is the default of the store.

default_location_id
required
string or null
Example: null

The location ID the store is associated with.

id
required
string
Example: "store_01G1G5V21KADXNGH29BJMAJ4B4"

The store's ID

invite_link_template
required
string or null
Example: null

A template to generate Invite links from

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

An optional key-value map with additional details

name
required
string
Example: "Medusa Store"

The name of the Store - this may be displayed to the Customer.

payment_link_template
required
string or null
Example: null

A template to generate Payment links from. Use {{cart_id}} to include the payment's cart_id in the link.

swap_link_template
required
string or null
Example: null

A template to generate Swap links from. Use {{cart_id}} to include the Swap's cart_id in the link.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

object (Currency)

Currency

Array of objects (Currency)

The details of the enabled currencies in the store.

default_sales_channel_id
string or null
Example: null

The ID of the store's default sales channel.

object (Sales Channel)

A Sales Channel is a method a business offers its products for purchase for the customers. For example, a Webshop can be a sales channel, and a mobile app can be another.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.store.deleteCurrency("eur")
.then(({ store }) => {
  console.log(store.currencies);
});

Response samples

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

List Payment Providers

Retrieve a list of available Payment Providers in a store.

Authorizations:
API TokenCookie Session ID

Responses

Response Schema: application/json
required
Array of objects (Payment Provider)

An array of payment providers details.

Array
id
required
string
Example: "manual"

The ID of the payment provider as given by the payment service.

is_installed
required
boolean
Default: true

Whether the payment service is installed in the current version. If a payment service is no longer installed, the is_installed attribute is set to false.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.store.listPaymentProviders()
.then(({ payment_providers }) => {
  console.log(payment_providers.length);
});

Response samples

Content type
application/json
{
  • "payment_providers": [
    ]
}

List Tax Providers

Retrieve a list of available Tax Providers in a store.

Authorizations:
API TokenCookie Session ID

Responses

Response Schema: application/json
required
Array of objects (Tax Provider)

An array of tax providers details.

Array
id
required
string
Example: "manual"

The ID of the tax provider as given by the tax service.

is_installed
required
boolean
Default: true

Whether the tax service is installed in the current version. If a tax service is no longer installed, the is_installed attribute is set to false.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.store.listTaxProviders()
.then(({ tax_providers }) => {
  console.log(tax_providers.length);
});

Response samples

Content type
application/json
{
  • "tax_providers": [
    ]
}

Swaps

A swap is created by a customer or an admin to exchange an item with a new one. Creating a swap implicitely includes creating a return for the item being exchanged.

List Swaps

Retrieve a list of Swaps. The swaps can be paginated.

Authorizations:
API TokenCookie Session ID
query Parameters
limit
number
Default: "50"

Limit the number of swaps returned.

offset
number
Default: "0"

The number of swaps to skip when retrieving the swaps.

Responses

Response Schema: application/json
required
Array of objects (Swap)

An array of swaps details.

count
required
integer

The total number of items available

offset
required
integer

The number of swaps skipped when retrieving the swaps.

limit
required
integer

The number of items per page

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.swaps.list()
.then(({ swaps }) => {
  console.log(swaps.length);
});

Response samples

Content type
application/json
{
  • "swaps": [
    ],
  • "count": 0,
  • "offset": 0,
  • "limit": 0
}

Get a Swap

Retrieve a Swap's details.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Swap.

Responses

Response Schema: application/json
required
object (Swap)

A swap can be created when a Customer wishes to exchange Products that they have purchased with different Products. It consists of a Return of previously purchased Products and a Fulfillment of new Products. It also includes information on any additional payment or refund required based on the difference between the exchanged products.

allow_backorder
required
boolean
Default: false

If true, swaps can be completed with items out of stock

canceled_at
required
string or null <date-time>

The date with timezone at which the Swap was canceled.

cart_id
required
string or null
Example: "cart_01G8ZH853Y6TFXWPG5EYE81X63"

The ID of the cart that the customer uses to complete the swap.

confirmed_at
required
string or null <date-time>

The date with timezone at which the Swap was confirmed by the Customer.

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.

difference_due
required
integer or null
Example: 0

The difference amount between the order’s original total and the new total imposed by the swap. If its value is negative, a refund must be issues to the customer. If it's positive, additional payment must be authorized by the customer. Otherwise, no payment processing is required.

fulfillment_status
required
string
Enum: "not_fulfilled" "fulfilled" "shipped" "partially_shipped" "canceled" "requires_action"
Example: "not_fulfilled"

The status of the Fulfillment of the Swap.

id
required
string
Example: "swap_01F0YET86Y9G92D3YDR9Y6V676"

The swap's ID

idempotency_key
required
string or null

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

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

An optional key-value map with additional details

no_notification
required
boolean or null
Example: false

If set to true, no notification will be sent related to this swap

order_id
required
string
Example: "order_01G8TJSYT9M6AVS5N4EMNFS1EK"

The ID of the order that the swap belongs to.

payment_status
required
string
Enum: "not_paid" "awaiting" "captured" "confirmed" "canceled" "difference_refunded" "partially_refunded" "refunded" "requires_action"
Example: "not_paid"

The status of the Payment of the Swap. The payment may either refer to the refund of an amount or the authorization of a new amount.

shipping_address_id
required
string or null
Example: "addr_01G8ZH853YPY9B94857DY91YGW"

The Address to send the new Line Items to - in most cases this will be the same as the shipping address on the Order.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

order
object or null

The details of the order that the swap belongs to.

Array of objects (Line Item)

The details of the new products to send to the customer, represented as line items.

return_order
object or null

The details of the return that belongs to the swap, which holds the details on the items being returned.

fulfillments
Array of objects

The details of the fulfillments that are used to send the new items to the customer.

payment
object or null

The details of the additional payment authorized by the customer when difference_due is positive.

object (Address)

An address is used across the Medusa backend within other schemas and object types. For example, a customer's billing and shipping addresses both use the Address entity.

Array of objects (Shipping Method)

The details of the shipping methods used to fulfill the additional items purchased.

cart
object or null

The details of the cart that the customer uses to complete the swap.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.swaps.retrieve(swapId)
.then(({ swap }) => {
  console.log(swap.id);
});

Response samples

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

Tax Rates

Each region has at least a default tax rate. Admins can create and manage additional tax rates that can be applied for certain conditions, such as for specific product types.

List Tax Rates

Retrieve a list of Tax Rates. The tax rates can be filtered by fields such as name or rate. The tax rates can also be paginated.

Authorizations:
API TokenCookie Session ID
query Parameters
name
string

Filter by name.

string or Array of strings

Filter by Region IDs

code
string

Filter by code.

number or object

Filter by Rate

offset
integer
Default: 0

The number of tax rates to skip when retrieving the tax rates.

limit
integer
Default: 50

Limit the number of tax rates returned.

fields
Array of strings

Comma-separated fields that should be included in the returned tax rate.

expand
Array of strings

Comma-separated relations that should be expanded in the returned tax rate.

Responses

Response Schema: application/json
required
Array of objects (Tax Rate)

An array of tax rate details.

count
required
integer

The total number of items available

offset
required
integer

The number of tax rates to skip when retrieving the tax rates.

limit
required
integer

The number of items per page

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.taxRates.list()
.then(({ tax_rates, limit, offset, count }) => {
  console.log(tax_rates.length);
});

Response samples

Content type
application/json
{
  • "tax_rates": [
    ],
  • "count": 0,
  • "offset": 0,
  • "limit": 0
}

Create a Tax Rate

Create a Tax Rate.

Authorizations:
API TokenCookie Session ID
query Parameters
fields
Array of strings

Comma-separated fields that should be included in the returned tax rate.

expand
Array of strings

Comma-separated relations that should be expanded in the returned tax rate.

Request Body schema: application/json
code
required
string

The code of the tax rate.

name
required
string

The name of the tax rate.

region_id
required
string

The ID of the Region that the tax rate belongs to.

rate
number

The numeric rate to charge.

products
Array of strings

The IDs of the products associated with this tax rate.

shipping_options
Array of strings

The IDs of the shipping options associated with this tax rate

product_types
Array of strings

The IDs of the types of products associated with this tax rate

Responses

Response Schema: application/json
required
object (Tax Rate)

A Tax Rate can be used to define a custom rate to charge on specified products, product types, and shipping options within a given region.

code
required
string or null
Example: "tax01"

A code to identify the tax type by

created_at
required
string <date-time>

The date with timezone at which the resource was created.

id
required
string
Example: "txr_01G8XDBAWKBHHJRKH0AV02KXBR"

The tax rate's ID

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

An optional key-value map with additional details

name
required
string
Example: "Tax Example"

A human friendly name for the tax

rate
required
number or null
Example: 10

The numeric rate to charge

region_id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The ID of the region that the rate belongs to.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

region
object or null

The details of the region that the rate belongs to.

Array of objects (Product)

The details of the products that belong to this tax rate.

Array of objects (Product Type)

The details of the product types that belong to this tax rate.

Array of objects (Shipping Option)

The details of the shipping options that belong to this tax rate.

product_count
integer
Example: 10

The count of products

product_type_count
integer
Example: 2

The count of product types

shipping_option_count
integer
Example: 1

The count of shipping options

Request samples

Content type
application/json
{
  • "code": "string",
  • "name": "string",
  • "region_id": "string",
  • "rate": 0,
  • "products": [
    ],
  • "shipping_options": [
    ],
  • "product_types": [
    ]
}

Response samples

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

Get a Tax Rate

Retrieve a Tax Rate's details.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

ID of the tax rate.

query Parameters
fields
Array of strings

Comma-separated fields that should be included in the returned tax rate.

expand
Array of strings

Comma-separated relations that should be expanded in the returned tax rate.

Responses

Response Schema: application/json
required
object (Tax Rate)

A Tax Rate can be used to define a custom rate to charge on specified products, product types, and shipping options within a given region.

code
required
string or null
Example: "tax01"

A code to identify the tax type by

created_at
required
string <date-time>

The date with timezone at which the resource was created.

id
required
string
Example: "txr_01G8XDBAWKBHHJRKH0AV02KXBR"

The tax rate's ID

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

An optional key-value map with additional details

name
required
string
Example: "Tax Example"

A human friendly name for the tax

rate
required
number or null
Example: 10

The numeric rate to charge

region_id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The ID of the region that the rate belongs to.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

region
object or null

The details of the region that the rate belongs to.

Array of objects (Product)

The details of the products that belong to this tax rate.

Array of objects (Product Type)

The details of the product types that belong to this tax rate.

Array of objects (Shipping Option)

The details of the shipping options that belong to this tax rate.

product_count
integer
Example: 10

The count of products

product_type_count
integer
Example: 2

The count of product types

shipping_option_count
integer
Example: 1

The count of shipping options

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.taxRates.retrieve(taxRateId)
.then(({ tax_rate }) => {
  console.log(tax_rate.id);
});

Response samples

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

Update a Tax Rate

Update a Tax Rate's details.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

ID of the tax rate.

query Parameters
fields
Array of strings

Comma-separated fields that should be included in the returned tax rate.

expand
Array of strings

Comma-separated relations that should be expanded in the returned tax rate.

Request Body schema: application/json
code
string

The code of the tax rate.

name
string

The name of the tax rate.

region_id
string

The ID of the Region that the tax rate belongs to.

rate
number

The numeric rate to charge.

products
Array of strings

The IDs of the products associated with this tax rate

shipping_options
Array of strings

The IDs of the shipping options associated with this tax rate

product_types
Array of strings

The IDs of the types of product types associated with this tax rate

Responses

Response Schema: application/json
required
object (Tax Rate)

A Tax Rate can be used to define a custom rate to charge on specified products, product types, and shipping options within a given region.

code
required
string or null
Example: "tax01"

A code to identify the tax type by

created_at
required
string <date-time>

The date with timezone at which the resource was created.

id
required
string
Example: "txr_01G8XDBAWKBHHJRKH0AV02KXBR"

The tax rate's ID

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

An optional key-value map with additional details

name
required
string
Example: "Tax Example"

A human friendly name for the tax

rate
required
number or null
Example: 10

The numeric rate to charge

region_id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The ID of the region that the rate belongs to.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

region
object or null

The details of the region that the rate belongs to.

Array of objects (Product)

The details of the products that belong to this tax rate.

Array of objects (Product Type)

The details of the product types that belong to this tax rate.

Array of objects (Shipping Option)

The details of the shipping options that belong to this tax rate.

product_count
integer
Example: 10

The count of products

product_type_count
integer
Example: 2

The count of product types

shipping_option_count
integer
Example: 1

The count of shipping options

Request samples

Content type
application/json
{
  • "code": "string",
  • "name": "string",
  • "region_id": "string",
  • "rate": 0,
  • "products": [
    ],
  • "shipping_options": [
    ],
  • "product_types": [
    ]
}

Response samples

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

Delete a Tax Rate

Delete a Tax Rate. Resources associated with the tax rate, such as products or product types, are not deleted.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the Shipping Option.

Responses

Response Schema: application/json
id
required
string

The ID of the deleted Shipping Option.

object
required
string
Default: "tax-rate"

The type of the object that was deleted.

deleted
required
boolean
Default: true

Whether or not the items were deleted.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.taxRates.delete(taxRateId)
.then(({ id, object, deleted }) => {
  console.log(id);
});

Response samples

Content type
application/json
{
  • "id": "string",
  • "object": "tax-rate",
  • "deleted": true
}

Add to Product Types

Associates a Tax Rate with a list of Product Types

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

ID of the tax rate.

query Parameters
fields
Array of strings

Comma-separated fields that should be included in the returned tax rate.

expand
Array of strings

Comma-separated relations that should be expanded in the returned tax rate.

Request Body schema: application/json
product_types
required
Array of strings

The IDs of the types of products to associate with this tax rate

Responses

Response Schema: application/json
required
object (Tax Rate)

A Tax Rate can be used to define a custom rate to charge on specified products, product types, and shipping options within a given region.

code
required
string or null
Example: "tax01"

A code to identify the tax type by

created_at
required
string <date-time>

The date with timezone at which the resource was created.

id
required
string
Example: "txr_01G8XDBAWKBHHJRKH0AV02KXBR"

The tax rate's ID

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

An optional key-value map with additional details

name
required
string
Example: "Tax Example"

A human friendly name for the tax

rate
required
number or null
Example: 10

The numeric rate to charge

region_id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The ID of the region that the rate belongs to.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

region
object or null

The details of the region that the rate belongs to.

Array of objects (Product)

The details of the products that belong to this tax rate.

Array of objects (Product Type)

The details of the product types that belong to this tax rate.

Array of objects (Shipping Option)

The details of the shipping options that belong to this tax rate.

product_count
integer
Example: 10

The count of products

product_type_count
integer
Example: 2

The count of product types

shipping_option_count
integer
Example: 1

The count of shipping options

Request samples

Content type
application/json
{
  • "product_types": [
    ]
}

Response samples

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

Remove Product Types from Rate

Remove product types from a tax rate. This only removes the association between the product types and the tax rate. It does not delete the product types.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

ID of the tax rate.

query Parameters
fields
Array of strings

Comma-separated fields that should be included in the returned tax rate.

expand
Array of strings

Comma-separated relations that should be expanded in the returned tax rate.

Request Body schema: application/json
product_types
required
Array of strings

The IDs of the product types to remove their association with this tax rate.

Responses

Response Schema: application/json
required
object (Tax Rate)

A Tax Rate can be used to define a custom rate to charge on specified products, product types, and shipping options within a given region.

code
required
string or null
Example: "tax01"

A code to identify the tax type by

created_at
required
string <date-time>

The date with timezone at which the resource was created.

id
required
string
Example: "txr_01G8XDBAWKBHHJRKH0AV02KXBR"

The tax rate's ID

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

An optional key-value map with additional details

name
required
string
Example: "Tax Example"

A human friendly name for the tax

rate
required
number or null
Example: 10

The numeric rate to charge

region_id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The ID of the region that the rate belongs to.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

region
object or null

The details of the region that the rate belongs to.

Array of objects (Product)

The details of the products that belong to this tax rate.

Array of objects (Product Type)

The details of the product types that belong to this tax rate.

Array of objects (Shipping Option)

The details of the shipping options that belong to this tax rate.

product_count
integer
Example: 10

The count of products

product_type_count
integer
Example: 2

The count of product types

shipping_option_count
integer
Example: 1

The count of shipping options

Request samples

Content type
application/json
{
  • "product_types": [
    ]
}

Response samples

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

Add to Products

Associates a Tax Rate with a list of Products.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

ID of the tax rate.

query Parameters
fields
Array of strings

Comma-separated fields that should be included in the returned tax rate.

expand
Array of strings

Comma-separated relations that should be expanded in the returned tax rate.

Request Body schema: application/json
products
required
Array of strings

The IDs of the products to associate with this tax rate

Responses

Response Schema: application/json
required
object (Tax Rate)

A Tax Rate can be used to define a custom rate to charge on specified products, product types, and shipping options within a given region.

code
required
string or null
Example: "tax01"

A code to identify the tax type by

created_at
required
string <date-time>

The date with timezone at which the resource was created.

id
required
string
Example: "txr_01G8XDBAWKBHHJRKH0AV02KXBR"

The tax rate's ID

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

An optional key-value map with additional details

name
required
string
Example: "Tax Example"

A human friendly name for the tax

rate
required
number or null
Example: 10

The numeric rate to charge

region_id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The ID of the region that the rate belongs to.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

region
object or null

The details of the region that the rate belongs to.

Array of objects (Product)

The details of the products that belong to this tax rate.

Array of objects (Product Type)

The details of the product types that belong to this tax rate.

Array of objects (Shipping Option)

The details of the shipping options that belong to this tax rate.

product_count
integer
Example: 10

The count of products

product_type_count
integer
Example: 2

The count of product types

shipping_option_count
integer
Example: 1

The count of shipping options

Request samples

Content type
application/json
{
  • "products": [
    ]
}

Response samples

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

Remove Products from Rate

Remove products from a tax rate. This only removes the association between the products and the tax rate. It does not delete the products.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

ID of the tax rate.

query Parameters
fields
Array of strings

Comma-separated fields that should be included in the returned tax rate.

expand
Array of strings

Comma-separated relations that should be expanded in the returned tax rate.

Request Body schema: application/json
products
required
Array of strings

The IDs of the products to remove their association with this tax rate.

Responses

Response Schema: application/json
required
object (Tax Rate)

A Tax Rate can be used to define a custom rate to charge on specified products, product types, and shipping options within a given region.

code
required
string or null
Example: "tax01"

A code to identify the tax type by

created_at
required
string <date-time>

The date with timezone at which the resource was created.

id
required
string
Example: "txr_01G8XDBAWKBHHJRKH0AV02KXBR"

The tax rate's ID

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

An optional key-value map with additional details

name
required
string
Example: "Tax Example"

A human friendly name for the tax

rate
required
number or null
Example: 10

The numeric rate to charge

region_id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The ID of the region that the rate belongs to.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

region
object or null

The details of the region that the rate belongs to.

Array of objects (Product)

The details of the products that belong to this tax rate.

Array of objects (Product Type)

The details of the product types that belong to this tax rate.

Array of objects (Shipping Option)

The details of the shipping options that belong to this tax rate.

product_count
integer
Example: 10

The count of products

product_type_count
integer
Example: 2

The count of product types

shipping_option_count
integer
Example: 1

The count of shipping options

Request samples

Content type
application/json
{
  • "products": [
    ]
}

Response samples

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

Add to Shipping Options

Associates a Tax Rate with a list of Shipping Options.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

ID of the tax rate.

query Parameters
fields
Array of strings

Comma-separated fields that should be included in the returned tax rate.

expand
Array of strings

Comma-separated relations that should be expanded in the returned tax rate.

Request Body schema: application/json
shipping_options
required
Array of strings

The IDs of the shipping options to associate with this tax rate

Responses

Response Schema: application/json
required
object (Tax Rate)

A Tax Rate can be used to define a custom rate to charge on specified products, product types, and shipping options within a given region.

code
required
string or null
Example: "tax01"

A code to identify the tax type by

created_at
required
string <date-time>

The date with timezone at which the resource was created.

id
required
string
Example: "txr_01G8XDBAWKBHHJRKH0AV02KXBR"

The tax rate's ID

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

An optional key-value map with additional details

name
required
string
Example: "Tax Example"

A human friendly name for the tax

rate
required
number or null
Example: 10

The numeric rate to charge

region_id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The ID of the region that the rate belongs to.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

region
object or null

The details of the region that the rate belongs to.

Array of objects (Product)

The details of the products that belong to this tax rate.

Array of objects (Product Type)

The details of the product types that belong to this tax rate.

Array of objects (Shipping Option)

The details of the shipping options that belong to this tax rate.

product_count
integer
Example: 10

The count of products

product_type_count
integer
Example: 2

The count of product types

shipping_option_count
integer
Example: 1

The count of shipping options

Request samples

Content type
application/json
{
  • "shipping_options": [
    ]
}

Response samples

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

Remove Shipping Options from Rate

Remove shipping options from a tax rate. This only removes the association between the shipping options and the tax rate. It does not delete the shipping options.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

ID of the tax rate.

query Parameters
fields
Array of strings

Comma-separated fields that should be included in the returned tax rate.

expand
Array of strings

Comma-separated relations that should be expanded in the returned tax rate.

Request Body schema: application/json
shipping_options
required
Array of strings

The IDs of the shipping options to remove their association with this tax rate.

Responses

Response Schema: application/json
required
object (Tax Rate)

A Tax Rate can be used to define a custom rate to charge on specified products, product types, and shipping options within a given region.

code
required
string or null
Example: "tax01"

A code to identify the tax type by

created_at
required
string <date-time>

The date with timezone at which the resource was created.

id
required
string
Example: "txr_01G8XDBAWKBHHJRKH0AV02KXBR"

The tax rate's ID

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

An optional key-value map with additional details

name
required
string
Example: "Tax Example"

A human friendly name for the tax

rate
required
number or null
Example: 10

The numeric rate to charge

region_id
required
string
Example: "reg_01G1G5V26T9H8Y0M4JNE3YGA4G"

The ID of the region that the rate belongs to.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

region
object or null

The details of the region that the rate belongs to.

Array of objects (Product)

The details of the products that belong to this tax rate.

Array of objects (Product Type)

The details of the product types that belong to this tax rate.

Array of objects (Shipping Option)

The details of the shipping options that belong to this tax rate.

product_count
integer
Example: 10

The count of products

product_type_count
integer
Example: 2

The count of product types

shipping_option_count
integer
Example: 1

The count of shipping options

Request samples

Content type
application/json
{
  • "shipping_options": [
    ]
}

Response samples

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

Uploads

The upload endpoints are used to upload any type of resources. For example, they can be used to upload CSV files that are used to import products into the store.

Upload Files

Upload at least one file to a public bucket or storage. The file upload is handled by the file service installed on the Medusa backend.

Authorizations:
API TokenCookie Session ID
Request Body schema: multipart/form-data
files
string <binary>

Responses

Response Schema: application/json
required
Array of objects

Uploaded files details.

Array
url
required
string <uri>

The URL of the uploaded file.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.uploads.create(file)
.then(({ uploads }) => {
  console.log(uploads.length);
});

Response samples

Content type
application/json
{}

Delete an Uploaded File

Delete an uploaded file from storage. The file is deleted using the installed file service on the Medusa backend.

Authorizations:
API TokenCookie Session ID
Request Body schema: application/json
file_key
required
string

key of the file to delete

Responses

Response Schema: application/json
id
required
string

The file key of the upload deleted

object
required
string
Default: "file"

The type of the object that was deleted.

deleted
required
boolean
Default: true

Whether or not the items were deleted.

Request samples

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

Response samples

Content type
application/json
{
  • "id": "string",
  • "object": "file",
  • "deleted": true
}

Get a File's Download URL

Create and retrieve a presigned or public download URL for a file. The URL creation is handled by the file service installed on the Medusa backend.

Authorizations:
API TokenCookie Session ID
Request Body schema: application/json
file_key
required
string

key of the file to obtain the download link for

Responses

Response Schema: application/json
download_url
required
string

The Download URL of the file

Request samples

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

Response samples

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

Protected File Upload

Upload at least one file to an ACL or a non-public bucket. The file upload is handled by the file service installed on the Medusa backend.

Authorizations:
API TokenCookie Session ID
Request Body schema: multipart/form-data
files
string <binary>

Responses

Response Schema: application/json
required
Array of objects

Uploaded files details.

Array
url
required
string <uri>

The URL of the uploaded file.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.uploads.createProtected(file)
.then(({ uploads }) => {
  console.log(uploads.length);
});

Response samples

Content type
application/json
{}

Users

A store can have more than one user, each having the same privileges. Admins can manage users, their passwords, and more.

List Users

Retrieve all admin users.

Authorizations:
API TokenCookie Session ID

Responses

Response Schema: application/json
required
Array of objects (User)

An array of users details.

Array
api_token
required
string or null
Example: null

An API token associated with the user.

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 email of the User

first_name
required
string or null
Example: "Levi"

The first name of the User

id
required
string
Example: "usr_01G1G5V26F5TB3GPAPNJ8X1S3V"

The user's ID

last_name
required
string or null
Example: "Bogan"

The last name of the User

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

An optional key-value map with additional details

role
required
string
Default: "member"
Enum: "admin" "member" "developer"

The user's role. These roles don't provide any different privileges.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.users.list()
.then(({ users }) => {
  console.log(users.length);
});

Response samples

Content type
application/json
{
  • "users": [
    ]
}

Create a User

Create an admin User. The user has the same privileges as all admin users, and will be able to authenticate and perform admin functionalities right after creation.

Authorizations:
API TokenCookie Session ID
Request Body schema: application/json
email
required
string <email>

The User's email.

password
required
string <password>

The User's password.

first_name
string

The first name of the User.

last_name
string

The last name of the User.

role
string
Enum: "admin" "member" "developer"

The role assigned to the user. These roles don't provide any different privileges.

Responses

Response Schema: application/json
required
object (User)

A User is an administrator who can manage store settings and data.

api_token
required
string or null
Example: null

An API token associated with the user.

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 email of the User

first_name
required
string or null
Example: "Levi"

The first name of the User

id
required
string
Example: "usr_01G1G5V26F5TB3GPAPNJ8X1S3V"

The user's ID

last_name
required
string or null
Example: "Bogan"

The last name of the User

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

An optional key-value map with additional details

role
required
string
Default: "member"
Enum: "admin" "member" "developer"

The user's role. These roles don't provide any different privileges.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

Request samples

Content type
application/json
{
  • "email": "user@example.com",
  • "first_name": "string",
  • "last_name": "string",
  • "role": "admin",
  • "password": "pa$$word"
}

Response samples

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

Request Password Reset

Generate a password token for an admin user with a given email.

Authorizations:
API TokenCookie Session ID
Request Body schema: application/json
email
required
string <email>

The User's email.

Responses

Request samples

Content type
application/json
{
  • "email": "user@example.com"
}

Response samples

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

Reset Password

Reset the password of an admin User using their reset password token. A user must request to reset their password first before attempting to reset their password with this request.

Authorizations:
API TokenCookie Session ID
Request Body schema: application/json
token
required
string

The password-reset token generated when the password reset was requested.

password
required
string <password>

The User's new password.

email
string <email>

The User's email.

Responses

Response Schema: application/json
required
object (User)

A User is an administrator who can manage store settings and data.

api_token
required
string or null
Example: null

An API token associated with the user.

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 email of the User

first_name
required
string or null
Example: "Levi"

The first name of the User

id
required
string
Example: "usr_01G1G5V26F5TB3GPAPNJ8X1S3V"

The user's ID

last_name
required
string or null
Example: "Bogan"

The last name of the User

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

An optional key-value map with additional details

role
required
string
Default: "member"
Enum: "admin" "member" "developer"

The user's role. These roles don't provide any different privileges.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

Request samples

Content type
application/json
{
  • "email": "user@example.com",
  • "token": "string",
  • "password": "pa$$word"
}

Response samples

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

Get a User

Retrieve an admin user's details.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the User.

Responses

Response Schema: application/json
required
object (User)

A User is an administrator who can manage store settings and data.

api_token
required
string or null
Example: null

An API token associated with the user.

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 email of the User

first_name
required
string or null
Example: "Levi"

The first name of the User

id
required
string
Example: "usr_01G1G5V26F5TB3GPAPNJ8X1S3V"

The user's ID

last_name
required
string or null
Example: "Bogan"

The last name of the User

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

An optional key-value map with additional details

role
required
string
Default: "member"
Enum: "admin" "member" "developer"

The user's role. These roles don't provide any different privileges.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.users.retrieve(userId)
.then(({ user }) => {
  console.log(user.id);
});

Response samples

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

Update a User

Update an admin user's details.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the User.

Request Body schema: application/json
first_name
string

The first name of the User.

last_name
string

The last name of the User.

role
string
Enum: "admin" "member" "developer"

The role assigned to the user. These roles don't provide any different privileges.

api_token
string

The API token of the User.

metadata
object

An optional set of key-value pairs with additional information.

Responses

Response Schema: application/json
required
object (User)

A User is an administrator who can manage store settings and data.

api_token
required
string or null
Example: null

An API token associated with the user.

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 email of the User

first_name
required
string or null
Example: "Levi"

The first name of the User

id
required
string
Example: "usr_01G1G5V26F5TB3GPAPNJ8X1S3V"

The user's ID

last_name
required
string or null
Example: "Bogan"

The last name of the User

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

An optional key-value map with additional details

role
required
string
Default: "member"
Enum: "admin" "member" "developer"

The user's role. These roles don't provide any different privileges.

updated_at
required
string <date-time>

The date with timezone at which the resource was updated.

Request samples

Content type
application/json
{
  • "first_name": "string",
  • "last_name": "string",
  • "role": "admin",
  • "api_token": "string",
  • "metadata": { }
}

Response samples

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

Delete a User

Delete a User. Once deleted, the user will not be able to authenticate or perform admin functionalities.

Authorizations:
API TokenCookie Session ID
path Parameters
id
required
string

The ID of the User.

Responses

Response Schema: application/json
id
required
string

The ID of the deleted user.

object
required
string
Default: "user"

The type of the object that was deleted.

deleted
required
boolean
Default: true

Whether or not the items were deleted.

Request samples

import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.users.delete(userId)
.then(({ id, object, deleted }) => {
  console.log(id);
});

Response samples

Content type
application/json
{
  • "id": "string",
  • "object": "user",
  • "deleted": true
}