Draft orders & invoices
A draft order is an order you build on the customer's behalf — a phone order, a wholesale quote, a custom price. You send them an invoice link; they pay when they're ready. The link works for up to 30 days. When they pay, it becomes a normal order: stock, emails and fulfillment all run as usual.
When to use draft orders
- Wholesale and B2B — a buyer wants 50 units at a negotiated price. Set
unit_priceper line; the customer pays the agreed total at checkout, not the catalog price. - Phone and chat orders — the customer gives their order over the phone. Build it in the API, send the invoice, and they pay from their inbox.
- Custom quotes — a bespoke or made-to-order item. The catalog price is optional on every line; leave it out and name your own.
For standard self-serve checkout, use checkouts.create() instead. Draft orders are for cases where you build the order, not the customer.
Create a draft
const { data: draft } = await commerce.draftOrders.create({
customer_email: "buyer@example.com",
customer_name: "Alex Chen",
note: "Wholesale Q4 — net 30 as discussed.",
items: [
{ variant_id: "var_tshirt_m", quantity: 50, unit_price: 1200 }, // $12.00 (catalog: $18.00)
{ variant_id: "var_tshirt_l", quantity: 25 }, // catalog price
],
shipping: { name: "Ground freight", amount: 0 }, // absorb shipping
expires_in_days: 30, // default; the invoice link works this long
});
console.log(draft.invoice_url); // share this, or call sendInvoice to email itunit_price overrides the catalog price for that line only. Omit it and the catalog price applies. All amounts are in the smallest currency unit (cents for USD). The draft gets a sequential number (D1001, D1002, …) alongside its id.
No stock is held and no Stripe session is created at this point. Both happen only when the customer clicks Pay.
Send the invoice
// Email the invoice to the draft's customer_email:
await commerce.draftOrders.sendInvoice(draft.id);
// Or send to a different address, with a note:
await commerce.draftOrders.sendInvoice(draft.id, {
to: "ap@example.com",
message: "Payment due net 30. Contact us with questions.",
});The email comes from your store's name, shows the line items and total, and includes a Pay button. You can call sendInvoice more than once — the customer gets a reminder email each time.
You can also skip the email and share draft.invoice_url yourself — paste it into a Slack message, a CRM note or a contract PDF.
Why the invoice link lasts 30 days
A Stripe checkout session expires in 24 hours. The invoice link lasts up to 30 days because it does not create a Stripe session when the draft is created. Instead, the invoice page creates a fresh checkout the moment the customer clicks Pay — using the draft's current items and prices — then immediately redirects them to Stripe. The link keeps working no matter how many times they come back.
The URL is /invoice/<id>?t=<token>. The token is a 22-character HMAC over the draft ID, signed with your store's encryption key. It cannot be guessed; sharing the URL is sharing the invoice.
Edit or cancel before payment
// Renegotiate a price, add an item, extend the link:
await commerce.draftOrders.update(draft.id, {
items: [
{ variant_id: "var_tshirt_m", quantity: 60, unit_price: 1150 }, // renegotiated
{ variant_id: "var_tshirt_l", quantity: 25 },
],
expires_in_days: 15, // reset the clock from now
});
// No longer needed:
await commerce.draftOrders.cancel(draft.id);Editing a draft does not invalidate the invoice URL. The customer sees the updated items the next time they open the link. If the draft has already expired, update it with a new expires_in_days to reopen it.
Retrieve and list
// Get one draft (by id or number):
const { data } = await commerce.draftOrders.get(draft.id);
const { data: byNum } = await commerce.draftOrders.get(1001); // D1001
// List open drafts:
const { data: list } = await commerce.draftOrders.list({ status: "open", limit: 20 });
// Statuses: "open" | "invoice_sent" | "completed" | "cancelled" | "expired"Webhook events
Five events cover the lifecycle:
draft_order.created— the draft was builtdraft_order.updated— items, prices or the note changeddraft_order.invoice_sent—sendInvoicewas called; payload includesemailandtestdraft_order.completed— the customer paid;order_idlinks to the resulting orderdraft_order.cancelled— the draft was cancelled
On completion, a normal order.paid event also fires. Fulfillment, emails and stock deduction all run as usual from that event.
// Listen for payment confirmation:
// draft_order.completed: { ...draft, order_id: "ord_..." }
// order.paid fires immediately after — fulfillment starts from hereFrom an AI agent or MCP server
The CommerceForAI MCP server exposes draft orders as tools. An agent can build a wholesale order, check its status and re-send the invoice from a conversation — no custom code required. Useful when a support agent or a CRM assistant needs to issue a quote mid-thread.
See also
- Discounts, buy links & reports — discount codes, subscriptions, gift cards, buy links and sales reports
- Shipping & returns — fulfillment for completed orders
- API reference — full parameter list for
/draft_orders