@medusajs/sales-channel
Documentation | Website
Building blocks for digital commerce
Sales Channel Module for Medusa: manages sales channels. Use it to model the channels you sell through, such as a website, a mobile app, or a B2B storefront, and scope product availability, carts, and orders to each one. It ships with @medusajs/medusa and is registered by default, so Medusa applications don't install it directly.
At a glance
| Package | @medusajs/sales-channel |
| Type | Commerce Module |
| Module key | Modules.SALES_CHANNEL ("sales_channel") |
| Registered by default | Yes |
| Import from | @medusajs/medusa/sales-channel |
Features
- Create, update, and disable sales channels.
- Link sales channels to products, carts, orders, and stock locations through module links.
- Scope storefront requests to sales channels with publishable API keys.
Installation
No installation needed. The module is included in @medusajs/medusa and registered by default.
Usage
Resolve the module's service from the container, for example in a workflow step:
import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk"
import { Modules } from "@medusajs/framework/utils"
const createSalesChannelStep = createStep(
"create-sales-channel",
async ({}, { container }) => {
const salesChannelModuleService = container.resolve(Modules.SALES_CHANNEL)
const salesChannels = await salesChannelModuleService.createSalesChannels([
{
name: "B2B",
},
{
name: "Mobile App",
},
])
return new StepResponse({ salesChannels }, salesChannels.map((sc) => sc.id))
}
)