> ## Documentation Index
> Fetch the complete documentation index at: https://docs.concatflow.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Concatflow client

> The server-side client from @concatflow/node. Node 18 or later, no dependencies.

```bash theme={"system"}
npm install @concatflow/node
```

```ts theme={"system"}
import { Concatflow } from "@concatflow/node";

const concatflow = new Concatflow({ apiKey: process.env.CONCATFLOW_API_KEY! });
```

Create one client and reuse it. It holds no connection and no state besides its key.

## Constructor

**apiKey** `string` *required*

Your secret API key, `lyra_sk_…`. See [Where to find your identifiers](https://docs.concatflow.com/identifiers.md).

**baseUrl** `string` (default: [https://app.concatflow.com](https://app.concatflow.com))

The Concatflow API origin. A trailing `/` is removed.

The constructor throws an `Error`:

* if `apiKey` does not start with `lyra_sk_`;
* if it runs in a browser (a global `window` exists). Your key would be sent to every visitor.

## Resources

| Method | Does |
| - | - |
| [`sessions.create()`](https://docs.concatflow.com/reference/node/sessions-create) | Opens a session for one customer. |
| [`conversations.list()`](https://docs.concatflow.com/reference/node/conversations-list) | Reads a customer's conversation. |
| [`conversations.erase()`](https://docs.concatflow.com/reference/node/conversations-erase) | Erases a customer's conversation. |

Every method returns a promise. A non-2xx answer rejects with a [`ConcatflowError`](https://docs.concatflow.com/reference/node/errors).

## Runtime

* Uses the global `fetch` of Node 18 and later.
* ESM only: `import`, not `require`.
* Your key is sent as `Authorization: Bearer lyra_sk_…`. It never appears in error messages.

## Exports

```ts theme={"system"}
import {
  Concatflow,
  ConcatflowError,
  DEFAULT_BASE_URL, // "https://app.concatflow.com"
  encodePartition,
} from "@concatflow/node";

import type {
  ConcatflowConfig,
  Partitions,
  Session,
  Thread,
  ThreadMessage,
  ThreadBlock,
  ConversationParams,
} from "@concatflow/node";
```

`encodePartition({ customer_id: "4712", region: "eu" })` returns `"customer_id=4712,region=eu"`, the form the [HTTP API](https://docs.concatflow.com/reference/api/overview.md) expects.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.