For the complete documentation index, see llms.txt. This page is also available as Markdown.

Orders

The Orders API exposes the platform's local order ledger — the row that records "this customer agreed to buy these items at this total, on this date." Orders sit upstream of subscriptions and invoices: a checkout flow typically writes an order first, then provisions the resulting subscription and emits the first invoice through the active billing adapter.

Orders are first-class platform records, not adapter pass-throughs. They are filed against either a contactId (individual buyer) or an organizationId (B2B account). The items array carries one entry per line item with productId, quantity, and priceCents. status is a free-form string driven by the order workflow (draft, pending, confirmed, fulfilled, cancelled, …); the API does not enforce a state machine, so callers and downstream consumers must agree on the vocabulary.

Writes require the commerce scope; reads require read. Every mutation (order.create, order.update) is recorded in the audit log and emits an event for subscribed webhooks.

Endpoints

GET /api/v1/orders

List all orders for the tenant

get
/orders
Authorizations
X-API-KeystringRequired

Scoped secret API key — send an sk_live_… value (keys issued before the typed format carry a bare pk_<hex> prefix and are also secret; they still work). A publishable pk_live_…/pk_test_… key is browser-safe, carries no scopes, and is refused by every endpoint in this spec with publishable_key_not_allowed. Coarse scopes: read, commerce, admin (admin covers everything below). Narrow per-resource scopes: journeys|pages :read|write|publish|delete, productsets :read|write|publish|delete, components|rules :read|write|delete, context :read (read-only context tier), catalog :read|write-native. publish is never implied by write.

Query parameters
limitinteger · min: 1 · max: 100Optional

Max items to return (1–100, default 20)

Default: 20
offsetintegerOptional

Number of items to skip (default 0)

Default: 0
sortstringOptional

Field to sort by

sortDirstring · enumOptional

Sort direction

Default: ascPossible values:
statusstringOptional

Filter by status

Responses
200

Paginated list of orders

get/orders
GET /api/v1/orders HTTP/1.1
Host: api.peakcommerce.app
X-API-Key: YOUR_API_KEY
Accept: */*

No content

Returns every order for the calling tenant in a single response (no cursor pagination yet). Suitable for back-office reconciliation and exports; for customer-facing lists, filter by contactId / organizationId client-side.

Requires the read scope.

POST /api/v1/orders

Create a new order

post
/orders
Authorizations
X-API-KeystringRequired

Scoped secret API key — send an sk_live_… value (keys issued before the typed format carry a bare pk_<hex> prefix and are also secret; they still work). A publishable pk_live_…/pk_test_… key is browser-safe, carries no scopes, and is refused by every endpoint in this spec with publishable_key_not_allowed. Coarse scopes: read, commerce, admin (admin covers everything below). Narrow per-resource scopes: journeys|pages :read|write|publish|delete, productsets :read|write|publish|delete, components|rules :read|write|delete, context :read (read-only context tier), catalog :read|write-native. publish is never implied by write.

Header parameters
Idempotency-KeystringOptional

Idempotency key to safely retry without creating duplicates

Body
cartIdstringOptional

When set, the order is built from this cart and its offer discount is enforced against the tenant's discount_cap policy

contactIdstringOptional
organizationIdstringOptional
itemsarrayOptional
totalCentsintegerOptional
currencystringOptional
Responses
201

Order created

No content

post/orders
POST /api/v1/orders HTTP/1.1
Host: api.peakcommerce.app
X-API-Key: YOUR_API_KEY
Content-Type: application/json
Accept: */*
Content-Length: 104

{
  "cartId": "text",
  "contactId": "text",
  "organizationId": "text",
  "items": [],
  "totalCents": 1,
  "currency": "text"
}

No content

Creates a local order row. Either contactId or organizationId should be set so the order is owned by an account; both are technically optional to support draft orders, but downstream consumers (commissions, reporting) assume one is present.

items is an array of { productId, quantity, priceCents }. totalCents is not computed for you — it is whatever the caller submits. This is intentional: callers run their own pricing pipeline (often via GET /pricing/resolve) and the API records the negotiated total verbatim.

When the body carries a cartId, the referenced cart is converted: the cart is marked checked_out and the resulting order completes immediately. A completed order also feeds platform usage metering (executed commerce value) asynchronously after the response is written; metering is opt-in per tenant and never affects the API result.

Requires the commerce scope. Returns 201 plus a nextActions hint pointing at POST /subscriptions (when the items include a subscription product) or POST /payments (for one-shot purchases).

GET /api/v1/orders/{id}

Get order details

get
/orders/{id}
Authorizations
X-API-KeystringRequired

Scoped secret API key — send an sk_live_… value (keys issued before the typed format carry a bare pk_<hex> prefix and are also secret; they still work). A publishable pk_live_…/pk_test_… key is browser-safe, carries no scopes, and is refused by every endpoint in this spec with publishable_key_not_allowed. Coarse scopes: read, commerce, admin (admin covers everything below). Narrow per-resource scopes: journeys|pages :read|write|publish|delete, productsets :read|write|publish|delete, components|rules :read|write|delete, context :read (read-only context tier), catalog :read|write-native. publish is never implied by write.

Path parameters
idstringRequired
Responses
200

Order details

No content

get/orders/{id}
GET /api/v1/orders/{id} HTTP/1.1
Host: api.peakcommerce.app
X-API-Key: YOUR_API_KEY
Accept: */*
200

Order details

No content

Returns the full order row including items, totals, status, owner ids, and audit timestamps. Requires the read scope. Returns 404 when the id is not owned by the calling tenant.

PATCH /api/v1/orders/{id}

Update order status or details

patch
/orders/{id}
Authorizations
X-API-KeystringRequired

Scoped secret API key — send an sk_live_… value (keys issued before the typed format carry a bare pk_<hex> prefix and are also secret; they still work). A publishable pk_live_…/pk_test_… key is browser-safe, carries no scopes, and is refused by every endpoint in this spec with publishable_key_not_allowed. Coarse scopes: read, commerce, admin (admin covers everything below). Narrow per-resource scopes: journeys|pages :read|write|publish|delete, productsets :read|write|publish|delete, components|rules :read|write|delete, context :read (read-only context tier), catalog :read|write-native. publish is never implied by write.

Path parameters
idstringRequired
Body
statusstringOptional
itemsarrayOptional
totalCentsintegerOptional
Responses
200

Order updated

No content

patch/orders/{id}
PATCH /api/v1/orders/{id} HTTP/1.1
Host: api.peakcommerce.app
X-API-Key: YOUR_API_KEY
Content-Type: application/json
Accept: */*
Content-Length: 43

{
  "status": "text",
  "items": [],
  "totalCents": 1
}
200

Order updated

No content

Partial-update; only fields supplied in the body are written. The most common use is advancing status (pending → confirmed → fulfilled). Updating items or totalCents after the order has been used to provision a subscription or invoice will not propagate the change to those downstream records — issue a credit note or compensating order instead.

Requires the commerce scope. Writes order.update to the audit log with a before/after diff in details.

Last updated

Was this helpful?