State Transitions

Fenicia models an order's lifecycle with two related state tables, not one: the 23-state catalog that decides which actions (accept, reject, cancel, prepare, fulfill, returns) appear in _links (HATEOAS), and a smaller transition table — 17 states, the canonical OrderStatus type — that's the one that actually validates POST /transition, POST /orders/bulk/transition, and GET /valid-transitions. This article documents both and all the endpoints that operate them.

Which endpoint should I use?

Use accept, reject, and cancel for the merchant's common actions — they're optimized for their use case and validate specific business rules (for example, the cancellation reason catalog). Use the generic transition endpoint when you need to move the order to any valid state in the machine that doesn't have a dedicated action.

The action catalog — 23 states (HATEOAS)

This table governs _links, NOT /transition validation

This 23-state table (it includes the new/pending aliases and additional states such as preparing, shipped, completed, ready_for_pickup, out_for_delivery, and problematic, which are not possible values of the persisted orderStatus field today) is the one that decides which named actions appear in _links when you retrieve an order — see "Available actions (HATEOAS)" below. It is not the table that validates POST /orders/{orderId}/transition, POST /orders/bulk/transition, or GET /orders/{orderId}/valid-transitions. Those three endpoints validate against a different, smaller table (17 states) — see "The table that actually validates a transition" below.

Each row indicates, per this table, the states an order could move to from the current state for the purposes of which action to show in _links.

Current stateValid transitions to
draftnew, cancelled
new (alias of pending)accepted, cancelled, rejected
pending (alias of new)accepted, cancelled, rejected
acceptedprocessing, preparing, cancelled
processingpackaging, cancelled, fulfilled
preparingfulfilled, cancelled
packagingpickup-pending, fulfilled, cancelled
pickup-pendingin-transit, fulfilled
ready_for_pickupfulfilled
fulfilledin-transit, delivered, partially-delivered
shippedin-transit, delivered
in-transitdelivered, exception, not-delivered, partially-delivered
out_for_deliverydelivered, exception, not-delivered
deliveredreturned
completedreturned
partially-delivereddelivered, returned
partially-fulfilledfulfilled, in-transit, delivered
exceptionin-transit, delivered, not-delivered, cancelled
not-deliveredin-transit, cancelled, returned
problematiccancelled
cancelled(terminal — no outgoing transitions)
rejected(terminal — no outgoing transitions)
returned(terminal — no outgoing transitions)

Terminal states

cancelled, rejected, and returned are terminal states: an order that reaches any of them cannot transition to any other state.

Tip

new and pending are aliases of the same state — they have exactly the same valid transitions. You can use either interchangeably.

The table that actually validates a transition — 17 states, by flowProfile

POST /orders/{orderId}/transition, POST /orders/bulk/transition, and GET /orders/{orderId}/valid-transitions don't use the 23-state table above. They validate against @fenicia/core's state machine, which only knows the 17 values of the canonical OrderStatus type (no new/pending aliases as separate states, and no preparing, shipped, completed, ready_for_pickup, out_for_delivery, or problematic) and which changes based on the flowProfile you send (basic, intermediate — default — or wms-full).

Current statebasicintermediate (default)wms-full
draftnew, cancellednew, cancellednew, cancelled
newaccepted, rejected, cancelledaccepted, rejected, cancelledaccepted, rejected, cancelled
acceptedfulfilled, cancelledprocessing, fulfilled, cancelledpicking, cancelled
cancelled(terminal)(terminal)(terminal)
rejected(terminal)(terminal)(terminal)
processing(not used in basic)picking, packaging, fulfilled, cancelledpicking, cancelled (alternative entry point)
packaging(not used in basic)pickup-pending, fulfilled, cancelledpickup-pending, cancelled
picking(not used in basic)packaging, fulfilled, cancelledpackaging, cancelled
pickup-pending(not used in basic)in-transit, fulfilledin-transit, delivered, cancelled
in-transitdelivered, exception, not-delivereddelivered, exception, not-delivereddelivered, exception, not-delivered
fulfilledin-transit, deliveredin-transit, deliveredin-transit, delivered
deliveredreturnedreturnedreturned
returned(terminal)(terminal)(terminal)
partially-fulfilledfulfilled, cancelledfulfilled, in-transit, cancelledfulfilled, in-transit, cancelled
partially-delivereddelivered, returneddelivered, returneddelivered, returned
not-deliveredin-transit, cancelledin-transit, cancelledin-transit, cancelled
exceptionin-transit, delivered, cancelledin-transit, delivered, cancelledin-transit, delivered, cancelled

