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.
customHeaders
Record<string, any>RequiredCustom headers to attach to the request.
Default: {}
Returns
ResponsePromise
ResponsePromise<AdminDraftOrdersRes>RequiredResolves to the draft order's details
ResponsePromise
ResponsePromise<AdminDraftOrdersRes>RequiredaddLineItem
Create a Line Item in the Draft Order.
Example
Parameters
id
stringRequiredThe ID of the draft order.
The line item to create.
customHeaders
Record<string, any>RequiredCustom headers to attach to the request.
Default: {}
Returns
ResponsePromise
ResponsePromise<AdminDraftOrdersRes>RequiredResolves to the draft order's details
ResponsePromise
ResponsePromise<AdminDraftOrdersRes>Requireddelete
Delete a Draft Order.
Example
Parameters
id
stringRequiredThe ID of the draft order.
customHeaders
Record<string, any>RequiredCustom headers to attach to the request.
Default: {}
Returns
ResponsePromise
ResponsePromise<DeleteResponse>RequiredResolves to the deletion operation details.
ResponsePromise
ResponsePromise<DeleteResponse>RequiredremoveLineItem
Delete a Line Item from a Draft Order.
Example
Parameters
id
stringRequiredThe ID of the draft order that the line item belongs to.
itemId
stringRequiredThe ID of the line item to delete from the draft order.
customHeaders
Record<string, any>RequiredCustom headers to attach to the request.
Default: {}
Returns
ResponsePromise
ResponsePromise<AdminDraftOrdersRes>RequiredResolves to the draft order's details
ResponsePromise
ResponsePromise<AdminDraftOrdersRes>Requiredretrieve
Retrieve a Draft Order's details.