---
title: "Create a service hierarchical state machine"
method: POST
path: "/v1/{organization}/organization/service_hierarchical_state_machine"
tags: ["Organization"]
---

# Create a service hierarchical state machine

`POST /v1/{organization}/organization/service_hierarchical_state_machine`

## Request

- Base URL: `https://api.amigo.ai`
- URL: `https://api.amigo.ai/v1/{organization}/organization/service_hierarchical_state_machine`
- Auth: HTTP bearer and API key in header `X-ORG-ID` and HTTP basic
- TypeScript: <https://skmtc.dev/amigo/apis/amigo-api/docs/v1/:organization/organization/service_hierarchical_state_machine/post.ts> (a function with typed inputs; its response is checked against the schema)

Create a new state machine for the given organization. No default version for the state machine will be created, so one must later create a version for this state machine so it can be used
in a service.

#### Permissions
This endpoint requires the following permissions:
* `Organization:CreateServiceHierarchicalStateMachine` for the new service hierarchical state machine.

## Path parameters

- `organization` string, required

## Headers

- `x-mongo-cluster-name` string, nullable: The Mongo cluster name to perform this request in. This is usually not needed unless the organization does not exist yet in the Amigo organization infra config database.
- `Sec-WebSocket-Protocol` string[]

## Request body

- SrcAppEndpointsOrganizationCreateServiceHierarchicalStateMachineRequest
  - `state_machine_name` string, required

## Response `201`

Succeeded.

- SrcAppEndpointsOrganizationCreateServiceHierarchicalStateMachineResponse
  - `id` string, required: The ID of the newly created state machine.

## Other responses

- `401`: Invalid authorization credentials.
- `403`: Missing required permissions.
- `404`: The specified organization does not exist.
- `409`: A state machine with the same name already exists.
- `422`: Invalid request path parameter or request body failed validation.
- `429`: The user has exceeded the rate limit of 10 requests per minute for this endpoint.
- `503`: The service is going through temporary maintenance.

---

[API](https://skmtc.dev/amigo/apis/amigo-api.md) - [All operations](https://skmtc.dev/amigo/apis/amigo-api/llms.txt) - [OpenAPI document](https://skmtc.dev/amigo/apis/amigo-api/revisions/fd3c06d4bc2c?raw)
