--- displayed_sidebar: jsClientSidebar slug: /references/js-client/AdminReservationsResource --- import ParameterTypes from "@site/src/components/ParameterTypes" # AdminReservationsResource This class is used to send requests to [Admin Reservation API Routes](https://docs.medusajs.com/api/admin#reservations). To use these API Routes, make sure to install the [@medusajs/inventory](https://docs.medusajs.com/modules/multiwarehouse/install-modules#inventory-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.reservations` property. Reservations, provided by the [Inventory Module](https://docs.medusajs.com/modules/multiwarehouse/inventory-module), are quantities of an item that are reserved, typically when an order is placed but not yet fulfilled. Reservations can be associated with any resources, but commonly with line items of an order. Related Guide: [How to manage item allocations in orders](https://docs.medusajs.com/modules/multiwarehouse/admin/manage-item-allocations-in-orders). ## Methods ### create Create a reservation which can be associated with any resource, such as an order's line item. #### 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.reservations .create({ line_item_id: "item_123", location_id: "loc_123", inventory_item_id: "iitem_123", quantity: 1, }) .then(({ reservation }) => { console.log(reservation.id) }) ``` #### Parameters `", "description": "An optional set of key-value pairs with additional information.", "optional": true, "defaultValue": "", "expandable": false, "children": [] }, { "name": "quantity", "type": "`number`", "description": "The quantity to reserve.", "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": "quantity", "type": "`number`", "description": "The id of the reservation item", "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": [] } ] } ] } ] } ]} /> ___ ### delete Delete a reservation. Associated resources, such as the line item, will not be 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.reservations .delete(reservationId) .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 reservations. The reservations can be filtered by fields such as `location_id` or `quantity` passed in the `query` parameter. The reservations can also be paginated. #### Example To list reservations: ```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.reservations .list() .then(({ reservations, count, limit, offset }) => { console.log(reservations.length) }) ``` To specify relations that should be retrieved within the reservations: ```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.reservations .list({ expand: "location", }) .then(({ reservations, count, limit, offset }) => { console.log(reservations.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.reservations .list({ expand: "location", limit, offset, }) .then(({ reservations, count, limit, offset }) => { console.log(reservations.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": "quantity", "type": "`number`", "description": "The id of the reservation item", "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": [] } ] } ] } ] } ]} /> ___ ### retrieve Retrieve a reservation'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.reservations.retrieve(reservationId).then(({ reservation }) => { console.log(reservation.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": "quantity", "type": "`number`", "description": "The id of the reservation item", "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": [] } ] } ] } ] } ]} /> ___ ### update Update a reservation'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.reservations .update(reservationId, { quantity: 3, }) .then(({ reservation }) => { console.log(reservation.id) }) ``` #### Parameters `", "description": "An optional set of key-value pairs with additional information.", "optional": true, "defaultValue": "", "expandable": false, "children": [] }, { "name": "quantity", "type": "`number`", "description": "The quantity to reserve.", "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": "quantity", "type": "`number`", "description": "The id of the reservation item", "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": [] } ] } ] } ] } ]} />