docs: update docusaurus to v3 (#5625)

* update dependencies

* update onboarding mdx

* fixes for mdx issues

* fixes for mdx compatibility

* resolve mdx errors

* fixes in reference

* fix check errors

* revert change in vale action

* fix node version in action

* fix summary in markdown
This commit is contained in:
Shahed Nasser
2023-11-13 20:11:50 +02:00
committed by GitHub
parent cedab58339
commit c6dff873de
2265 changed files with 46163 additions and 47195 deletions

View File

@@ -79,84 +79,84 @@ Item allocations are created automatically for items that are associated with pr
You can create an item allocation by sending a request to the [Create a Reservation API Route](https://docs.medusajs.com/api/admin#reservations_postreservations):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.reservations.create({
line_item_id,
location_id,
inventory_item_id,
quantity,
})
.then(({ reservation }) => {
console.log(reservation.id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminCreateReservation } from "medusa-react"
const CreateReservation = () => {
const createReservation = useAdminCreateReservation()
// ...
const handleCreate = () => {
createReservation.mutate({
```ts
medusa.admin.reservations.create({
line_item_id,
location_id,
inventory_item_id,
quantity,
})
}
.then(({ reservation }) => {
console.log(reservation.id)
})
```
// ...
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default CreateReservation
```
```tsx
import { useAdminCreateReservation } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const CreateReservation = () => {
const createReservation = useAdminCreateReservation()
// ...
```ts
fetch(`<BACKEND_URL>/admin/reservations`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
line_item_id,
location_id,
inventory_item_id,
quantity,
}),
})
.then((response) => response.json())
.then(({ reservation }) => {
console.log(reservation.id)
})
```
const handleCreate = () => {
createReservation.mutate({
line_item_id,
location_id,
inventory_item_id,
quantity,
})
}
</TabItem>
<TabItem value="curl" label="cURL">
// ...
}
```bash
curl -L -X POST '<BACKEND_URL>/admin/reservations' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"line_item_id": "<LINE_ITEM_ID>",
"location_id": "<LOC_ID>",
"inventory_item_id": "<INV_ITEM_ID>",
"quantity": 1
}'
```
export default CreateReservation
```
</TabItem>
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/reservations`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
line_item_id,
location_id,
inventory_item_id,
quantity,
}),
})
.then((response) => response.json())
.then(({ reservation }) => {
console.log(reservation.id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/reservations' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"line_item_id": "<LINE_ITEM_ID>",
"location_id": "<LOC_ID>",
"inventory_item_id": "<INV_ITEM_ID>",
"quantity": 1
}'
```
</TabItem>
</Tabs>
This API Route requires the following body parameters:
@@ -175,72 +175,72 @@ When listing item allocations, by default, youll be retrieving all item alloc
You can retrieve the item allocations of a line item in an order using the [List Reservations API Route](https://docs.medusajs.com/api/admin#reservations_getreservations):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.reservations.list({
line_item_id,
})
.then(({ reservations, count, limit, offset }) => {
console.log(reservations.length)
})
```
```ts
medusa.admin.reservations.list({
line_item_id,
})
.then(({ reservations, count, limit, offset }) => {
console.log(reservations.length)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminReservations } from "medusa-react"
```tsx
import { useAdminReservations } from "medusa-react"
function Reservations() {
const { reservations, isLoading } = useAdminReservations({
line_item_id,
})
function Reservations() {
const { reservations, isLoading } = useAdminReservations({
line_item_id,
})
return (
<div>
{isLoading && <span>Loading...</span>}
{reservations && !reservations.length && (
<span>No Reservations</span>
)}
{reservations && reservations.length > 0 && (
<ul>
{reservations.map((reservation) => (
<li key={reservation.id}>{reservation.quantity}</li>
))}
</ul>
)}
</div>
)
}
return (
<div>
{isLoading && <span>Loading...</span>}
{reservations && !reservations.length && (
<span>No Reservations</span>
)}
{reservations && reservations.length > 0 && (
<ul>
{reservations.map((reservation) => (
<li key={reservation.id}>{reservation.quantity}</li>
))}
</ul>
)}
</div>
)
}
export default Reservations
```
export default Reservations
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
<!-- eslint-disable max-len -->
```ts
fetch(`<BACKEND_URL>/admin/reservations?line_item_id=${lineItemId}`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ reservations, count, limit, offset }) => {
console.log(reservations.length)
})
```
```ts
fetch(`<BACKEND_URL>/admin/reservations?line_item_id=${lineItemId}`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ reservations, count, limit, offset }) => {
console.log(reservations.length)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X GET '<BACKEND_URL>/admin/reservations?line_item_id=<LINE_ITEM_ID>' \
-H 'Authorization: Bearer <API_TOKEN>'
```
```bash
curl -L -X GET '<BACKEND_URL>/admin/reservations?line_item_id=<LINE_ITEM_ID>' \
-H 'Authorization: Bearer <API_TOKEN>'
```
</TabItem>
</TabItem>
</Tabs>
This API Route doesn't require any path or query parameters. As mentioned earlier, you can pass query parameters to filter the reservations. In the code snippets above, you filter the reservations by a line item ID. You can, however, filter by other attributes, such as the ID of the location. You can refer to the [API reference](https://docs.medusajs.com/api/admin#reservations_getreservations) for a full list of query parameters.
@@ -252,61 +252,61 @@ The request returns the reservations along with [pagination fields](https://docs
You can retrieve a single item allocation by its ID using the [Get a Reservation API Route](https://docs.medusajs.com/api/admin#reservations_getreservationsreservation):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.reservations.retrieve(reservationId)
.then(({ reservation }) => {
console.log(reservation.id)
})
```
```ts
medusa.admin.reservations.retrieve(reservationId)
.then(({ reservation }) => {
console.log(reservation.id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminReservation } from "medusa-react"
```tsx
import { useAdminReservation } from "medusa-react"
function Reservation() {
const {
reservation,
isLoading } = useAdminReservation(reservationId)
function Reservation() {
const {
reservation,
isLoading } = useAdminReservation(reservationId)
return (
<div>
{isLoading && <span>Loading...</span>}
{reservation && (
<span>{reservation.quantity}</span>
)}
</div>
)
}
return (
<div>
{isLoading && <span>Loading...</span>}
{reservation && (
<span>{reservation.quantity}</span>
)}
</div>
)
}
export default Reservation
```
export default Reservation
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/reservations/${reservationId}`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ reservation }) => {
console.log(reservation.id)
})
```
```ts
fetch(`<BACKEND_URL>/admin/reservations/${reservationId}`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ reservation }) => {
console.log(reservation.id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X GET '<BACKEND_URL>/admin/reservations/<RESERVATION_ID>' \
-H 'Authorization: Bearer <API_TOKEN>'
```
```bash
curl -L -X GET '<BACKEND_URL>/admin/reservations/<RESERVATION_ID>' \
-H 'Authorization: Bearer <API_TOKEN>'
```
</TabItem>
</TabItem>
</Tabs>
This API Route requires the reservations ID as a path parameter.
@@ -318,74 +318,74 @@ The request returns the reservation as an object.
You can update an item allocation to change the location to allocate from or the quantity to allocate by sending a request to the [Update Reservation API Route](https://docs.medusajs.com/api/admin#reservations_postreservationsreservation):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.reservations.update(reservationId, {
quantity,
})
.then(({ reservation }) => {
console.log(reservation.id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminUpdateReservation } from "medusa-react"
const UpdateReservation = () => {
const updateReservation = useAdminUpdateReservation(
reservationId
)
// ...
const handleCreate = () => {
updateReservation.mutate({
```ts
medusa.admin.reservations.update(reservationId, {
quantity,
})
}
.then(({ reservation }) => {
console.log(reservation.id)
})
```
// ...
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default UpdateReservation
```
```tsx
import { useAdminUpdateReservation } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const UpdateReservation = () => {
const updateReservation = useAdminUpdateReservation(
reservationId
)
// ...
```ts
fetch(`<BACKEND_URL>/admin/reservations/${reservationId}`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
quantity,
}),
})
.then((response) => response.json())
.then(({ reservation }) => {
console.log(reservation.id)
})
```
const handleCreate = () => {
updateReservation.mutate({
quantity,
})
}
</TabItem>
<TabItem value="curl" label="cURL">
// ...
}
```bash
curl -L -X POST '<BACKEND_URL>/admin/reservations/<RESERVATION_ID>' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"quantity": 3
}'
```
export default UpdateReservation
```
</TabItem>
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/reservations/${reservationId}`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
quantity,
}),
})
.then((response) => response.json())
.then(({ reservation }) => {
console.log(reservation.id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/reservations/<RESERVATION_ID>' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"quantity": 3
}'
```
</TabItem>
</Tabs>
This API Route requires the ID of the reservation as a path parameter.
@@ -405,60 +405,60 @@ Deleting an item allocation means that the quantity that was previously reserved
You can delete an item allocation by sending a request to the [Delete Reservation API Route](https://docs.medusajs.com/api/admin#reservations_deletereservationsreservation):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.reservations.delete(reservationId)
.then(({ id, object, deleted }) => {
console.log(id)
})
```
```ts
medusa.admin.reservations.delete(reservationId)
.then(({ id, object, deleted }) => {
console.log(id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminDeleteReservation } from "medusa-react"
```tsx
import { useAdminDeleteReservation } from "medusa-react"
const DeleteReservation = () => {
const deleteReservation = useAdminDeleteReservation(
reservationId
)
// ...
const DeleteReservation = () => {
const deleteReservation = useAdminDeleteReservation(
reservationId
)
// ...
const handleDelete = () => {
deleteReservation.mutate()
}
const handleDelete = () => {
deleteReservation.mutate()
}
// ...
}
// ...
}
export default DeleteReservation
```
export default DeleteReservation
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/reservations/${reservationId}`, {
credentials: "include",
method: "DELETE",
})
.then((response) => response.json())
.then(({ id, object, deleted }) => {
console.log(id)
})
```
```ts
fetch(`<BACKEND_URL>/admin/reservations/${reservationId}`, {
credentials: "include",
method: "DELETE",
})
.then((response) => response.json())
.then(({ id, object, deleted }) => {
console.log(id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X DELETE '<BACKEND_URL>/admin/reservations/<RESERVATION_ID>' \
-H 'Authorization: Bearer <API_TOKEN>'
```
```bash
curl -L -X DELETE '<BACKEND_URL>/admin/reservations/<RESERVATION_ID>' \
-H 'Authorization: Bearer <API_TOKEN>'
```
</TabItem>
</TabItem>
</Tabs>
This API Route requires the reservation ID to be passed as a path parameter.
@@ -476,36 +476,10 @@ The request returns the following fields:
When you create a fulfillment of an order, you can specify the location to fulfill the item from by passing the `location_id` parameter:
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.orders.createFulfillment(orderId, {
items: [
{
item_id,
quantity,
},
],
// ...other parameters
location_id,
})
.then(({ order }) => {
console.log(order.id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminCreateFulfillment } from "medusa-react"
const CreateFulfillment = () => {
const createFulfillment = useAdminCreateFulfillment(orderId)
// ...
const handleCreate = () => {
createFulfillment.mutate({
```ts
medusa.admin.orders.createFulfillment(orderId, {
items: [
{
item_id,
@@ -515,60 +489,86 @@ const CreateFulfillment = () => {
// ...other parameters
location_id,
})
}
.then(({ order }) => {
console.log(order.id)
})
```
// ...
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default CreateFulfillment
```
```tsx
import { useAdminCreateFulfillment } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const CreateFulfillment = () => {
const createFulfillment = useAdminCreateFulfillment(orderId)
// ...
```ts
fetch(`<BACKEND_URL>/admin/orders/${orderId}/fulfillment`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
items: [
{
item_id,
quantity,
const handleCreate = () => {
createFulfillment.mutate({
items: [
{
item_id,
quantity,
},
],
// ...other parameters
location_id,
})
}
// ...
}
export default CreateFulfillment
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/orders/${orderId}/fulfillment`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
],
// ...other parameters
location_id,
}),
})
.then((response) => response.json())
.then(({ order }) => {
console.log(order.id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/fulfillment' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"items": [
body: JSON.stringify({
items: [
{
"item_id": "<LINE_ITEM_ID>",
"quantity": 1
}
item_id,
quantity,
},
],
"location_id": "<LOC_ID>"
}'
```
// ...other parameters
location_id,
}),
})
.then((response) => response.json())
.then(({ order }) => {
console.log(order.id)
})
```
</TabItem>
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/fulfillment' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"items": [
{
"item_id": "<LINE_ITEM_ID>",
"quantity": 1
}
],
"location_id": "<LOC_ID>"
}'
```
</TabItem>
</Tabs>
The `location_id` is an optional parameter that allows you to specify where to fulfill the item from. This subsequently decrements the stock quantity of the product variant in that location.
@@ -582,99 +582,99 @@ You can learn more about this API Route's parameters and response in the [API re
When requesting a return, you can specify the location to return the item to by passing the `location_id` parameter:
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.orders.requestReturn(orderId, {
items: [
{
item_id,
quantity: 1,
},
],
// other parameters...
location_id,
})
.then(({ order }) => {
console.log(order.id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminRequestReturn } from "medusa-react"
const RequestReturn = () => {
const requestReturn = useAdminRequestReturn(orderId)
// ...
const handleRequest = () => {
requestReturn.mutate({
```ts
medusa.admin.orders.requestReturn(orderId, {
items: [
{
item_id,
quantity,
quantity: 1,
},
],
// ...other parameters
// other parameters...
location_id,
})
}
.then(({ order }) => {
console.log(order.id)
})
```
// ...
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default RequestReturn
```
```tsx
import { useAdminRequestReturn } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const RequestReturn = () => {
const requestReturn = useAdminRequestReturn(orderId)
// ...
```ts
fetch(`<BACKEND_URL>/admin/orders/${orderId}/return`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
items: [
{
item_id,
quantity,
const handleRequest = () => {
requestReturn.mutate({
items: [
{
item_id,
quantity,
},
],
// ...other parameters
location_id,
})
}
// ...
}
export default RequestReturn
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/orders/${orderId}/return`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
],
// ...other parameters
location_id,
}),
})
.then((response) => response.json())
.then(({ order }) => {
console.log(order.id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/return' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"items": [
body: JSON.stringify({
items: [
{
"item_id": "<LINE_ITEM_ID>",
"quantity": 1
}
item_id,
quantity,
},
],
"location_id": "<LOC_ID>"
}'
```
// ...other parameters
location_id,
}),
})
.then((response) => response.json())
.then(({ order }) => {
console.log(order.id)
})
```
</TabItem>
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/orders/<ORDER_ID>/return' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"items": [
{
"item_id": "<LINE_ITEM_ID>",
"quantity": 1
}
],
"location_id": "<LOC_ID>"
}'
```
</TabItem>
</Tabs>
The `location_id` is an optional parameter that allows you to specify where to return the item to. This subsequently increments the stock quantity of the product variant in that location.

View File

@@ -72,66 +72,66 @@ You can learn more about [authenticating as an admin user in the API reference](
You can list all reservations in your store by sending a request to the [List Reservations API Route](https://docs.medusajs.com/api/admin#reservations_getreservations):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.reservations.list()
.then(({ reservations, limit, count, offset }) => {
console.log(reservations.length)
})
```
```ts
medusa.admin.reservations.list()
.then(({ reservations, limit, count, offset }) => {
console.log(reservations.length)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminReservations } from "medusa-react"
```tsx
import { useAdminReservations } from "medusa-react"
const Reservations = () => {
const { reservations, isLoading } = useAdminReservations()
const Reservations = () => {
const { reservations, isLoading } = useAdminReservations()
return (
<div>
{isLoading && <span>Loading...</span>}
{reservations && !reservations.length && (
<span>No Reservations</span>
)}
{reservations && reservations.length > 0 && (
<ul>
{reservations.map((reservation) => (
<li key={reservation.id}>{reservation.quantity}</li>
))}
</ul>
)}
</div>
)
}
return (
<div>
{isLoading && <span>Loading...</span>}
{reservations && !reservations.length && (
<span>No Reservations</span>
)}
{reservations && reservations.length > 0 && (
<ul>
{reservations.map((reservation) => (
<li key={reservation.id}>{reservation.quantity}</li>
))}
</ul>
)}
</div>
)
}
export default Reservations
```
export default Reservations
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/reservations`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ reservations, limit, count, offset }) => {
console.log(reservations.length)
})
```
```ts
fetch(`<BACKEND_URL>/admin/reservations`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ reservations, limit, count, offset }) => {
console.log(reservations.length)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X GET '<BACKEND_URL>/admin/reservations' \
-H 'Authorization: Bearer <API_TOKEN>'
```
```bash
curl -L -X GET '<BACKEND_URL>/admin/reservations' \
-H 'Authorization: Bearer <API_TOKEN>'
```
</TabItem>
</TabItem>
</Tabs>
This API Route doesn't require any query or path parameters. You can pass it query parameters for filtering or pagination purposes. Check out the [API reference](https://docs.medusajs.com/api/admin#reservations_getreservations) for a list of accepted query parameters.
@@ -151,80 +151,80 @@ Before you create a reservation for a product variant, make sure youve create
You can create a reservation by sending a request to the [Create Reservation API Route](https://docs.medusajs.com/api/admin#reservations_postreservations):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.reservations.create({
location_id,
inventory_item_id,
quantity,
})
.then(({ reservation }) => {
console.log(reservation.id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminCreateReservation } from "medusa-react"
const CreateReservation = () => {
const createReservation = useAdminCreateReservation()
// ...
const handleCreate = () => {
createReservation.mutate({
```ts
medusa.admin.reservations.create({
location_id,
inventory_item_id,
quantity,
})
}
.then(({ reservation }) => {
console.log(reservation.id)
})
```
// ...
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default CreateReservation
```
```tsx
import { useAdminCreateReservation } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const CreateReservation = () => {
const createReservation = useAdminCreateReservation()
// ...
```ts
fetch(`<BACKEND_URL>/admin/reservations`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
location_id,
inventory_item_id,
quantity,
}),
})
.then((response) => response.json())
.then(({ reservation }) => {
console.log(reservation.id)
})
```
const handleCreate = () => {
createReservation.mutate({
location_id,
inventory_item_id,
quantity,
})
}
</TabItem>
<TabItem value="curl" label="cURL">
// ...
}
```bash
curl -L -X POST '<BACKEND_URL>/admin/reservations' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"location_id": "<LOC_ID>",
"inventory_item_id": "<INV_ITEM_ID>",
"quantity": 1
}'
```
export default CreateReservation
```
</TabItem>
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/reservations`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
location_id,
inventory_item_id,
quantity,
}),
})
.then((response) => response.json())
.then(({ reservation }) => {
console.log(reservation.id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/reservations' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"location_id": "<LOC_ID>",
"inventory_item_id": "<INV_ITEM_ID>",
"quantity": 1
}'
```
</TabItem>
</Tabs>
This API Route requires the following body parameters:
@@ -242,74 +242,74 @@ The request returns the created reservation as an object.
You can update a reservation by sending a request to the [Update Reservation API Route](https://docs.medusajs.com/api/admin#reservations_postreservationsreservation):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.reservations.update(reservationId, {
quantity,
})
.then(({ reservation }) => {
console.log(reservation.id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminUpdateReservation } from "medusa-react"
const UpdateReservation = () => {
const updateReservation = useAdminUpdateReservation(
reservationId
)
// ...
const handleCreate = () => {
updateReservation.mutate({
```ts
medusa.admin.reservations.update(reservationId, {
quantity,
})
}
.then(({ reservation }) => {
console.log(reservation.id)
})
```
// ...
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default UpdateReservation
```
```tsx
import { useAdminUpdateReservation } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const UpdateReservation = () => {
const updateReservation = useAdminUpdateReservation(
reservationId
)
// ...
```ts
fetch(`<BACKEND_URL>/admin/reservations/${reservationId}`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
quantity,
}),
})
.then((response) => response.json())
.then(({ reservation }) => {
console.log(reservation.id)
})
```
const handleCreate = () => {
updateReservation.mutate({
quantity,
})
}
</TabItem>
<TabItem value="curl" label="cURL">
// ...
}
```bash
curl -L -X POST '<BACKEND_URL>/admin/reservations/<RESERVATION_ID>' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"quantity": 3
}'
```
export default UpdateReservation
```
</TabItem>
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/reservations/${reservationId}`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
quantity,
}),
})
.then((response) => response.json())
.then(({ reservation }) => {
console.log(reservation.id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/reservations/<RESERVATION_ID>' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"quantity": 3
}'
```
</TabItem>
</Tabs>
This API Route requires the ID of the reservation as a path parameter.
@@ -329,60 +329,60 @@ The request returns the updated reservation as an object.
You can delete a reservation by sending a request to the [Delete Reservation API Route](https://docs.medusajs.com/api/admin#reservations_deletereservationsreservation):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.reservations.delete(reservationId)
.then(({ id, object, deleted }) => {
console.log(id)
})
```
```ts
medusa.admin.reservations.delete(reservationId)
.then(({ id, object, deleted }) => {
console.log(id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminDeleteReservation } from "medusa-react"
```tsx
import { useAdminDeleteReservation } from "medusa-react"
const DeleteReservation = () => {
const deleteReservation = useAdminDeleteReservation(
reservationId
)
// ...
const DeleteReservation = () => {
const deleteReservation = useAdminDeleteReservation(
reservationId
)
// ...
const handleDelete = () => {
deleteReservation.mutate()
}
const handleDelete = () => {
deleteReservation.mutate()
}
// ...
}
// ...
}
export default DeleteReservation
```
export default DeleteReservation
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/reservations/${reservationId}`, {
credentials: "include",
method: "DELETE",
})
.then((response) => response.json())
.then(({ id, object, deleted }) => {
console.log(id)
})
```
```ts
fetch(`<BACKEND_URL>/admin/reservations/${reservationId}`, {
credentials: "include",
method: "DELETE",
})
.then((response) => response.json())
.then(({ id, object, deleted }) => {
console.log(id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X DELETE '<BACKEND_URL>/admin/reservations/<RESERVATION_ID>' \
-H 'Authorization: Bearer <API_TOKEN>'
```
```bash
curl -L -X DELETE '<BACKEND_URL>/admin/reservations/<RESERVATION_ID>' \
-H 'Authorization: Bearer <API_TOKEN>'
```
</TabItem>
</TabItem>
</Tabs>
This API Route requires the reservation ID to be passed as a path parameter.

View File

@@ -62,70 +62,70 @@ You can learn more about [authenticating as an admin user in the API reference](
You can list stock locations by using the [List Stock Locations API Route](https://docs.medusajs.com/api/admin#stock-locations_getstocklocations):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.stockLocations.list()
.then(({ stock_locations, limit, offset, count }) => {
console.log(stock_locations.length)
})
```
```ts
medusa.admin.stockLocations.list()
.then(({ stock_locations, limit, offset, count }) => {
console.log(stock_locations.length)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminStockLocations } from "medusa-react"
```tsx
import { useAdminStockLocations } from "medusa-react"
function StockLocations() {
const {
stock_locations,
isLoading } = useAdminStockLocations()
function StockLocations() {
const {
stock_locations,
isLoading } = useAdminStockLocations()
return (
<div>
{isLoading && <span>Loading...</span>}
{stock_locations && !stock_locations.length && (
<span>No Locations</span>
)}
{stock_locations && stock_locations.length > 0 && (
<ul>
{stock_locations.map(
(location) => (
<li key={location.id}>{location.name}</li>
)
return (
<div>
{isLoading && <span>Loading...</span>}
{stock_locations && !stock_locations.length && (
<span>No Locations</span>
)}
</ul>
)}
</div>
)
}
{stock_locations && stock_locations.length > 0 && (
<ul>
{stock_locations.map(
(location) => (
<li key={location.id}>{location.name}</li>
)
)}
</ul>
)}
</div>
)
}
export default StockLocations
```
export default StockLocations
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/stock-locations`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ stock_locations, limit, offset, count }) => {
console.log(stock_locations.length)
})
```
```ts
fetch(`<BACKEND_URL>/admin/stock-locations`, {
credentials: "include",
})
.then((response) => response.json())
.then(({ stock_locations, limit, offset, count }) => {
console.log(stock_locations.length)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X GET '<BACKEND_URL>/admin/stock-locations' \
-H 'Authorization: Bearer <API_TOKEN>'
```
```bash
curl -L -X GET '<BACKEND_URL>/admin/stock-locations' \
-H 'Authorization: Bearer <API_TOKEN>'
```
</TabItem>
</TabItem>
</Tabs>
This API Route doesn't require any path or query parameters. You can, however, pass it query parameters to search or filter the list of stock locations. For example, you can pass the `q` query parameter to search through the locations by name. You can learn about available query parameters in the [API reference](https://docs.medusajs.com/api/admin#stock-locations_getstocklocations).
@@ -139,72 +139,72 @@ The request returns an array of stock location objects along with [pagination pa
You can create a stock location using the [Create a Stock Location API Route](https://docs.medusajs.com/api/admin#stock-locations_poststocklocations):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.stockLocations.create({
name: "Main Warehouse",
})
.then(({ stock_location }) => {
console.log(stock_location.id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminCreateStockLocation } from "medusa-react"
const CreateStockLocation = () => {
const createStockLocation = useAdminCreateStockLocation()
// ...
const handleCreate = () => {
createStockLocation.mutate({
```ts
medusa.admin.stockLocations.create({
name: "Main Warehouse",
})
}
.then(({ stock_location }) => {
console.log(stock_location.id)
})
```
// ...
}
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
export default CreateStockLocation
```
```tsx
import { useAdminCreateStockLocation } from "medusa-react"
</TabItem>
<TabItem value="fetch" label="Fetch API">
const CreateStockLocation = () => {
const createStockLocation = useAdminCreateStockLocation()
// ...
```ts
fetch(`<BACKEND_URL>/admin/stock-locations`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
name: "Main Warehouse",
}),
})
.then((response) => response.json())
.then(({ stock_location }) => {
console.log(stock_location.id)
})
```
const handleCreate = () => {
createStockLocation.mutate({
name: "Main Warehouse",
})
}
</TabItem>
<TabItem value="curl" label="cURL">
// ...
}
```bash
curl -L -X POST '<BACKEND_URL>/admin/stock-locations' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"name": "Main Warehouse"
}'
```
export default CreateStockLocation
```
</TabItem>
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/stock-locations`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
name: "Main Warehouse",
}),
})
.then((response) => response.json())
.then(({ stock_location }) => {
console.log(stock_location.id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/stock-locations' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"name": "Main Warehouse"
}'
```
</TabItem>
</Tabs>
This API Route requires in its body parameters the `name` field, which is the name of the stock location. You can also pass in the request body parameters other fields related to the address or metadata. You can learn more in the [API reference](https://docs.medusajs.com/api/admin#stock-locations_poststocklocations).
@@ -218,63 +218,63 @@ This request returns the created stock location as an object.
You can retrieve a stock location by sending a request to the [Get Stock Location API Route](https://docs.medusajs.com/api/admin#stock-locations_getstocklocationsstocklocation):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.stockLocations.retrieve(stockLocationId)
.then(({ stock_location }) => {
console.log(stock_location.id)
})
```
```ts
medusa.admin.stockLocations.retrieve(stockLocationId)
.then(({ stock_location }) => {
console.log(stock_location.id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminStockLocation } from "medusa-react"
```tsx
import { useAdminStockLocation } from "medusa-react"
function StockLocation() {
const {
stock_location,
isLoading } = useAdminStockLocation(stockLocationId)
function StockLocation() {
const {
stock_location,
isLoading } = useAdminStockLocation(stockLocationId)
return (
<div>
{isLoading && <span>Loading...</span>}
{stock_location && (
<span>{stock_location.name}</span>
)}
</div>
)
}
return (
<div>
{isLoading && <span>Loading...</span>}
{stock_location && (
<span>{stock_location.name}</span>
)}
</div>
)
}
export default StockLocation
```
export default StockLocation
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/stock-locations/${stockLocationId}`,
{
credentials: "include",
}
)
.then((response) => response.json())
.then(({ stock_location }) => {
console.log(stock_location.id)
})
```
```ts
fetch(`<BACKEND_URL>/admin/stock-locations/${stockLocationId}`,
{
credentials: "include",
}
)
.then((response) => response.json())
.then(({ stock_location }) => {
console.log(stock_location.id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X GET '<BACKEND_URL>/admin/stock-locations/<LOC_ID>' \
-H 'Authorization: Bearer <API_TOKEN>'
```
```bash
curl -L -X GET '<BACKEND_URL>/admin/stock-locations/<LOC_ID>' \
-H 'Authorization: Bearer <API_TOKEN>'
```
</TabItem>
</TabItem>
</Tabs>
This API Route requires the stock location ID to be passed as a path parameter. It also accepts query parameters related to expanding and selecting fields. You can learn more in the [API reference](https://docs.medusajs.com/api/admin#stock-locations_getstocklocationsstocklocation).
@@ -288,73 +288,73 @@ It returns the stock location as an object.
You can associate a stock location with a sales channel by sending a request to the [Associate Stock Channel API Route](https://docs.medusajs.com/api/admin#sales-channels_postsaleschannelssaleschannelstocklocation):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.salesChannels.addLocation(salesChannelId, {
location_id,
})
.then(({ sales_channel }) => {
console.log(sales_channel.id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminAddLocationToSalesChannel } from "medusa-react"
function StockLocation() {
const addLocation = useAdminAddLocationToSalesChannel()
// ...
const handleAdd = () => {
addLocation.mutate({
sales_channel_id,
```ts
medusa.admin.salesChannels.addLocation(salesChannelId, {
location_id,
})
}
}
.then(({ sales_channel }) => {
console.log(sales_channel.id)
})
```
export default StockLocation
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```tsx
import { useAdminAddLocationToSalesChannel } from "medusa-react"
function StockLocation() {
const addLocation = useAdminAddLocationToSalesChannel()
// ...
const handleAdd = () => {
addLocation.mutate({
sales_channel_id,
location_id,
})
}
}
export default StockLocation
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
<!-- eslint-disable max-len -->
```ts
fetch(`<BACKEND_URL>/admin/sales-channels/${salesChannelId}/stock-locations`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
location_id,
}),
})
.then((response) => response.json())
.then(({ sales_channel }) => {
console.log(sales_channel.id)
})
```
```ts
fetch(`<BACKEND_URL>/admin/sales-channels/${salesChannelId}/stock-locations`, {
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
location_id,
}),
})
.then((response) => response.json())
.then(({ sales_channel }) => {
console.log(sales_channel.id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/sales-channels/<CHANNEL_ID>/stock-locations' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"location_id": "<LOC_ID>"
}'
```
```bash
curl -L -X POST '<BACKEND_URL>/admin/sales-channels/<CHANNEL_ID>/stock-locations' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"location_id": "<LOC_ID>"
}'
```
</TabItem>
</TabItem>
</Tabs>
This API Route requires the ID of the sales channel as a path parameter. In its body parameters, it requires the ID of the stock location youre associating the sales channel with.
@@ -374,76 +374,76 @@ You can associate a location with more than one sales channel, and you can assoc
You can remove the association between a stock location and a sales channel by sending a request to the [Remove Stock Location Association API Route](https://docs.medusajs.com/api/admin#sales-channels_deletesaleschannelssaleschannelstocklocation):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.salesChannels.removeLocation(salesChannelId, {
location_id,
})
.then(({ id, object, deleted }) => {
console.log(id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import {
useAdminRemoveLocationFromSalesChannel,
} from "medusa-react"
function StockLocation() {
const removeLocation =
useAdminRemoveLocationFromSalesChannel()
// ...
const handleRemove = () => {
removeLocation.mutate({
sales_channel_id,
```ts
medusa.admin.salesChannels.removeLocation(salesChannelId, {
location_id,
})
}
}
.then(({ id, object, deleted }) => {
console.log(id)
})
```
export default StockLocation
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```tsx
import {
useAdminRemoveLocationFromSalesChannel,
} from "medusa-react"
function StockLocation() {
const removeLocation =
useAdminRemoveLocationFromSalesChannel()
// ...
const handleRemove = () => {
removeLocation.mutate({
sales_channel_id,
location_id,
})
}
}
export default StockLocation
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
<!-- eslint-disable max-len -->
```ts
fetch(`<BACKEND_URL>/admin/sales-channels/${salesChannelId}/stock-locations`, {
credentials: "include",
method: "DELETE",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
location_id,
}),
})
.then((response) => response.json())
.then(({ id, object, deleted }) => {
console.log(id)
})
```
```ts
fetch(`<BACKEND_URL>/admin/sales-channels/${salesChannelId}/stock-locations`, {
credentials: "include",
method: "DELETE",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
location_id,
}),
})
.then((response) => response.json())
.then(({ id, object, deleted }) => {
console.log(id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X DELETE '<BACKEND_URL>/admin/sales-channels/<CHANNEL_ID>/stock-locations' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"location_id": "<LOC_ID>"
}'
```
```bash
curl -L -X DELETE '<BACKEND_URL>/admin/sales-channels/<CHANNEL_ID>/stock-locations' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"location_id": "<LOC_ID>"
}'
```
</TabItem>
</TabItem>
</Tabs>
This API Route requires the ID of the sales channel as a path parameter. In its body parameters, it requires the ID of the stock location youre removing the association of the sales channel with.
@@ -467,74 +467,74 @@ This request does not delete the stock location. It only removes the association
You can update a stock location by sending a request to the [Update Stock Location API Route](https://docs.medusajs.com/api/admin#stock-locations_poststocklocationsstocklocation):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.stockLocations.update(stockLocationId, {
name: "Warehouse",
})
.then(({ stock_location }) => {
console.log(stock_location.id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminUpdateStockLocation } from "medusa-react"
function StockLocation() {
const updateLocation = useAdminUpdateStockLocation(
stockLocationId
)
// ...
const handleRemove = () => {
updateLocation.mutate({
```ts
medusa.admin.stockLocations.update(stockLocationId, {
name: "Warehouse",
})
}
}
.then(({ stock_location }) => {
console.log(stock_location.id)
})
```
export default StockLocation
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```tsx
import { useAdminUpdateStockLocation } from "medusa-react"
```ts
fetch(`<BACKEND_URL>/admin/stock-locations/${stockLocationId}`,
{
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
name: "Warehouse",
}),
}
)
.then((response) => response.json())
.then(({ stock_location }) => {
console.log(stock_location.id)
})
```
function StockLocation() {
const updateLocation = useAdminUpdateStockLocation(
stockLocationId
)
// ...
</TabItem>
<TabItem value="curl" label="cURL">
const handleRemove = () => {
updateLocation.mutate({
name: "Warehouse",
})
}
}
```bash
curl -L -X POST '<BACKEND_URL>/admin/stock-locations/<LOC_ID>' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"name": "Main Warehouse"
}'
```
export default StockLocation
```
</TabItem>
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/stock-locations/${stockLocationId}`,
{
credentials: "include",
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
name: "Warehouse",
}),
}
)
.then((response) => response.json())
.then(({ stock_location }) => {
console.log(stock_location.id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X POST '<BACKEND_URL>/admin/stock-locations/<LOC_ID>' \
-H 'Authorization: Bearer <API_TOKEN>' \
-H 'Content-Type: application/json' \
--data-raw '{
"name": "Main Warehouse"
}'
```
</TabItem>
</Tabs>
This API Route requires the ID of a stock location as a path parameter. In its body parameters, you can pass any of the locations attributes to update, such as the name or address. You can learn more in the [API reference](https://docs.medusajs.com/api/admin#stock-locations_poststocklocationsstocklocation).
@@ -548,60 +548,60 @@ This request returns the updated stock location as an object.
You can delete a stock location by sending a request to the [Delete Stock Location API Route](https://docs.medusajs.com/api/admin#stock-locations_deletestocklocationsstocklocation):
<Tabs groupId="request-type" isCodeTabs={true}>
<TabItem value="client" label="Medusa JS Client" default>
<TabItem value="client" label="Medusa JS Client" default>
```ts
medusa.admin.stockLocations.delete(stockLocationId)
.then(({ id, object, deleted }) => {
console.log(id)
})
```
```ts
medusa.admin.stockLocations.delete(stockLocationId)
.then(({ id, object, deleted }) => {
console.log(id)
})
```
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
</TabItem>
<TabItem value="medusa-react" label="Medusa React">
```tsx
import { useAdminDeleteStockLocation } from "medusa-react"
```tsx
import { useAdminDeleteStockLocation } from "medusa-react"
function StockLocation() {
const deleteLocation = useAdminDeleteStockLocation(
stockLocationId
)
// ...
function StockLocation() {
const deleteLocation = useAdminDeleteStockLocation(
stockLocationId
)
// ...
const handleDelete = () => {
deleteLocation.mutate()
}
}
const handleDelete = () => {
deleteLocation.mutate()
}
}
export default StockLocation
```
export default StockLocation
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
</TabItem>
<TabItem value="fetch" label="Fetch API">
```ts
fetch(`<BACKEND_URL>/admin/stock-locations/${stockLocationId}`,
{
credentials: "include",
method: "DELETE",
}
)
.then((response) => response.json())
.then(({ id, object, deleted }) => {
console.log(id)
})
```
```ts
fetch(`<BACKEND_URL>/admin/stock-locations/${stockLocationId}`,
{
credentials: "include",
method: "DELETE",
}
)
.then((response) => response.json())
.then(({ id, object, deleted }) => {
console.log(id)
})
```
</TabItem>
<TabItem value="curl" label="cURL">
</TabItem>
<TabItem value="curl" label="cURL">
```bash
curl -L -X DELETE '<BACKEND_URL>/admin/stock-locations/<LOC_ID>' \
-H 'Authorization: Bearer <API_TOKEN>'
```
```bash
curl -L -X DELETE '<BACKEND_URL>/admin/stock-locations/<LOC_ID>' \
-H 'Authorization: Bearer <API_TOKEN>'
```
</TabItem>
</TabItem>
</Tabs>
This API Route requires the ID of the stock location as a path parameter.