# Flows

> Create, read, update and delete your flows from code, and rotate their keys.

Source: https://voxio.in/docs/flows · voxioagent 2.0.0 · Index: https://voxio.in/docs/llms.txt

Flows you create here are the same as flows made in the dashboard: they appear there, and the dashboard creates its flows the same way.

## Before you begin

You need:

- A server client made with your account key. See [Server SDK](https://voxio.in/docs/server.md).

## Create a flow

Create a flow with a name and a workflow:

```js
const { flowKey } = await voxio.flows.create({
  name: "Support",
  workflow: { start_node: "greet", nodes: { greet: { /* … */ } } },
  webhookUrl: "https://example.com/voxio",
  stt: { service: "deepgram", model: "nova-3" },
  tts: { service: "elevenlabs", voice: "VOICE_ID" },
  runtime: { "warmup-agent": true },
});

console.log(flowKey);   // → vk_…
```

Replace `VOICE_ID` with the voice to use, from your text-to-speech provider.

The new flow's key comes back as `flowKey`.

> **Tip: Start from the dashboard**
>
> The easiest way to get a workflow is to build it in the dashboard's **Workflow** editor and read it back with `flows.get`.

## Flow settings

- `name` (string, required): The name shown in the dashboard. Required when you create a flow.
- `workflow` ({ start_node, nodes }): The conversation graph. `start_node` must be one of the `nodes`.
- `webhookUrl` (URL): Where session events are posted. See [Webhooks](https://voxio.in/docs/webhooks.md). When you create a flow, it needs a `workflow` too.
- `stt` ({ service, … }): The speech-to-text provider and its settings.
- `tts` ({ service, … }): The text-to-speech provider and its settings.
- `faces` (array): The avatar's expressions. See [Talking avatar](https://voxio.in/docs/avatar.md).
- `transitions` (array): The transitions between expressions.
- `processType` (string): How the flow processes speech.
- `vision` (object): Camera understanding, for flows that can see.
- `runningVision` (object): Continuous camera understanding during a call.
- `runtime` (object): Any other flow setting, stored as given.

## Read a flow

Read the whole flow, or only the fields you need:

```js
const flow = await voxio.flows.get(flowKey);
const some = await voxio.flows.get(flowKey, { keys: ["flow_name", "agent_id"] });
```

## Update a flow

Pass only the fields to change:

```js
await voxio.flows.update(flowKey, {
  name: "Support (EN)",
  tts: { service: "deepgram", voice: "aura-2" },
});
```

Other fields keep their values. If you update `faces` without `transitions`, or the other way round, the one you leave out is kept. The next session uses the new settings; sessions already running aren't affected.

## Rotate the key

Replace the flow's key:

```js
const { flowKey: newKey } = await voxio.flows.rotateKey(flowKey);
```

The old key stops working at once. Phone numbers and sessions stay with the flow.

## Delete a flow

Delete the flow and see what went with it:

```js
const { sessionsDeleted, numbersDetached } = await voxio.flows.delete(flowKey);
```

> **Warning: Deleting is permanent**
>
> The flow's sessions go with it, and so do its agent, speech and voice settings unless another flow shares them. Phone numbers stay on your account, detached from any flow. `delete` always needs the key passed explicitly and is never retried.

## Next steps

- [Webhooks](https://voxio.in/docs/webhooks.md): receive each conversation on your server.
- [Sessions and usage](https://voxio.in/docs/sessions-usage.md): read transcripts and usage for a flow.
