Skip to main content
Skip to main content

AdminReturnsResource

This class is used to send requests to Admin Return API Routes. All its method are available in the JS Client under the medusa.admin.returns property.

All methods in this class require user authentication.

A return can be created by a customer or an admin to return items in an order. Admins can manage these returns and change their state.

Related Guide: How to manage returns.

Methods

cancel

Register a return as canceled. The return can be associated with an order, claim, or swap.

Example

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.returns.cancel(returnId)
.then(({ order }) => {
console.log(order.id);
});

Parameters

idstringRequired
The return's ID.
customHeadersRecord<string, any>Required
Custom headers to attach to the request.

Default: {}

Returns

ResponsePromiseResponsePromise<AdminReturnsCancelRes>Required
Resolves to the details of the order associated with the return. If the return is associated with a claim or a swap, then it'll be the order that the claim or swap belongs to.

receive

Mark a return as received. This also updates the status of associated order, claim, or swap accordingly.

Example

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.returns.receive(returnId, {
items: [
{
item_id,
quantity: 1
}
]
})
.then((data) => {
console.log(data.return.id);
});

Parameters

idstringRequired
The return's ID.
The received return.
customHeadersRecord<string, any>Required
Custom headers to attach to the request.

Default: {}

Returns

ResponsePromiseResponsePromise<AdminReturnsRes>Required
Resolves to the return's details.

list

Retrieve a list of Returns. The returns can be paginated.

Example

To list returns:

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.returns.list()
.then(({ returns, limit, offset, count }) => {
console.log(returns.length)
})

By default, only the first 50 records are retrieved. You can control pagination by specifying the limit and offset properties:

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.returns.list({
limit,
offset
})
.then(({ returns, limit, offset, count }) => {
console.log(returns.length)
})

Parameters

customHeadersRecord<string, any>Required
Custom headers to attach to the request.

Default: {}

Paignation configurations to be applied on the retrieved returns.

Returns

ResponsePromiseResponsePromise<AdminReturnsListRes>Required
Resolves to the list of returns with pagination fields.
Was this section helpful?