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

# TypeScript SDK

> Use the official Maesn TypeScript SDK to interact with the unified API.

<Warning>
  The Maesn TypeScript SDK is currently in **beta**. The API surface may change between releases. We recommend pinning to a specific version in production.
</Warning>

The Maesn TypeScript SDK lets you interact with the unified API from your TypeScript or JavaScript application. It provides full type safety, built-in error handling, and supports all endpoints available in the API reference.

The SDK is available on [npm](https://www.npmjs.com/package/@maesn/typescript-sdk) and is actively developed.

## Installation

Install the SDK using your preferred package manager:

<CodeGroup>
  ```bash npm theme={null}
  npm add @maesn/typescript-sdk
  ```

  ```bash pnpm theme={null}
  pnpm add @maesn/typescript-sdk
  ```

  ```bash yarn theme={null}
  yarn add @maesn/typescript-sdk
  ```

  ```bash bun theme={null}
  bun add @maesn/typescript-sdk
  ```
</CodeGroup>

<Note>
  The SDK is published as an ES Module (ESM) only. If your project uses CommonJS, import it with `await import("@maesn/typescript-sdk")`.
</Note>

## Authentication

The SDK requires two API keys, which you can pass directly or load from environment variables:

| Key          | Environment variable | Description                                       |
| ------------ | -------------------- | ------------------------------------------------- |
| `apiKey`     | `MAESN_API_KEY`      | Authenticates your application with the Maesn API |
| `accountKey` | `MAESN_ACCOUNT_KEY`  | Identifies the end user's connected target system |

See the [authentication guide](/authentication) for how to obtain these keys.

## Example

The following example initializes the client and fetches a list of invoices for a connected end user:

```typescript theme={null}
import { Maesn } from "@maesn/typescript-sdk";

const maesn = new Maesn({
  serverURL: "https://api.maesn.dev",
  security: {
    apiKey: process.env["MAESN_API_KEY"] ?? "",
    accountKey: process.env["MAESN_ACCOUNT_KEY"] ?? "",
  },
});

const result = await maesn.accounting.retrieveInvoices();

console.log(result);
```

Replace the environment variables with your actual API key and account key.
