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

# Client

> Create one client and reuse it.

```ts theme={null}
import { createClient } from "@revenuebee/sdk";

const crm = createClient({
  apiKey: process.env.CRM_API_KEY!,
  baseUrl: "https://crm.example.com",
});
```

**apiKey** `string` *required*

A key from **Settings → API keys**, starting with `gd_key_`. Sent as a bearer token on every request.

**baseUrl** `string` *required*

The address your CRM is served on.

**fetch** `typeof fetch`

A `fetch` to use instead of the global one, for older runtimes or tests.

## Methods

Methods are grouped by what they work on: `crm.contacts`, `crm.events`, `crm.externalAccounts`, `crm.subscriptions`, `crm.payments`, `crm.notes`, `crm.communications`, `crm.tasks`, `crm.goals`, `crm.chat` and `crm.calls`. Every input and result is typed, so your editor lists what each one takes.

```ts theme={null}
const [contact] = await crm.contacts.upsert({ dbId: user.id, name: user.name });
await crm.tasks.create({ partyId: contact.id, type: "todo", title: "Send the welcome pack" });
```

> [!TIP]
>
> Already sent this customer? Look them up with [`contacts.resolve`](https://docs.revenuebee.ai/sdk/resolve-contact) instead. Faster still: save
> `contact.id` in your own database the first time, and pass it as `partyId` from then on. No lookup needed.

Every method except `contacts.upsert` and `contacts.get` names the customer by the CRM's `partyId`: the `id` that upsert
returns, or what `contacts.resolve` finds from your own id.

## Results

Every method resolves to a pair, and never throws:

```ts theme={null}
const [data, error] = await crm.contacts.upsert({ dbId: "user_42", name: "Ada" });

if (error) {
  // error.code, error.message, error.status
  return;
}

// data is the contact
```

Exactly one of the two is set. See [Errors](https://docs.revenuebee.ai/sdk/errors.md) for every `error.code`.

The SDK works in Node 18 and later, Bun, Deno, and edge runtimes such as Cloudflare Workers.


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