> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.livingbrain.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.livingbrain.com/_mcp/server.

# TypeScript SDK

Generated by Fern

## Install

**`npm`**

```bash npm
npm install @livingbrain/sdk
```

**`pnpm`**

```bash pnpm
pnpm add @livingbrain/sdk
```

**`yarn`**

```bash yarn
yarn add @livingbrain/sdk
```

Requires Node 18+ (or any runtime with a global `fetch`).

## Usage

```typescript
import { LivingBrainClient } from "@livingbrain/sdk";

const client = new LivingBrainClient({
  apiKey: process.env.LIVING_BRAIN_API_KEY!,
  subjectId: "3f2b8c1e-7a4d-4e9b-9c2a-5d6e7f8a9b0c",
});

const brain = await client.brains.create({ name: "Research" });

await client.captures.capture({
  brainId: brain.id,
  body: { kind: "note", content: "Worth remembering." },
});

for await (const page of await client.workspace.listPages({ brainId: brain.id })) {
  console.log(page.title);
}
```

## Namespaces

| Namespace          | Covers                                                       |
| ------------------ | ------------------------------------------------------------ |
| `client.brains`    | Create, list, update, delete brains; stats; daily briefs     |
| `client.captures`  | Push captures; manage ingest sources                         |
| `client.workspace` | Pages, buckets, connections, changes, search, score, profile |
| `client.webhooks`  | Webhook subscriptions                                        |
| `client.slack`     | Slack installation, OAuth, and channel bindings              |
| `client.telegram`  | Telegram bot connection                                      |

## Types

Every request and response is typed, and types are exported for your own signatures:

```typescript
import type { Page, Brain, ChangeEvent, Connection } from "@livingbrain/sdk";

function summarize(page: Page): string {
  return `${page.title} (${page.status})`;
}
```

## Errors

```typescript
import { LivingBrain } from "@livingbrain/sdk";

try {
  await client.workspace.getPage({ brainId, slug });
} catch (err) {
  if (err instanceof LivingBrain.NotFoundError) return null;
  throw err;
}
```

See [Errors](/docs/errors) for the full table.

## Request options

```typescript
await client.brains.list({
  maxRetries: 5,
  timeoutInSeconds: 30,
  abortSignal: controller.signal,
});
```

## Raw responses

When you need headers or the status code, every method has a `.withRawResponse()` variant:

```typescript
const { data, rawResponse } = await client.brains.list().withRawResponse();
console.log(rawResponse.headers.get("x-request-id"));
```

## Custom fetch

Useful for proxies, instrumentation, or non-standard runtimes:

```typescript
const client = new LivingBrainClient({
  apiKey,
  subjectId,
  fetcher: async (args) => myInstrumentedFetch(args),
});
```