--- 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 ", "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 ", "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`](../modules/internal.mdx#stocklocationexpandeddto)", "description": "Stock location details.", "optional": false, "defaultValue": "", "expandable": false, "children": [ { "name": "address", "type": "[`StockLocationAddressDTO`](../internal-1/modules/internal.internal-1.StockLocationTypes.mdx#stocklocationaddressdto)", "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 ", "description": "Custom headers to attach to the request.", "optional": false, "defaultValue": "{}", "expandable": false, "children": [] } ]} /> #### Returns ", "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 ", "description": "Custom headers to attach to the request.", "optional": false, "defaultValue": "{}", "expandable": false, "children": [] } ]} /> #### Returns ", "optional": false, "defaultValue": "", "description": "Resolves to the list of stock locations with pagination fields.", "expandable": false, "children": [ { "name": "AdminStockLocationsListRes", "type": "[`PaginatedResponse`](../modules/internal.mdx#paginatedresponse) & { `stock_locations`: [`StockLocationExpandedDTO`](../modules/internal.mdx#stocklocationexpandeddto)[] }", "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`](../modules/internal.mdx#stocklocationexpandeddto)[]", "description": "", "optional": false, "defaultValue": "", "expandable": false, "children": [ { "name": "address", "type": "[`StockLocationAddressDTO`](../internal-1/modules/internal.internal-1.StockLocationTypes.mdx#stocklocationaddressdto)", "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 ", "description": "Custom headers to attach to the request.", "optional": false, "defaultValue": "{}", "expandable": false, "children": [] } ]} /> #### Returns ", "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`](../modules/internal.mdx#stocklocationexpandeddto)", "description": "Stock location details.", "optional": false, "defaultValue": "", "expandable": false, "children": [ { "name": "address", "type": "[`StockLocationAddressDTO`](../internal-1/modules/internal.internal-1.StockLocationTypes.mdx#stocklocationaddressdto)", "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 ", "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 ", "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`](../modules/internal.mdx#stocklocationexpandeddto)", "description": "Stock location details.", "optional": false, "defaultValue": "", "expandable": false, "children": [ { "name": "address", "type": "[`StockLocationAddressDTO`](../internal-1/modules/internal.internal-1.StockLocationTypes.mdx#stocklocationaddressdto)", "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": [] } ] } ] } ] } ]} />