Files
medusa-store/www/apps/docs/content/references/js-client/classes/AdminSalesChannelsResource.mdx
Shahed Nasser c51dce164d docs: general fixes to references (#5653)
* fixed typedoc plugin's escape strategy

* move props comments to the associated property

* regenerate references
2023-11-17 19:36:58 +02:00

1830 lines
56 KiB
Plaintext

---
displayed_sidebar: jsClientSidebar
slug: /references/js-client/AdminSalesChannelsResource
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# AdminSalesChannelsResource
This class is used to send requests to [Admin Sales Channel API Routes](https://docs.medusajs.com/api/admin#sales-channels). All its method
are available in the JS Client under the `medusa.admin.salesChannels` property.
All methods in this class require [user authentication](AdminAuthResource.mdx#createsession).
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.
Related Guide: [How to manage sales channels](https://docs.medusajs.com/modules/sales-channels/admin/manage).
## Methods
### addLocation
Associate a stock location with a sales channel.
#### Example
```ts
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
.addLocation(salesChannelId, {
location_id: "loc_123",
})
.then(({ sales_channel }) => {
console.log(sales_channel.id)
})
```
#### Parameters
<ParameterTypes parameters={[
{
"name": "salesChannelId",
"type": "`string`",
"description": "The sales channel's ID.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "payload",
"type": "[AdminPostSalesChannelsChannelStockLocationsReq](../internal/classes/internal.AdminPostSalesChannelsChannelStockLocationsReq.mdx)",
"description": "The stock location to associate with the sales channel.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "location_id",
"type": "`string`",
"description": "The ID of the stock location",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
},
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} />
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "[ResponsePromise](../internal/types/internal.ResponsePromise.mdx)&#60;[AdminSalesChannelsRes](../internal/types/internal.AdminSalesChannelsRes.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the sales channel's details.",
"expandable": false,
"children": [
{
"name": "AdminSalesChannelsRes",
"type": "`object`",
"description": "The sales channel's details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "sales_channel",
"type": "[SalesChannel](../internal/classes/internal.SalesChannel.mdx)",
"description": "Sales Channel's details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "created_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was created.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "deleted_at",
"type": "`null` \\| `Date`",
"description": "The date with timezone at which the resource was deleted.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "description",
"type": "`null` \\| `string`",
"description": "The description of the sales channel.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "id",
"type": "`string`",
"description": "The sales channel's ID",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "is_disabled",
"type": "`boolean`",
"description": "Specify if the sales channel is enabled or disabled.",
"optional": false,
"defaultValue": "false",
"expandable": false,
"children": []
},
{
"name": "locations",
"type": "[SalesChannelLocation](../internal/classes/internal.internal.SalesChannelLocation.mdx)[]",
"description": "The details of the stock locations related to the sales channel.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "metadata",
"type": "`null` \\| `Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "name",
"type": "`string`",
"description": "The name of the sales channel.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "updated_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was updated.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]
}
]
}
]} />
___
### addProducts
Add a list of products to a sales channel.
#### Example
```ts
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
.addProducts(salesChannelId, {
product_ids: [
{
id: productId,
},
],
})
.then(({ sales_channel }) => {
console.log(sales_channel.id)
})
```
#### Parameters
<ParameterTypes parameters={[
{
"name": "salesChannelId",
"type": "`string`",
"description": "The sales channel's ID.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "payload",
"type": "[AdminPostSalesChannelsChannelProductsBatchReq](../internal/classes/internal.AdminPostSalesChannelsChannelProductsBatchReq.mdx)",
"description": "The products to add to the sales channel.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "product_ids",
"type": "[ProductBatchSalesChannel](../internal/classes/internal.ProductBatchSalesChannel.mdx)[]",
"description": "The IDs of the products to add to the Sales Channel",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "id",
"type": "`string`",
"description": "The ID of the sales channel",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]
},
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} />
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "[ResponsePromise](../internal/types/internal.ResponsePromise.mdx)&#60;[AdminSalesChannelsRes](../internal/types/internal.AdminSalesChannelsRes.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the sales channel's details.",
"expandable": false,
"children": [
{
"name": "AdminSalesChannelsRes",
"type": "`object`",
"description": "The sales channel's details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "sales_channel",
"type": "[SalesChannel](../internal/classes/internal.SalesChannel.mdx)",
"description": "Sales Channel's details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "created_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was created.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "deleted_at",
"type": "`null` \\| `Date`",
"description": "The date with timezone at which the resource was deleted.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "description",
"type": "`null` \\| `string`",
"description": "The description of the sales channel.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "id",
"type": "`string`",
"description": "The sales channel's ID",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "is_disabled",
"type": "`boolean`",
"description": "Specify if the sales channel is enabled or disabled.",
"optional": false,
"defaultValue": "false",
"expandable": false,
"children": []
},
{
"name": "locations",
"type": "[SalesChannelLocation](../internal/classes/internal.internal.SalesChannelLocation.mdx)[]",
"description": "The details of the stock locations related to the sales channel.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "metadata",
"type": "`null` \\| `Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "name",
"type": "`string`",
"description": "The name of the sales channel.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "updated_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was updated.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]
}
]
}
]} />
___
### create
Create a sales channel.
#### Example
```ts
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
.create({
name: "App",
description: "Mobile app",
})
.then(({ sales_channel }) => {
console.log(sales_channel.id)
})
```
#### Parameters
<ParameterTypes parameters={[
{
"name": "payload",
"type": "[AdminPostSalesChannelsReq](../internal/classes/internal.AdminPostSalesChannelsReq.mdx)",
"description": "The sales channel to create.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "description",
"type": "`string`",
"description": "The description of the Sales Channel",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "is_disabled",
"type": "`boolean`",
"description": "Whether the Sales Channel is disabled.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "name",
"type": "`string`",
"description": "The name of the Sales Channel",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
},
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} />
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "[ResponsePromise](../internal/types/internal.ResponsePromise.mdx)&#60;[AdminSalesChannelsRes](../internal/types/internal.AdminSalesChannelsRes.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the sales channel's details.",
"expandable": false,
"children": [
{
"name": "AdminSalesChannelsRes",
"type": "`object`",
"description": "The sales channel's details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "sales_channel",
"type": "[SalesChannel](../internal/classes/internal.SalesChannel.mdx)",
"description": "Sales Channel's details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "created_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was created.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "deleted_at",
"type": "`null` \\| `Date`",
"description": "The date with timezone at which the resource was deleted.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "description",
"type": "`null` \\| `string`",
"description": "The description of the sales channel.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "id",
"type": "`string`",
"description": "The sales channel's ID",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "is_disabled",
"type": "`boolean`",
"description": "Specify if the sales channel is enabled or disabled.",
"optional": false,
"defaultValue": "false",
"expandable": false,
"children": []
},
{
"name": "locations",
"type": "[SalesChannelLocation](../internal/classes/internal.internal.SalesChannelLocation.mdx)[]",
"description": "The details of the stock locations related to the sales channel.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "metadata",
"type": "`null` \\| `Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "name",
"type": "`string`",
"description": "The name of the sales channel.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "updated_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was updated.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]
}
]
}
]} />
___
### delete
Delete a sales channel. Associated products, stock locations, and other resources are not deleted.
#### Example
```ts
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)
})
```
#### Parameters
<ParameterTypes parameters={[
{
"name": "salesChannelId",
"type": "`string`",
"description": "The sales channel's ID.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} />
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "[ResponsePromise](../internal/types/internal.ResponsePromise.mdx)&#60;[DeleteResponse](../internal/interfaces/internal.DeleteResponse.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the deletion operation's details.",
"expandable": false,
"children": [
{
"name": "deleted",
"type": "`boolean`",
"description": "Whether the item was deleted successfully.",
"optional": false,
"defaultValue": "true",
"expandable": false,
"children": []
},
{
"name": "id",
"type": "`string`",
"description": "The ID of the deleted item.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "object",
"type": "`string`",
"description": "The type of the deleted item.",
"optional": false,
"defaultValue": "product-collection",
"expandable": false,
"children": []
}
]
}
]} />
___
### list
Retrieve a list of sales channels. The sales channels can be filtered by fields such as `q` or `name` passed in the `query` parameter. The sales channels can also be sorted or paginated.
#### Example
To list sales channels:
```ts
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)
})
```
To specify relations that should be retrieved within the sales channels:
```ts
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({
expand: "locations",
})
.then(({ sales_channels, limit, offset, count }) => {
console.log(sales_channels.length)
})
```
By default, only the first `20` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:
```ts
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({
expand: "locations",
limit,
offset,
})
.then(({ sales_channels, limit, offset, count }) => {
console.log(sales_channels.length)
})
```
#### Parameters
<ParameterTypes parameters={[
{
"name": "query",
"type": "[AdminGetSalesChannelsParams](../internal/classes/internal.AdminGetSalesChannelsParams.mdx)",
"description": "Filters and pagination configurations applied on the retrieved sales channels.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "created_at",
"type": "[DateComparisonOperator](../internal/classes/internal.DateComparisonOperator.mdx)",
"description": "Date filters to apply on sales channels' `created_at` field.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "gt",
"type": "`Date`",
"description": "The filtered date must be greater than this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "gte",
"type": "`Date`",
"description": "The filtered date must be greater than or equal to this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "lt",
"type": "`Date`",
"description": "The filtered date must be less than this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "lte",
"type": "`Date`",
"description": "The filtered date must be less than or equal to this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]
},
{
"name": "deleted_at",
"type": "[DateComparisonOperator](../internal/classes/internal.DateComparisonOperator.mdx)",
"description": "Date filters to apply on sales channels' `deleted_at` field.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "gt",
"type": "`Date`",
"description": "The filtered date must be greater than this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "gte",
"type": "`Date`",
"description": "The filtered date must be greater than or equal to this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "lt",
"type": "`Date`",
"description": "The filtered date must be less than this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "lte",
"type": "`Date`",
"description": "The filtered date must be less than or equal to this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]
},
{
"name": "description",
"type": "`string`",
"description": "Description to filter sales channels by.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "expand",
"type": "`string`",
"description": "Comma-separated relations that should be expanded in the returned data.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "fields",
"type": "`string`",
"description": "Comma-separated fields that should be included in the returned data.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "id",
"type": "`string`",
"description": "ID to filter sales channels by.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "limit",
"type": "`number`",
"description": "Limit the number of items returned in the list.",
"optional": true,
"defaultValue": "20",
"expandable": false,
"children": []
},
{
"name": "name",
"type": "`string`",
"description": "Name to filter sales channels by.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "offset",
"type": "`number`",
"description": "The number of items to skip when retrieving a list.",
"optional": true,
"defaultValue": "0",
"expandable": false,
"children": []
},
{
"name": "order",
"type": "`string`",
"description": "The field to sort the data by. By default, the sort order is ascending. To change the order to descending, prefix the field name with `-`.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "q",
"type": "`string`",
"description": "Search term to search sales channels' names and descriptions.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "updated_at",
"type": "[DateComparisonOperator](../internal/classes/internal.DateComparisonOperator.mdx)",
"description": "Date filters to apply on sales channels' `updated_at` field.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "gt",
"type": "`Date`",
"description": "The filtered date must be greater than this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "gte",
"type": "`Date`",
"description": "The filtered date must be greater than or equal to this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "lt",
"type": "`Date`",
"description": "The filtered date must be less than this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "lte",
"type": "`Date`",
"description": "The filtered date must be less than or equal to this value.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]
},
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} />
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "[ResponsePromise](../internal/types/internal.ResponsePromise.mdx)&#60;[AdminSalesChannelsListRes](../internal/types/internal.AdminSalesChannelsListRes.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the list of sales channels with pagination fields.",
"expandable": false,
"children": [
{
"name": "AdminSalesChannelsListRes",
"type": "[PaginatedResponse](../internal/interfaces/internal.PaginatedResponse.mdx) & ``{ sales_channels: [SalesChannel](../internal/classes/internal.SalesChannel.mdx)[] }``",
"description": "The list of sales channels with pagination fields.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "count",
"type": "`number`",
"description": "The total number of items available.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "limit",
"type": "`number`",
"description": "The maximum number of items that can be returned in the list.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "offset",
"type": "`number`",
"description": "The number of items skipped before the returned items in the list.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "sales_channels",
"type": "[SalesChannel](../internal/classes/internal.SalesChannel.mdx)[]",
"description": "An array of sales channels details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "created_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was created.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "deleted_at",
"type": "`null` \\| `Date`",
"description": "The date with timezone at which the resource was deleted.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "description",
"type": "`null` \\| `string`",
"description": "The description of the sales channel.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "id",
"type": "`string`",
"description": "The sales channel's ID",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "is_disabled",
"type": "`boolean`",
"description": "Specify if the sales channel is enabled or disabled.",
"optional": false,
"defaultValue": "false",
"expandable": false,
"children": []
},
{
"name": "locations",
"type": "[SalesChannelLocation](../internal/classes/internal.internal.SalesChannelLocation.mdx)[]",
"description": "The details of the stock locations related to the sales channel.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "metadata",
"type": "`null` \\| `Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "name",
"type": "`string`",
"description": "The name of the sales channel.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "updated_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was updated.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]
}
]
}
]} />
___
### removeLocation
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.
#### Example
```ts
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
.removeLocation(salesChannelId, {
location_id: "loc_id",
})
.then(({ sales_channel }) => {
console.log(sales_channel.id)
})
```
#### Parameters
<ParameterTypes parameters={[
{
"name": "salesChannelId",
"type": "`string`",
"description": "The sales channel's ID.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "payload",
"type": "[AdminDeleteSalesChannelsChannelStockLocationsReq](../internal/classes/internal.AdminDeleteSalesChannelsChannelStockLocationsReq.mdx)",
"description": "The stock location to remove from the sales channel.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "location_id",
"type": "`string`",
"description": "The ID of the stock location",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
},
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} />
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "[ResponsePromise](../internal/types/internal.ResponsePromise.mdx)&#60;[AdminSalesChannelsRes](../internal/types/internal.AdminSalesChannelsRes.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the sales channel's details.",
"expandable": false,
"children": [
{
"name": "AdminSalesChannelsRes",
"type": "`object`",
"description": "The sales channel's details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "sales_channel",
"type": "[SalesChannel](../internal/classes/internal.SalesChannel.mdx)",
"description": "Sales Channel's details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "created_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was created.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "deleted_at",
"type": "`null` \\| `Date`",
"description": "The date with timezone at which the resource was deleted.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "description",
"type": "`null` \\| `string`",
"description": "The description of the sales channel.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "id",
"type": "`string`",
"description": "The sales channel's ID",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "is_disabled",
"type": "`boolean`",
"description": "Specify if the sales channel is enabled or disabled.",
"optional": false,
"defaultValue": "false",
"expandable": false,
"children": []
},
{
"name": "locations",
"type": "[SalesChannelLocation](../internal/classes/internal.internal.SalesChannelLocation.mdx)[]",
"description": "The details of the stock locations related to the sales channel.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "metadata",
"type": "`null` \\| `Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "name",
"type": "`string`",
"description": "The name of the sales channel.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "updated_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was updated.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]
}
]
}
]} />
___
### removeProducts
Remove a list of products from a sales channel. This doesn't delete the product. It only removes the association between the product and the sales channel.
#### Example
```ts
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
.removeProducts(salesChannelId, {
product_ids: [
{
id: productId,
},
],
})
.then(({ sales_channel }) => {
console.log(sales_channel.id)
})
```
#### Parameters
<ParameterTypes parameters={[
{
"name": "salesChannelId",
"type": "`string`",
"description": "The sales channel's ID.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "payload",
"type": "[AdminDeleteSalesChannelsChannelProductsBatchReq](../internal/classes/internal.AdminDeleteSalesChannelsChannelProductsBatchReq.mdx)",
"description": "The products to remove from the sales channel.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "product_ids",
"type": "[ProductBatchSalesChannel](../internal/classes/internal.ProductBatchSalesChannel.mdx)[]",
"description": "The IDs of the products to remove from the Sales Channel.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "id",
"type": "`string`",
"description": "The ID of the sales channel",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]
},
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} />
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "[ResponsePromise](../internal/types/internal.ResponsePromise.mdx)&#60;[AdminSalesChannelsRes](../internal/types/internal.AdminSalesChannelsRes.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the sales channel's details.",
"expandable": false,
"children": [
{
"name": "AdminSalesChannelsRes",
"type": "`object`",
"description": "The sales channel's details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "sales_channel",
"type": "[SalesChannel](../internal/classes/internal.SalesChannel.mdx)",
"description": "Sales Channel's details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "created_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was created.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "deleted_at",
"type": "`null` \\| `Date`",
"description": "The date with timezone at which the resource was deleted.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "description",
"type": "`null` \\| `string`",
"description": "The description of the sales channel.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "id",
"type": "`string`",
"description": "The sales channel's ID",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "is_disabled",
"type": "`boolean`",
"description": "Specify if the sales channel is enabled or disabled.",
"optional": false,
"defaultValue": "false",
"expandable": false,
"children": []
},
{
"name": "locations",
"type": "[SalesChannelLocation](../internal/classes/internal.internal.SalesChannelLocation.mdx)[]",
"description": "The details of the stock locations related to the sales channel.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "metadata",
"type": "`null` \\| `Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "name",
"type": "`string`",
"description": "The name of the sales channel.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "updated_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was updated.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]
}
]
}
]} />
___
### retrieve
Retrieve a sales channel's details.
#### Example
```ts
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)
})
```
#### Parameters
<ParameterTypes parameters={[
{
"name": "salesChannelId",
"type": "`string`",
"description": "The sales channel's ID.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} />
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "[ResponsePromise](../internal/types/internal.ResponsePromise.mdx)&#60;[AdminSalesChannelsRes](../internal/types/internal.AdminSalesChannelsRes.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the sales channel's details.",
"expandable": false,
"children": [
{
"name": "AdminSalesChannelsRes",
"type": "`object`",
"description": "The sales channel's details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "sales_channel",
"type": "[SalesChannel](../internal/classes/internal.SalesChannel.mdx)",
"description": "Sales Channel's details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "created_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was created.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "deleted_at",
"type": "`null` \\| `Date`",
"description": "The date with timezone at which the resource was deleted.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "description",
"type": "`null` \\| `string`",
"description": "The description of the sales channel.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "id",
"type": "`string`",
"description": "The sales channel's ID",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "is_disabled",
"type": "`boolean`",
"description": "Specify if the sales channel is enabled or disabled.",
"optional": false,
"defaultValue": "false",
"expandable": false,
"children": []
},
{
"name": "locations",
"type": "[SalesChannelLocation](../internal/classes/internal.internal.SalesChannelLocation.mdx)[]",
"description": "The details of the stock locations related to the sales channel.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "metadata",
"type": "`null` \\| `Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "name",
"type": "`string`",
"description": "The name of the sales channel.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "updated_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was updated.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]
}
]
}
]} />
___
### update
Update a sales channel's details.
#### Example
```ts
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
.update(salesChannelId, {
name: "App",
})
.then(({ sales_channel }) => {
console.log(sales_channel.id)
})
```
#### Parameters
<ParameterTypes parameters={[
{
"name": "salesChannelId",
"type": "`string`",
"description": "The sales channel's ID.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "payload",
"type": "[AdminPostSalesChannelsSalesChannelReq](../internal/classes/internal.AdminPostSalesChannelsSalesChannelReq.mdx)",
"description": "The attributes to update in the sales channel.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "description",
"type": "`string`",
"description": "The description of the sales channel.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "is_disabled",
"type": "`boolean`",
"description": "Whether the Sales Channel is disabled.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "name",
"type": "`string`",
"description": "The name of the sales channel",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]
},
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} />
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "[ResponsePromise](../internal/types/internal.ResponsePromise.mdx)&#60;[AdminSalesChannelsRes](../internal/types/internal.AdminSalesChannelsRes.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the sales channel's details.",
"expandable": false,
"children": [
{
"name": "AdminSalesChannelsRes",
"type": "`object`",
"description": "The sales channel's details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "sales_channel",
"type": "[SalesChannel](../internal/classes/internal.SalesChannel.mdx)",
"description": "Sales Channel's details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "created_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was created.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "deleted_at",
"type": "`null` \\| `Date`",
"description": "The date with timezone at which the resource was deleted.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "description",
"type": "`null` \\| `string`",
"description": "The description of the sales channel.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "id",
"type": "`string`",
"description": "The sales channel's ID",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "is_disabled",
"type": "`boolean`",
"description": "Specify if the sales channel is enabled or disabled.",
"optional": false,
"defaultValue": "false",
"expandable": false,
"children": []
},
{
"name": "locations",
"type": "[SalesChannelLocation](../internal/classes/internal.internal.SalesChannelLocation.mdx)[]",
"description": "The details of the stock locations related to the sales channel.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "metadata",
"type": "`null` \\| `Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "name",
"type": "`string`",
"description": "The name of the sales channel.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "updated_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was updated.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]
}
]
}
]} />