AdminDraftOrdersResource
This class is used to send requests to Admin Draft Order API Routes. All its method
are available in the JS Client under the medusa.admin.draftOrders property.
All methods in this class require user authentication.
A draft order is an order created manually by the admin. It allows admins to create orders without direct involvement from the customer.
Related Guide: How to manage draft orders.
Methods
create
Create a Draft Order. A draft order is not transformed into an order until payment is captured.
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.draftOrders.create({
email: "user@example.com",
region_id,
items: [
{
quantity: 1
}
],
shipping_methods: [
{
option_id
}
],
})
.then(({ draft_order }) => {
console.log(draft_order.id);
})
Parameters
The draft order to create.
customHeadersRecord<string, any>RequiredCustom headers to attach to the request.
Default: {}
Returns
ResponsePromiseResponsePromise<AdminDraftOrdersRes>RequiredResolves to the draft order's details
ResponsePromiseResponsePromise<AdminDraftOrdersRes>RequiredaddLineItem
Create a Line Item in the Draft Order.
Example
Parameters
idstringRequiredThe ID of the draft order.
The line item to create.
customHeadersRecord<string, any>RequiredCustom headers to attach to the request.
Default: {}
Returns
ResponsePromiseResponsePromise<AdminDraftOrdersRes>RequiredResolves to the draft order's details
ResponsePromiseResponsePromise<AdminDraftOrdersRes>Requireddelete
Delete a Draft Order.
Example
Parameters
idstringRequiredThe ID of the draft order.
customHeadersRecord<string, any>RequiredCustom headers to attach to the request.
Default: {}
Returns
ResponsePromiseResponsePromise<DeleteResponse>RequiredResolves to the deletion operation details.
ResponsePromiseResponsePromise<DeleteResponse>RequiredremoveLineItem
Delete a Line Item from a Draft Order.
Example
Parameters
idstringRequiredThe ID of the draft order that the line item belongs to.
itemIdstringRequiredThe ID of the line item to delete from the draft order.
customHeadersRecord<string, any>RequiredCustom headers to attach to the request.
Default: {}
Returns
ResponsePromiseResponsePromise<AdminDraftOrdersRes>RequiredResolves to the draft order's details
ResponsePromiseResponsePromise<AdminDraftOrdersRes>Requiredretrieve
Retrieve a Draft Order's details.