preparing is not a valid state for /transition

Notice preparing doesn't appear in any column: it isn't one of the 17 values of the OrderStatus type, so sending it as toStatus to /transition (with any flowProfile) always gets rejected with orders:invalid_transition, even though it does appear in the 23-state HATEOAS table above.

Available actions (HATEOAS)

When you retrieve an order, its _links object includes only the actions valid for its current state. The possible actions are: accept, reject, cancel, prepare, fulfill, returns. If an action doesn't appear in _links, it isn't valid for the order's current state.

Accept an order

Accepts a pending order. Requires orders:update permission.

{}
200
{
  "data": {
    "_id": "65f3a1b2c4d5e6f7a8b9c0d1",
    "orderStatus": "accepted",
    "_links": { "self": "/orders/65f3a1b2c4d5e6f7a8b9c0d1" }
  }
}
curl -X POST https://api.fenicia.io/orders/65f3a1b2c4d5e6f7a8b9c0d1/accept \
  -H "Authorization: Bearer fkapi_your_api_key"

Returns the updated order, wrapped in data, with its new state (accepted) and its _links.

Required permission: orders:update

Parameters

orderIdstringrequired

Order ID.

No body required

The handler doesn't read any field from the request body — send {} or simply omit the body. If the order belongs to a channel that requires confirming the acceptance in the marketplace before accepting locally (today: Walmart), the acceptance is propagated automatically; you don't need to send anything for that.

Reject an order

Rejects a pending order. Requires orders:cancel permission.

{
  "reason": "out_of_stock"
}
200
{
  "data": {
    "_id": "65f3a1b2c4d5e6f7a8b9c0d1",
    "orderStatus": "rejected",
    "_links": {
      "self": "/orders/65f3a1b2c4d5e6f7a8b9c0d1",
      "attachments": "/orders/65f3a1b2c4d5e6f7a8b9c0d1/attachments",
      "activityLog": "/orders/65f3a1b2c4d5e6f7a8b9c0d1/activity-log",
      "validTransitions": "/orders/65f3a1b2c4d5e6f7a8b9c0d1/valid-transitions"
    }
  }
}
curl -X POST https://api.fenicia.io/orders/65f3a1b2c4d5e6f7a8b9c0d1/reject \
  -H "Authorization: Bearer fkapi_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{"reason": "out_of_stock"}'

Returns the updated order, wrapped in data, with its new state (rejected) and its _links. rejected is a terminal state in the HATEOAS table, so no action (accept/prepare/fulfill/…) appears — only the four base navigation links (self, attachments, activityLog, validTransitions), which are always present.

Required permission: orders:cancel

Parameters

orderIdstringrequired

Order ID.

reasonstringrequired

One of the 12 canonical cancellation reasons — same catalog used by cancel (see table in 'Cancel an order' below).

motivestring

Specific child motive within the chosen reason. Must belong to reason.

notestring

Additional free-text context. Required when reason is other.

requestedBystring

Who requested the rejection: buyer, seller, or platform.

Same reason catalog as cancel, strict validation

reject uses the same catalog of 12 canonical reasons as cancel (see the table in the "Cancel an order" section below) and the same rule: note is required when reason is other. Unlike cancel (which accepts extra fields without rejecting them), reject's validator is strict: sending any field other than reason, motive, note, or requestedBy is rejected.

