# Create a flow

`POST https://api.morevoice.ai/v1/flows`

Creates a flow with an empty draft, a template's, or the `graph` you send. It runs on calls once published (POST /v1/flows/{id}/publish).

Authenticate with a secret API key: `Authorization: Bearer $MOREVOICE_API_KEY`.

Operation ID: `flows_create`.

## Parameters

### Headers

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `MoreVoice-Version` | `string` | no | The API version to use for this request. Defaults to the version the API key is pinned to. |
| `Idempotency-Key` | `string` | no | A unique key (for example a UUID) that makes this request safe to retry: for 24 hours, a retry with the same key and parameters returns the first response instead of acting twice. |

## Request body

Required, `application/json`.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `name` | `string` | yes | — |
| `assistant_id` | `string \| null` | no | `asst_…` ID. |
| `description` | `string` | no | — |
| `graph` | `FlowGraphParamsInput` | no | A whole graph to write. Nodes are matched to the stored draft by `key`. |
| `graph.nodes` | `FlowNodeParamsInput[]` | yes | — |
| `graph.kind` | `"voice" \| "agent_script" \| "ivr"` | no | Must be the flow's kind (default: the flow's). |
| `graph.schema_version` | `1` | no | — |
| `graph.settings` | `object` | no | Merged with the stored settings. |
| `graph.variables` | `object[]` | no | Default: the stored variables. |
| `kind` | `"voice" \| "agent_script" \| "ivr"` | no | — |
| `language` | `"he" \| "en"` | no | The template's / empty flow's language (default he). |
| `template_id` | `string` | no | Start from a template instead of an empty flow. |

Example:

```json
{
  "kind": "voice",
  "language": "en",
  "name": "Reception"
}
```

## Responses

### 201 Created

The new flow. Returns `Flow`.

| Field | Type | Description |
| --- | --- | --- |
| `id` | `string` | The flow's ID. |
| `object` | `"flow"` | — |
| `livemode` | `boolean` | `true` in live mode, `false` in test mode. |
| `name` | `string` | — |
| `description` | `string` | — |
| `kind` | `"voice" \| "agent_script" \| "ivr"` | voice: drives an AI assistant; agent_script: a human agent's branching script; ivr: a phone menu. |
| `status` | `"draft" \| "published" \| "archived"` | — |
| `published_version` | `integer \| null` | The version calls run (null: never published). |
| `latest_version` | `integer` | — |
| `draft_rev` | `integer` | The draft's revision: send it as `base_rev` when you write the draft. |
| `assistant_id` | `string \| null` | `asst_…` ID. |
| `template_id` | `string \| null` | — |
| `node_count` | `integer` | — |
| `updated` | `string` | An ISO-8601 timestamp in UTC. |

Example:

```json
{
  "assistant_id": "asst_3cYbE6uYvGkH8w4ZK1rTqd",
  "description": "Identify the caller and route them.",
  "draft_rev": 17,
  "id": "flow_7Kp1Ns4Vy6Ab9Dg2Hj5Lm8",
  "kind": "voice",
  "latest_version": 3,
  "livemode": true,
  "name": "Reception",
  "node_count": 12,
  "object": "flow",
  "published_version": 3,
  "status": "published",
  "template_id": null,
  "updated": "2026-11-03T09:14:22.000Z"
}
```

### 400 Bad Request

The request is invalid: a parameter is missing, malformed or unknown, or the version header is unknown. Returns `ErrorEnvelope`.

### 401 Unauthorized

No valid API key was sent. Returns `ErrorEnvelope`.

### 403 Forbidden

The key may not do this (a missing scope, a plan limit, or a compliance block). Returns `ErrorEnvelope`.

### 409 Conflict

The request conflicts with the object's state, or the Idempotency-Key was reused with other parameters. Returns `ErrorEnvelope`.

### 429 Too Many Requests

Too many requests, or no call capacity right now. Retry after the Retry-After delay. Returns `ErrorEnvelope`.

### 500 Internal Server Error

Something went wrong on MoreVoice's side. Retry with the same Idempotency-Key. Returns `ErrorEnvelope`.

## Code samples

**TypeScript**

```ts
import MoreVoice from "@morevoice/sdk";

const mv = new MoreVoice(); // MOREVOICE_API_KEY from the environment

const flow = await mv.flows.create({
	kind: "voice",
	language: "en",
	name: "Reception",
});
console.log(flow);
```

**Python**

```python
from morevoice import MoreVoice

client = MoreVoice()  # MOREVOICE_API_KEY from the environment

flow = client.flows.create({
    "kind": "voice",
    "language": "en",
    "name": "Reception",
})
print(flow)
```

**cURL**

```sh
curl -X POST https://api.morevoice.ai/v1/flows \
  -H "Authorization: Bearer $MOREVOICE_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
  "kind": "voice",
  "language": "en",
  "name": "Reception"
}'
```
