Skip to main content
Skip to main content

AdminReturnReasonsResource

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

All methods in this class require authentication.

Return reasons are key-value pairs that are used to specify why an order return is being created. Admins can manage available return reasons, and they can be used by both admins and customers when creating a return.

Related Guide: How to manage return reasons.

Methods

create

Create a return reason.

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.returnReasons.create({
label: "Damaged",
value: "damaged"
})
.then(({ return_reason }) => {
console.log(return_reason.id);
});

Parameters

The return reason to create.
customHeadersRecord<string, any>Required
Custom headers to attach to the request.

Default: {}

Returns

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

update

Update a return reason's details.

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.returnReasons.update(returnReasonId, {
label: "Damaged"
})
.then(({ return_reason }) => {
console.log(return_reason.id);
});

Parameters

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

Default: {}

Returns

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

delete

Delete a return reason.

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.returnReasons.delete(returnReasonId)
.then(({ id, object, deleted }) => {
console.log(id);
});

Parameters

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

Default: {}

Returns

ResponsePromiseResponsePromise<DeleteResponse>Required
Resolves to the deletion operation's details.

retrieve

Retrieve a return reason's details.

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.returnReasons.retrieve(returnReasonId)
.then(({ return_reason }) => {
console.log(return_reason.id);
});

Parameters

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

Default: {}

Returns

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

list

Retrieve a list of return reasons.

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.returnReasons.list()
.then(({ return_reasons }) => {
console.log(return_reasons.length);
});

Parameters

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

Default: {}

Returns

ResponsePromiseResponsePromise<AdminReturnReasonsListRes>Required
Resolves to the list of return reasons.
Was this section helpful?