---
title: "Create state machine"
method: POST
path: "/api/v1/state-machines"
tags: ["state-machines"]
---

# Create state machine

`POST /api/v1/state-machines`

Creates a new state machine within the caller account. The transition graph is validated against the Kruzer mandatory skeleton (mandatory statuses present, cancellation route, no post-invoice cancellation, arrow integrity, custom status placement, nature composition).

## Request body

- StateMachineCreate
  - `entityType` 'ORDER' | 'FULFILLMENT_ORDER', required
  - `code` string, required
  - `name` string, required
  - `transitions` StateMachineTransitionCreate[], required
    - `from` string, required
    - `to` string, required
  - `states` StateMachineStateConfigCreate[]
    - `status` string, required

## Response `201`

State machine created.

- StateMachineCreateResponse
  - `states` object[], required
    - `status` string
    - `actions` string[]
  - `id` string, required
  - `entity_type` 'ORDER' | 'FULFILLMENT_ORDER', required
  - `code` string, required
  - `name` string, required
  - `transitions` object[], required
    - `from` string, required
    - `to` string, required
  - `active` boolean, required
  - `is_default` boolean, required
  - `version` number, required
  - `created_at` string, required
  - `updated_at` string, required

## Other responses

- `400` — Request payload, query string, or path parameter failed validation.
- `401` — Authentication is missing, malformed, expired, or refers to a session that is no longer active.
- `403` — The caller is authenticated but lacks the required permission for this action.
- `404` — Status not found in the caller account.
- `409` — A state machine with the same code already exists for the entity type within the account.
- `422` — The payload passed schema validation but breaks a business rule: ORDER machines are not creatable via the API (provisioned by the account seed), or the FULFILLMENT_ORDER graph breaks a structural save validation.
- `500` — Unexpected server error. The response body never leaks internal details.

---

[API](https://skmtc.net/kruzer-corp/apis/oms-api.md) · [All operations](https://skmtc.net/kruzer-corp/apis/oms-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/kruzer-corp/oms-api/revisions/38ef6e16a7a8/schema)
