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

# TypeScript SDK

> Install @fact0/sdk v1.0.2 for Node.js and TypeScript agent stacks.

# TypeScript SDK

|              |                                                                 |
| ------------ | --------------------------------------------------------------- |
| **npm**      | [`@fact0/sdk`](https://www.npmjs.com/package/@fact0/sdk) v1.0.2 |
| **API**      | `https://api.fact0.io`                                          |
| **Requires** | Node.js 18+                                                     |

```bash theme={null}
npm install @fact0/sdk
```

```typescript theme={null}
import { Fact0Client } from "@fact0/sdk";

const client = new Fact0Client({
  apiKey: process.env.FACT0_API_KEY!,
});

await client.audit.log({
  actor: { id: "agent-1", type: "agent" },
  action: "document.delete",
  resource: { id: "doc_1", type: "document" },
  outcome: "success",
});

const events = await client.audit.listEvents({ pageSize: 20 });
```

<Warning>
  Never expose API keys in browser code. Use `@fact0/sdk` only in server-side contexts (Next.js route handlers, Node agents, workers).
</Warning>

## Modules

* `client.audit` - audit log read/write/verify/export
* `client.telemetry` - execution tracing

Types are generated from OpenAPI specs in `openapi/`.

## Environment variables

| Variable        | Purpose                                              |
| --------------- | ---------------------------------------------------- |
| `FACT0_API_KEY` | Bearer API key (optional if `apiKey` is set in code) |

API origin defaults to `https://api.fact0.io`. Override with `baseUrl` in the constructor for local dev (e.g. `http://localhost:8000`).