Cancel an order

Cancels an order. Requires orders:cancel permission.

{
  "reason": "customer_request",
  "requestedBy": "buyer",
  "note": "El cliente cambió de opinión"
}
200
{
  "data": {
    "_id": "65f3a1b2c4d5e6f7a8b9c0d1",
    "orderStatus": "cancelled",
    "_links": {
      "self": "/orders/65f3a1b2c4d5e6f7a8b9c0d1",
      "attachments": "/orders/65f3a1b2c4d5e6f7a8b9c0d1/attachments",
      "activityLog": "/orders/65f3a1b2c4d5e6f7a8b9c0d1/activity-log",
      "validTransitions": "/orders/65f3a1b2c4d5e6f7a8b9c0d1/valid-transitions"
    }
  }
}
curl -X POST https://api.fenicia.io/orders/65f3a1b2c4d5e6f7a8b9c0d1/cancel \
  -H "Authorization: Bearer fkapi_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "reason": "customer_request",
    "requestedBy": "buyer",
    "note": "El cliente cambió de opinión"
  }'

Returns the updated order, wrapped in data, with its new state (cancelled) and its _links. cancelled is a terminal state in the HATEOAS table, so no action (accept/prepare/fulfill/…) appears — only the four base navigation links (self, attachments, activityLog, validTransitions), which are always present.

Required permission: orders:cancel

Parameters

orderIdstringrequired

Order ID.

reasonstringrequired

One of the 12 canonical cancellation reasons (see table below).

motivestring

Specific child motive within the chosen reason.

notestring

Additional free-text context. Required when reason is other.

requestedBystring

Who requested the cancellation: buyer, seller, or platform. Accepts exactly one of these three values.

Canonical cancellation reasons

reason
out_of_stock
fulfillment_unavailable
customer_request
shipping_issue
payment_declined
fraud_suspected
product_issue
pricing_error
duplicate_order
merchant_decision
system_error
other

note is required when reason is other

If you send reason: "other", the note field becomes required — describe the actual reason for the cancellation.

Set status directly

Sets the order's status without going through a named action. Useful when integrating a flow that already knows the exact destination state.

Directly sets an order's status. Requires orders:update permission.

{
  "status": "preparing"
}
204No body
(no content)
curl -X POST https://api.fenicia.io/orders/65f3a1b2c4d5e6f7a8b9c0d1/status \
  -H "Authorization: Bearer fkapi_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{"status": "preparing"}'

Returns 204 No Content — no body.

Required permission: orders:update

Parameters

orderIdstringrequired

Order ID.

statusstringrequired

Target status.

204 No Content — no body

Unlike accept/reject/cancel/transition, this endpoint responds with 204 No Content: it doesn't validate the transition against the state machine (don't confuse it with transition, which does validate) and it doesn't return the updated order. If you need the resulting order, do a GET /orders/{orderId} afterward.

Generic transition

Transitions an order to the given state, validating the state machine. Requires orders:update permission.

{
  "toStatus": "processing"
}
200
{
  "data": {
    "order": { "_id": "65f3a1b2c4d5e6f7a8b9c0d1", "orderStatus": "processing" },
    "previousStatus": "accepted",
    "newStatus": "processing",
    "hooks": []
  }
}
curl -X POST https://api.fenicia.io/orders/65f3a1b2c4d5e6f7a8b9c0d1/transition \
  -H "Authorization: Bearer fkapi_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{"toStatus": "processing"}'

Returns the updated order nested under data.order, along with previousStatus, newStatus, and the hooks triggered by the transition.

Required permission: orders:update

Parameters

orderIdstringrequired

Order ID.

toStatusstringrequired

Target status. Must be a valid transition from the current state per the 17-state table by `flowProfile` (see above) — not the 23-state HATEOAS table.

reasonstring

