# Server SDK

> Set up voxioagent/server to manage flows and read sessions from your own backend.

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

`voxioagent/server` manages your flows and reads their sessions and usage. It runs on Node 18 or later, or any edge runtime with `fetch`.

## Before you begin

You need:

- Your account key, from [**Developers**](https://voxio.in/dashboard/developers) in the dashboard.
- Node 18 or later.

## Install the package

npm:

```bash
npm install voxioagent
```

pnpm:

```bash
pnpm add voxioagent
```

yarn:

```bash
yarn add voxioagent
```

## Store your account key

Keep the account key out of your code. Set it as an environment variable:

macOS / Linux:

```bash
export VOXIO_SECRET_KEY="ACCOUNT_KEY"
```

Windows (PowerShell):

```powershell
$env:VOXIO_SECRET_KEY = "ACCOUNT_KEY"
```

Replace `ACCOUNT_KEY` with your account key.

## Create a client

Create the client with the key from the environment:

voxio.js:

```js
import { Voxio } from "voxioagent/server";

export const voxio = new Voxio({ secretKey: process.env.VOXIO_SECRET_KEY, environment: "gpu" });
```

To check it works, read one of your flows:

```js
const flow = await voxio.flows.get("YOUR_FLOW_KEY", { keys: ["flow_name"] });
console.log(flow.flow_name);   // → Support
```

Replace `YOUR_FLOW_KEY` with your flow key, from the flow's **Overview** in the dashboard.

If you only read one flow's sessions and usage, its flow key is enough: `new Voxio({ flowKey, environment: "gpu" })`.

> **Warning**
>
> Keep `secretKey` on your server. The client refuses to run in a browser unless you pass `dangerouslyAllowBrowser: true`, which you shouldn't.

## Options

- `secretKey` (string): Your account key. Needed to create, change, delete or rotate flows.
- `flowKey` (string): A default flow key for reading sessions and usage.
- `environment` ("standard" | "gpu"): Use `gpu`: the data service runs there.
- `endpoints` ({ data? }): Overrides the data service.
- `timeoutMs` (number): The timeout for each request. Default: 15000.
- `maxRetries` (number): Retries for reads that fail with 429 or 5xx. Default: 2. Writes are never retried.
- `fetch` (typeof fetch): Your own fetch, for tests or proxies.

## Next steps

- [Flows](https://voxio.in/docs/flows.md): create, change and delete flows.
- [Sessions and usage](https://voxio.in/docs/sessions-usage.md): read transcripts and usage.
