Generated the following references: - `entities` - `inventory` - `js-client` - `pricing` - `product` - `services` - `stock-location` - `workflows` Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com> Co-authored-by: Shahed Nasser <27354907+shahednasser@users.noreply.github.com>
1114 lines
34 KiB
Plaintext
1114 lines
34 KiB
Plaintext
---
|
|
displayed_sidebar: jsClientSidebar
|
|
slug: /references/js-client/AdminStockLocationsResource
|
|
---
|
|
|
|
import ParameterTypes from "@site/src/components/ParameterTypes"
|
|
|
|
# AdminStockLocationsResource
|
|
|
|
This class is used to send requests to [Admin Stock Location API Routes](https://docs.medusajs.com/api/admin#stock-locations). To use these API Routes, make sure to install the
|
|
[@medusajs/stock-location](https://docs.medusajs.com/modules/multiwarehouse/install-modules#stock-location-module) module in your Medusa backend.
|
|
|
|
All methods in this class require [user authentication](AdminAuthResource.mdx#createsession). The methods
|
|
are available in the JS Client under the `medusa.admin.stockLocations` property.
|
|
|
|
A stock location, provided by the [Stock Location module](https://docs.medusajs.com/modules/multiwarehouse/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.
|
|
|
|
Related Guide: [How to manage stock locations](https://docs.medusajs.com/modules/multiwarehouse/admin/manage-stock-locations).
|
|
|
|
## Methods
|
|
|
|
#### create
|
|
|
|
Create a 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.stockLocations
|
|
.create({
|
|
name: "Main Warehouse",
|
|
})
|
|
.then(({ stock_location }) => {
|
|
console.log(stock_location.id)
|
|
})
|
|
```
|
|
|
|
##### Parameters
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "payload",
|
|
"type": "[AdminPostStockLocationsReq](../internal/classes/internal.AdminPostStockLocationsReq.mdx)",
|
|
"description": "The stock location to be created.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": [
|
|
{
|
|
"name": "address",
|
|
"type": "[StockLocationAddress](../internal/classes/internal.StockLocationAddress.mdx)",
|
|
"description": "A new stock location address to create and associate with the stock location. Only required if `address\\_id` is not provided.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": [
|
|
{
|
|
"name": "address_1",
|
|
"type": "`string`",
|
|
"description": "Stock location address",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "address_2",
|
|
"type": "`string`",
|
|
"description": "Stock location address' complement",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "city",
|
|
"type": "`string`",
|
|
"description": "Stock location address' city",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "company",
|
|
"type": "`string`",
|
|
"description": "Stock location address' company",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "country_code",
|
|
"type": "`string`",
|
|
"description": "The two character ISO code for the country.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "phone",
|
|
"type": "`string`",
|
|
"description": "Stock location address' phone number",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "postal_code",
|
|
"type": "`string`",
|
|
"description": "Stock location address' postal code",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "province",
|
|
"type": "`string`",
|
|
"description": "Stock location address' province",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "address_id",
|
|
"type": "`string`",
|
|
"description": "the ID of an existing stock location address to associate with the stock location. Only required if `address` is not provided.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "metadata",
|
|
"type": "`Record<string, unknown>`",
|
|
"description": "An optional key-value map with additional details",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "name",
|
|
"type": "`string`",
|
|
"description": "the name 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)<[AdminStockLocationsRes](../internal/types/internal.AdminStockLocationsRes.mdx)>",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"description": "Resolves to the stock location's details.",
|
|
"expandable": false,
|
|
"children": [
|
|
{
|
|
"name": "AdminStockLocationsRes",
|
|
"type": "`object`",
|
|
"description": "The stock location's details.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": [
|
|
{
|
|
"name": "stock_location",
|
|
"type": "[StockLocationExpandedDTO](../internal/types/internal.StockLocationExpandedDTO.mdx)",
|
|
"description": "Stock location details.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": [
|
|
{
|
|
"name": "address",
|
|
"type": "[StockLocationAddressDTO](../StockLocationTypes/types/internal.internal-1.StockLocationTypes.StockLocationAddressDTO.mdx)",
|
|
"description": "The Address of the Stock Location",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "address_id",
|
|
"type": "`string`",
|
|
"description": "Stock location address' ID",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "created_at",
|
|
"type": "`string` \\| `Date`",
|
|
"description": "The date with timezone at which the resource was created.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "deleted_at",
|
|
"type": "`string` \\| `Date` \\| `null`",
|
|
"description": "The date with timezone at which the resource was deleted.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "id",
|
|
"type": "`string`",
|
|
"description": "The stock location's ID",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "metadata",
|
|
"type": "`Record<string, unknown>` \\| `null`",
|
|
"description": "An optional key-value map with additional details",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "name",
|
|
"type": "`string`",
|
|
"description": "The name of the stock location",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "updated_at",
|
|
"type": "`string` \\| `Date`",
|
|
"description": "The date with timezone at which the resource was updated.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "sales_channels",
|
|
"type": "`any`[]",
|
|
"description": "The associated sales channels.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
]} />
|
|
|
|
___
|
|
|
|
#### delete
|
|
|
|
Delete a 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.stockLocations
|
|
.delete(stockLocationId)
|
|
.then(({ id, object, deleted }) => {
|
|
console.log(id)
|
|
})
|
|
```
|
|
|
|
##### Parameters
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "id",
|
|
"type": "`string`",
|
|
"description": "The stock location'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)<[DeleteResponse](../internal/types/internal.DeleteResponse-1.mdx)>",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"description": "Resolves to the deletion operation's details.",
|
|
"expandable": false,
|
|
"children": [
|
|
{
|
|
"name": "DeleteResponse",
|
|
"type": "`object`",
|
|
"description": "The fields returned in the response of a DELETE request.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": [
|
|
{
|
|
"name": "deleted",
|
|
"type": "`boolean`",
|
|
"description": "Whether the item was deleted successfully.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "id",
|
|
"type": "`string`",
|
|
"description": "The ID of the item that was deleted.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "object",
|
|
"type": "`string`",
|
|
"description": "The type of the item that was deleted.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
]} />
|
|
|
|
___
|
|
|
|
#### list
|
|
|
|
Retrieve a list of stock locations. The stock locations can be filtered by fields such as `name` or `created_at` passed in the `query` parameter.
|
|
The stock locations can also be sorted or paginated.
|
|
|
|
##### Example
|
|
|
|
To list stock locations:
|
|
|
|
```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.stockLocations
|
|
.list()
|
|
.then(({ stock_locations, limit, offset, count }) => {
|
|
console.log(stock_locations.length)
|
|
})
|
|
```
|
|
|
|
To specify relations that should be retrieved within the stock locations:
|
|
|
|
```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.stockLocations
|
|
.list({
|
|
expand: "address",
|
|
})
|
|
.then(({ stock_locations, limit, offset, count }) => {
|
|
console.log(stock_locations.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.stockLocations
|
|
.list({
|
|
expand: "address",
|
|
limit,
|
|
offset,
|
|
})
|
|
.then(({ stock_locations, limit, offset, count }) => {
|
|
console.log(stock_locations.length)
|
|
})
|
|
```
|
|
|
|
##### Parameters
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "query",
|
|
"type": "[AdminGetStockLocationsParams](../internal/classes/internal.AdminGetStockLocationsParams.mdx)",
|
|
"description": "Filters and pagination configurations to apply on the retrieved stock locations.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": [
|
|
{
|
|
"name": "address_id",
|
|
"type": "`string` \\| `string`[]",
|
|
"description": "Filter stock locations by the ID of their associated addresses.",
|
|
"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` \\| `string`[]",
|
|
"description": "IDs to filter stock locations 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` \\| `string`[]",
|
|
"description": "Names to filter stock locations 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": "sales_channel_id",
|
|
"type": "`string` \\| `string`[]",
|
|
"description": "Filter stock locations by the ID of their associated sales channels.",
|
|
"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)<[AdminStockLocationsListRes](../internal/types/internal.AdminStockLocationsListRes.mdx)>",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"description": "Resolves to the list of stock locations with pagination fields.",
|
|
"expandable": false,
|
|
"children": [
|
|
{
|
|
"name": "AdminStockLocationsListRes",
|
|
"type": "[PaginatedResponse](../internal/types/internal.PaginatedResponse-1.mdx) & ``{ stock_locations: [StockLocationExpandedDTO](../internal/types/internal.StockLocationExpandedDTO.mdx)[] }``",
|
|
"description": "The list of stock locations 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": "stock_locations",
|
|
"type": "[StockLocationExpandedDTO](../internal/types/internal.StockLocationExpandedDTO.mdx)[]",
|
|
"description": "",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": [
|
|
{
|
|
"name": "address",
|
|
"type": "[StockLocationAddressDTO](../StockLocationTypes/types/internal.internal-1.StockLocationTypes.StockLocationAddressDTO.mdx)",
|
|
"description": "The Address of the Stock Location",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "address_id",
|
|
"type": "`string`",
|
|
"description": "Stock location address' ID",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "created_at",
|
|
"type": "`string` \\| `Date`",
|
|
"description": "The date with timezone at which the resource was created.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "deleted_at",
|
|
"type": "`string` \\| `Date` \\| `null`",
|
|
"description": "The date with timezone at which the resource was deleted.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "id",
|
|
"type": "`string`",
|
|
"description": "The stock location's ID",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "metadata",
|
|
"type": "`Record<string, unknown>` \\| `null`",
|
|
"description": "An optional key-value map with additional details",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "name",
|
|
"type": "`string`",
|
|
"description": "The name of the stock location",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "updated_at",
|
|
"type": "`string` \\| `Date`",
|
|
"description": "The date with timezone at which the resource was updated.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "sales_channels",
|
|
"type": "`any`[]",
|
|
"description": "The associated sales channels.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
]} />
|
|
|
|
___
|
|
|
|
#### retrieve
|
|
|
|
Retrieve a stock location'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.stockLocations
|
|
.retrieve(stockLocationId)
|
|
.then(({ stock_location }) => {
|
|
console.log(stock_location.id)
|
|
})
|
|
```
|
|
|
|
##### Parameters
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "itemId",
|
|
"type": "`string`",
|
|
"description": "The stock location'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)<[AdminStockLocationsRes](../internal/types/internal.AdminStockLocationsRes.mdx)>",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"description": "Resolves to the stock location's details.",
|
|
"expandable": false,
|
|
"children": [
|
|
{
|
|
"name": "AdminStockLocationsRes",
|
|
"type": "`object`",
|
|
"description": "The stock location's details.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": [
|
|
{
|
|
"name": "stock_location",
|
|
"type": "[StockLocationExpandedDTO](../internal/types/internal.StockLocationExpandedDTO.mdx)",
|
|
"description": "Stock location details.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": [
|
|
{
|
|
"name": "address",
|
|
"type": "[StockLocationAddressDTO](../StockLocationTypes/types/internal.internal-1.StockLocationTypes.StockLocationAddressDTO.mdx)",
|
|
"description": "The Address of the Stock Location",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "address_id",
|
|
"type": "`string`",
|
|
"description": "Stock location address' ID",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "created_at",
|
|
"type": "`string` \\| `Date`",
|
|
"description": "The date with timezone at which the resource was created.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "deleted_at",
|
|
"type": "`string` \\| `Date` \\| `null`",
|
|
"description": "The date with timezone at which the resource was deleted.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "id",
|
|
"type": "`string`",
|
|
"description": "The stock location's ID",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "metadata",
|
|
"type": "`Record<string, unknown>` \\| `null`",
|
|
"description": "An optional key-value map with additional details",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "name",
|
|
"type": "`string`",
|
|
"description": "The name of the stock location",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "updated_at",
|
|
"type": "`string` \\| `Date`",
|
|
"description": "The date with timezone at which the resource was updated.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "sales_channels",
|
|
"type": "`any`[]",
|
|
"description": "The associated sales channels.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
]} />
|
|
|
|
___
|
|
|
|
#### update
|
|
|
|
Update a stock location'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.stockLocations
|
|
.update(stockLocationId, {
|
|
name: "Main Warehouse",
|
|
})
|
|
.then(({ stock_location }) => {
|
|
console.log(stock_location.id)
|
|
})
|
|
```
|
|
|
|
##### Parameters
|
|
|
|
<ParameterTypes parameters={[
|
|
{
|
|
"name": "stockLocationId",
|
|
"type": "`string`",
|
|
"description": "The stock location's ID.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "payload",
|
|
"type": "[AdminPostStockLocationsLocationReq](../internal/classes/internal.AdminPostStockLocationsLocationReq.mdx)",
|
|
"description": "The attributes to be updated in the stock location.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": [
|
|
{
|
|
"name": "address",
|
|
"type": "[StockLocationAddress](../internal/classes/internal.StockLocationAddress-1.mdx)",
|
|
"description": "The data of an associated address to create or update.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": [
|
|
{
|
|
"name": "address_1",
|
|
"type": "`string`",
|
|
"description": "First line address.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "address_2",
|
|
"type": "`string`",
|
|
"description": "Second line address.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "city",
|
|
"type": "`string`",
|
|
"description": "City.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "company",
|
|
"type": "`string`",
|
|
"description": "Company.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "country_code",
|
|
"type": "`string`",
|
|
"description": "Country code.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "phone",
|
|
"type": "`string`",
|
|
"description": "Phone.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "postal_code",
|
|
"type": "`string`",
|
|
"description": "Postal code.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "province",
|
|
"type": "`string`",
|
|
"description": "Province.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "address_id",
|
|
"type": "`string`",
|
|
"description": "the stock location address ID",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "metadata",
|
|
"type": "`Record<string, unknown>`",
|
|
"description": "An optional key-value map with additional details",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "name",
|
|
"type": "`string`",
|
|
"description": "the name of the stock location",
|
|
"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)<[AdminStockLocationsRes](../internal/types/internal.AdminStockLocationsRes.mdx)>",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"description": "Resolves to the stock location's details.",
|
|
"expandable": false,
|
|
"children": [
|
|
{
|
|
"name": "AdminStockLocationsRes",
|
|
"type": "`object`",
|
|
"description": "The stock location's details.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": [
|
|
{
|
|
"name": "stock_location",
|
|
"type": "[StockLocationExpandedDTO](../internal/types/internal.StockLocationExpandedDTO.mdx)",
|
|
"description": "Stock location details.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": [
|
|
{
|
|
"name": "address",
|
|
"type": "[StockLocationAddressDTO](../StockLocationTypes/types/internal.internal-1.StockLocationTypes.StockLocationAddressDTO.mdx)",
|
|
"description": "The Address of the Stock Location",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "address_id",
|
|
"type": "`string`",
|
|
"description": "Stock location address' ID",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "created_at",
|
|
"type": "`string` \\| `Date`",
|
|
"description": "The date with timezone at which the resource was created.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "deleted_at",
|
|
"type": "`string` \\| `Date` \\| `null`",
|
|
"description": "The date with timezone at which the resource was deleted.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "id",
|
|
"type": "`string`",
|
|
"description": "The stock location's ID",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "metadata",
|
|
"type": "`Record<string, unknown>` \\| `null`",
|
|
"description": "An optional key-value map with additional details",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "name",
|
|
"type": "`string`",
|
|
"description": "The name of the stock location",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "updated_at",
|
|
"type": "`string` \\| `Date`",
|
|
"description": "The date with timezone at which the resource was updated.",
|
|
"optional": false,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
},
|
|
{
|
|
"name": "sales_channels",
|
|
"type": "`any`[]",
|
|
"description": "The associated sales channels.",
|
|
"optional": true,
|
|
"defaultValue": "",
|
|
"expandable": false,
|
|
"children": []
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
]} />
|