Reason for the transition, for the activity log. Only required when the specific transition demands it (e.g. some transitions to cancelled/rejected) — in that case, omitting it returns validation:invalid_input.

detailsstring

Additional free-text detail for the activity log.

flowProfilestring

Flow profile the transition is validated against: basic, intermediate (default), or wms-full.

The response does NOT carry _links, and the order is nested under order

Unlike accept/reject/cancel (which return { data: { ...order, _links } }), this endpoint returns { data: { order, previousStatus, newStatus, hooks } } — the complete order lives under the order key, without _links, alongside the previous/new status and the list of hooks that fired (e.g. inventory adjustments).

preparing is not a valid toStatus

preparing belongs only to the 23-state HATEOAS table, not to the canonical OrderStatus type this endpoint validates against — sending it as toStatus always returns orders:invalid_transition, regardless of flowProfile. Use one of the 17 states from "The table that actually validates a transition" above (e.g. processing, as in the example).

Bulk transition

Applies the same transition to several orders in a single call.

Transitions several orders at once. Requires orders:update permission.

{
  "orderIds": ["65f3a1b2c4d5e6f7a8b9c0d1", "65f3a1b2c4d5e6f7a8b9c0d2"],
  "toStatus": "accepted"
}
200
{
  "data": {
    "success": true,
    "bulkOperationId": "bulk_1721500000000_abc123",
    "summary": { "total": 2, "successful": 2, "failed": 0, "skipped": 0 },
    "results": [
      { "orderId": "65f3a1b2c4d5e6f7a8b9c0d1", "success": true, "previousStatus": "new", "newStatus": "accepted" },
      { "orderId": "65f3a1b2c4d5e6f7a8b9c0d2", "success": true, "previousStatus": "new", "newStatus": "accepted" }
    ],
    "targetStatus": "accepted",
    "performedAt": "2026-07-20T18:30:00.000Z",
    "performedBy": { "userId": "65f0a0b0c0d0e0f0a0b0c0d0" }
  }
}
curl -X POST https://api.fenicia.io/orders/bulk/transition \
  -H "Authorization: Bearer fkapi_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "orderIds": ["65f3a1b2c4d5e6f7a8b9c0d1", "65f3a1b2c4d5e6f7a8b9c0d2"],
    "toStatus": "accepted"
  }'

Returns success (true only if no order failed), a summary of the operation (summary), and the detailed per-order result (results[]), along with the bulkOperationId, the applied targetStatus, and performedAt/performedBy with the timestamp and the user who ran the operation.

Required permission: orders:update

Parameters

orderIdsstring[]required

IDs of the orders to transition. At least one element — an empty array rejects the entire call with validation:invalid_input.

toStatusstringrequired

Target status for all orders.

reasonstring

Reason applied to the batch. Not required by the schema.

detailsstring

Additional free-text detail, same as the individual transition — applied to each order's activity log entry in the batch.

flowProfilestring

Optional flow profile for the transition.

Each order is processed individually

With at least one element in orderIds, each order is processed separately: one can fail (invalid transition, not found) without aborting the rest — check results[] for the per-order detail.

Get an order's valid transitions

Returns the states an order can transition to from its current state. Requires orders:read permission.

200
{
  "data": {
    "currentStatus": "accepted",
    "validTargets": ["processing", "fulfilled", "cancelled"]
  }
}

Returns the order's current state (currentStatus) and the array of states it can transition to (validTargets), computed against the 17-state table by flowProfile from "The table that actually validates a transition" above — not the 23-state HATEOAS table.

Required permission: orders:read

Parameters

orderIdstringrequired

Order ID.

flowProfilestring

Flow profile the valid transitions are computed against: basic, intermediate (default), or wms-full.

This endpoint saves you from having to reimplement @fenicia/core's 17-state transition table in your client: it returns directly the set of valid states, per flowProfile, for the queried order. It's documented in detail in Get an order, along with the rest of the resource's HATEOAS links.

Next steps