Links between Sales Channel Module and Other Modules

This document showcases the module links defined between the Sales Channel Module and other Commerce Modules.

Summary#

The Sales Channel Module has the following links to other modules:

Tip: Read-only links are used to query data across modules, but the relations aren't stored in a pivot table in the database.

First Data Model

Second Data Model

Type

Description

ApiKey in API Key Module

SalesChannel

Stored - many-to-many

Learn more

Cart in Cart Module

SalesChannel

Read-only - has one

Learn more

Order in Order Module

SalesChannel

Read-only - has one

Learn more

Product in Product Module

SalesChannel

Stored - many-to-many

Learn more

SalesChannel

StockLocation in Stock Location Module

Stored - many-to-many

Learn more


API Key Module#

A publishable API key allows you to easily specify the sales channel scope in a client request.

Medusa defines a link between the ApiKey and the SalesChannel data models.

A diagram showcasing an example of how resources from the Sales Channel and API Key modules are linked

Retrieve with Query#

To retrieve the API keys associated with a sales channel with Query, pass publishable_api_keys.* in fields:

To manage the sales channels of an API key, use Link:


Cart Module#

Medusa defines a read-only link between the Cart Module's Cart data model and the SalesChannel data model. Because the link is read-only from the Cart's side, you can only retrieve the sales channel of a cart, and not the other way around.

Retrieve with Query#

To retrieve the sales channel of a cart with Query, pass sales_channel.* in fields:


Order Module#

Medusa defines a read-only link between the Order Module's Order data model and the SalesChannel data model. Because the link is read-only from the Order's side, you can only retrieve the sales channel of an order, and not the other way around.

Retrieve with Query#

To retrieve the sales channel of an order with Query, pass sales_channel.* in fields:


Product Module#

A product has different availability for different sales channels. Medusa defines a link between the Product and the SalesChannel data models.

A diagram showcasing an example of how resources from the Sales Channel and Product modules are linked

A product can be available in more than one sales channel. You can retrieve only the products of a sales channel.

Retrieve with Query#

To retrieve the products of a sales channel with Query, pass products.* in fields:

To manage the sales channels of a product, use Link:


Stock Location Module#

A stock location is associated with a sales channel. This scopes inventory quantities associated with that stock location by the associated sales channel.

Medusa defines a link between the SalesChannel and StockLocation data models.

A diagram showcasing an example of how resources from the Sales Channel and Stock Location modules are linked

Retrieve with Query#

To retrieve the stock locations of a sales channel with Query, pass stock_locations.* in fields:

To manage the stock locations of a sales channel, use Link:

Was this page helpful?
Ask Anything
Ask any questions about Medusa. Get help with your development.
You can also use the Medusa MCP server in Cursor, VSCode, etc...
FAQ
What is Medusa?
How can I create a module?
How can I create a data model?
How do I create a workflow?
How can I extend a data model in the Product Module?
Recipes
How do I build a marketplace with Medusa?
How do I build digital products with Medusa?
How do I build subscription-based purchases with Medusa?
What other recipes are available in the Medusa documentation?
Chat is cleared on refresh
Line break