Hanzo
PlatformCommerce

Orders

Manage the full order lifecycle — orders, draft orders, fulfillments, returns, exchanges, and edits.

Orders

The Orders API manages the complete lifecycle of a purchase: from cart capture through fulfillment, and every post-purchase change — returns, exchanges, claims, and edits — with a versioned timeline so every mutation is auditable.

Base URL: https://api.hanzo.ai/v1/commerce/orders

Order lifecycle

draft ──▶ pending ──▶ completed

              ├──▶ canceled

              ├──▶ return ──▶ refunded
              ├──▶ exchange ──▶ new fulfillment
              └──▶ edit ──▶ new version

An order moves through pending once payment is authorized, and completed once every fulfillment is delivered. Post-purchase operations (returns, exchanges, edits) create order changes that append a new version to the order's timeline rather than mutating history.

Order object

FieldTypeDescription
idstringUnique order identifier (order_...)
statusenumdraft, pending, completed, canceled
customer_idstringCustomer who placed the order
emailstringContact email (guest or registered)
currencystringISO 4217 currency code
itemsarrayLine items with quantity, unit price, and adjustments
shipping_methodsarraySelected shipping options with tax and promotion adjustments
payment_statusenumnot_paid, authorized, captured, partially_refunded, refunded
fulfillment_statusenumnot_fulfilled, partially_fulfilled, fulfilled, delivered
totalnumberOrder grand total after tax and discounts
versionintegerCurrent timeline version

List and retrieve orders

# List orders (paginated, filterable by status/customer/date)
curl "https://api.hanzo.ai/v1/commerce/orders?status=pending&limit=20" \
  -H "Authorization: Bearer $HANZO_API_KEY"

# Retrieve a single order
curl https://api.hanzo.ai/v1/commerce/orders/order_123 \
  -H "Authorization: Bearer $HANZO_API_KEY"
import { HanzoCommerce } from '@hanzo/commerce'

const commerce = new HanzoCommerce({ apiKey: process.env.HANZO_API_KEY })

const orders = await commerce.orders.list({ status: 'pending', limit: 20 })
const order = await commerce.orders.retrieve('order_123')

Draft orders

Draft orders let a merchant build an order on behalf of a customer — quotes, phone sales, or B2B — then convert it to a live order when the customer confirms.

const draft = await commerce.orders.createDraft({
  email: 'buyer@example.com',
  currency: 'USD',
  items: [{ variant_id: 'variant_1', quantity: 2, unit_price: 2500 }],
  shipping_methods: [{ option_id: 'so_standard' }]
})

// Convert the draft to a pending order once the customer confirms
const order = await commerce.orders.completeDraft(draft.id)

Fulfillments

Create a fulfillment to ship all or part of an order. Each fulfillment tracks the items, shipping location, and delivery state.

curl -X POST https://api.hanzo.ai/v1/commerce/orders/order_123/fulfillments \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "location_id": "sloc_warehouse_sf",
    "items": [{ "item_id": "item_1", "quantity": 1 }]
  }'

Mark a fulfillment as shipped or delivered to advance the order's fulfillment_status:

curl -X POST https://api.hanzo.ai/v1/commerce/orders/order_123/fulfillments/ful_1/ship \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "tracking_numbers": ["1Z999AA10123456784"] }'

Returns, exchanges, and claims

Post-purchase changes are modeled as order changes. Each creates a new order version so the timeline is fully auditable.

OperationEndpointEffect
ReturnPOST /orders/:id/returnsCustomer sends items back; issues a refund on receipt
ExchangePOST /orders/:id/exchangesReturn items and ship replacements in one flow
ClaimPOST /orders/:id/claimsResolve damaged/incorrect items (refund or replace)
EditPOST /orders/:id/editsAdd, remove, or re-price items after purchase
// Request a return with a refund on receipt
const ret = await commerce.orders.createReturn('order_123', {
  items: [{ item_id: 'item_1', quantity: 1, reason: 'wrong_size' }],
  refund_on_receive: true
})

Every return, exchange, edit, and claim appends a new version to the order. Fetch GET /orders/:id/changes to render the full timeline of who changed what and when.

Refunds

curl -X POST https://api.hanzo.ai/v1/commerce/orders/order_123/refund \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "amount": 2500, "reason": "return_accepted" }'

Endpoints

MethodEndpointDescription
GET/ordersList orders
GET/orders/:idRetrieve an order
POST/orders/draftCreate a draft order
POST/orders/:id/completeComplete a draft into a pending order
POST/orders/:id/fulfillmentsCreate a fulfillment
POST/orders/:id/fulfillments/:fid/shipMark shipped
POST/orders/:id/returnsRequest a return
POST/orders/:id/exchangesCreate an exchange
POST/orders/:id/claimsFile a claim
POST/orders/:id/editsEdit order items
POST/orders/:id/refundRefund all or part of an order
POST/orders/:id/cancelCancel an order
GET/orders/:id/changesRetrieve the versioned change timeline

Next steps

Attach orders to customers and customer groups

Reserve and deduct stock as orders are placed and fulfilled

Authorize, capture, and refund order payments

How is this guide?

Last updated on

On this page