--- 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`", "description": "Custom headers to attach to the request.", "optional": false, "defaultValue": "{}", "expandable": false, "children": [] } ]} /> #### Returns ` \\| ``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 ___ ### 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 ` \\| ``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 ` \\| ``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`", "description": "Custom headers to attach to the request.", "optional": false, "defaultValue": "{}", "expandable": false, "children": [] } ]} /> #### Returns ` \\| ``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": [] } ] } ] } ] } ]} />