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

# VibeFollow class

> Constructor signature and configuration options.

The `VibeFollow` class is the SDK's single entry point. Construct it once per process with your API key; reuse it across requests.

## Signature

```ts theme={null}
import { VibeFollow } from '@vibefollow/sdk';

const vf = new VibeFollow({
  apiKey: process.env.VIBEFOLLOW_API_KEY!,
  baseUrl: 'https://api.vibefollow.com', // default
  timeoutMs: 10_000,                     // default
  maxRetries: 2,                         // default
  fetchImpl: globalThis.fetch,           // default
});
```

The constructor accepts a `VibeFollowOptions` object. Only `apiKey` is required; the rest have sensible defaults.

## Options

<ParamField path="apiKey" type="string" required>
  Your Vibefollow API key. Prefix `sk_live_` for production, `sk_test_` for the sandbox (when available). Must be kept server-side — the browser is not a supported runtime.
</ParamField>

<ParamField path="baseUrl" type="string" default="https://api.vibefollow.com">
  Override the API base URL. Useful for self-hosted deployments or pointing at a local mock during tests. Trailing slashes are stripped automatically.
</ParamField>

<ParamField path="timeoutMs" type="number" default="10000">
  Per-request timeout in milliseconds. Implemented with `AbortController` — the SDK throws `NetworkError` when the timeout fires.
</ParamField>

<ParamField path="maxRetries" type="number" default="2">
  Maximum number of retry attempts on transient failures (`NetworkError`, `ServerError`, `RateLimitError`). The total request count is `maxRetries + 1`. Set to `0` to disable retries entirely.
</ParamField>

<ParamField path="fetchImpl" type="typeof fetch" default="globalThis.fetch">
  Inject a custom `fetch` implementation. Useful in tests (pass a mock) or on edge runtimes that expose `fetch` under a different global.
</ParamField>

## Resources

After construction the instance exposes three readonly resource APIs:

<CardGroup cols={3}>
  <Card title="vf.users" icon="user" href="/sdk/resources/users">
    `UsersAPI` — identify users; emit lifecycle events.
  </Card>

  <Card title="vf.events" icon="bolt" href="/sdk/resources/events">
    `EventsAPI` — track custom events; create batches.
  </Card>

  <Card title="vf.webhooks" icon="webhook" href="/webhooks/signature-verification">
    `Webhooks` — verify signed webhook deliveries.
  </Card>
</CardGroup>

See [`users`](/sdk/resources/users) and [`events`](/sdk/resources/events) for the per-method reference.

## Headers the SDK sets

Every outgoing request includes:

| Header            | Value                          |
| ----------------- | ------------------------------ |
| `Authorization`   | `Bearer <apiKey>`              |
| `Content-Type`    | `application/json`             |
| `User-Agent`      | `vibefollow-sdk/<SDK_VERSION>` |
| `Idempotency-Key` | `<auto-generated v4 UUID>`     |

<Info>
  The `User-Agent` lets the backend identify and warn on outdated client versions. `SDK_VERSION` is exported from the package if you need it elsewhere.
</Info>

## Lifecycle

The client is stateless — you can construct it on every request if you want, and there's no `close()` method. Keep one instance per process if you prefer the conventional pattern.

<Warning>
  The `EventBatch` instances returned by `vf.events.batch()` **do** carry state (in-memory queue + timer). Always `await batch.flush()` before process exit. See [`events` resource](/sdk/resources/events#batch).
</Warning>

## Deprecated alias

`AIFollowups` is exported as a deprecated alias for `VibeFollow` to ease the `@ai-revenue-manager/sdk` → `@vibefollow/sdk` rename. It will be removed in v2.0.0.

```ts theme={null}
// Both of these work; prefer VibeFollow.
import { VibeFollow, AIFollowups } from '@vibefollow/sdk';
```
