Create a Sales Order
This guide covers creating a wholesale sales order through the GoodDay API,
including deterministic block positions, nested line items, and safe retries.
The token needs the write:sales_orders scope.
Base URL:
https://api.gooddayai.com/v1
Create endpoint
POST /sales-orders
A sales order can contain one or more blocks. Each block can carry line items
and an optional blocks[].position value.
Explicit positions
Use explicit positions when downstream fulfillment must target a particular
block. If any block supplies position, every block must supply position and
the values must form the unique contiguous set 1..N. Request-array order does
not change the declared mapping.
This request sends position 2 first, while keeping the fulfillment-bearing SKU on position 1:
{
"status": "open",
"blocks": [
{
"position": 2,
"lineItems": [{ "sku": "DISPLAY-CASE", "unitsOrdered": 1 }]
},
{
"position": 1,
"lineItems": [{ "sku": "FULFILLMENT-SKU", "unitsOrdered": 12 }]
}
]
}
The response returns blocks in persisted position order: position 1 first, followed by position 2. Each nested item stays attached to its declared block.
position accepts only a positive safe JSON integer. Numeric strings,
booleans, null, blanks, fractions, zero, negative values, and integers larger
than 9007199254740991 return 422 VALIDATION_ERROR.
Mixed positioned and unpositioned blocks, duplicate values, gaps, or a set that
starts above 1 return 400 VALIDATION_ERROR. Use the blocks.position entry in
error.details to repair the complete set before retrying.
Omit positions for backward compatibility
If position is omitted from every block, GoodDay preserves request-array order: the first block becomes position 1, the second becomes position 2, and so on. Do not mix this form with explicit positions in the same request.
Position 1 and fulfillment
For CRSTL-created orders, position 1 is the fulfillment-bearing block. Put the items that an inbound fulfillment must match on position 1. Creating an order does not release it: release remains an existing staff action, and the GoodDay API has no release endpoint.
Retry safely with Idempotency-Key
Send an Idempotency-Key header on create requests:
curl -X POST https://api.gooddayai.com/v1/sales-orders \
-H "Authorization: Bearer gd_yourTokenValueHere" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: sales-order-2026-08-28-001" \
--data @sales-order.json
For 24 hours, repeating the same Idempotency-Key with the same body returns
the original resource without creating a second order. If you change the
body—including a block position—while reusing the key during that window, the
API returns 409 CONFLICT. Repair the request and use a fresh key for a new
intent; do not retry the changed body with the old key. Do not reuse a key after
the 24-hour window expires: its cached result may no longer exist, so the request
can create a new order.
Common errors
| Status | Meaning |
|---|---|
| 400 | Invalid complete position set or another semantic request conflict |
| 401 | Bad or missing bearer token |
| 403 | Token lacks write:sales_orders |
| 409 | An idempotency key was reused for a different request |
| 422 | A field has the wrong type or range, including an invalid position |
Next steps
- List and poll sales orders
- Browse the full API reference for all supported create fields.