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

# init() options

> Reference for every option accepted by Wendung.init(): apiKey, endpoint, flushInterval, maxBatchSize, trackPageviews, consent, and debug, with defaults, types, and constraints.

`init()` accepts a single configuration object. Call it once at application startup, before any other SDK method. Calling `init()` a second time is safe: it tears down the previous instance and starts a fresh one, which makes the SDK compatible with React Strict Mode and Next.js Fast Refresh.

## Options

**apiKey** `string` *required*

Your publishable API key. It is safe to include in browser code and is sent as the `X-API-Key` header on every ingest request. Find or create keys under [Settings → API Keys](https://docs.wendung.app/help/settings.md#api-keys) in the dashboard.

**endpoint** `string` (default: [https://ingest.wendung.app/v1/events](https://ingest.wendung.app/v1/events))

The ingest URL. Set it only if you route through your own CDN or run a self-hosted ingest service.

Must use `https://`. `http://` is allowed only when the hostname is `localhost`, `127.0.0.1`, or `[::1]`.

**debug** `boolean` (default: false)

Enable SDK lifecycle logging in the browser console, prefixed with `[Wendung]`. Intended for development; disable in production. See [Debugging](https://docs.wendung.app/configuration/debugging.md) for the full list of messages. Warnings are emitted regardless of this setting.

**flushInterval** `number` (default: 5000)

Milliseconds between automatic event flushes. While collection is active, the SDK sends queued events each time the timer fires. The value is used as-is, without validation or clamping. Flushing also happens when `maxBatchSize` is reached and on page hide, regardless of this interval.

**maxBatchSize** `number` (default: 50)

Maximum number of events in a single HTTP request. If the queue reaches this threshold before the flush timer fires, the SDK flushes immediately.

Effective range is `1` to `100`: fractional values are floored, values below `1` are treated as `1`, and values above `100` (the ingest endpoint's per-request limit) are capped with a one-time warning. Your configured value is not mutated.

**trackPageviews** `boolean | 'auto'` (default: false)

Automatic pageviews are off by default. `true` records full pageviews only with granted consent. `'auto'` records aggregate pageviews while consent is pending, then full pageviews after consent is granted. `denied` stops collection in either mode.

When enabled, the SDK records the initial load and navigation through `pushState`, `replaceState`, and `popstate`. Aggregate collection ignores changes to only the query string or fragment. Pageviews count against your plan's pageview allowance and appear in reports for registered [sites](https://docs.wendung.app/help/sites.md). See [`page()`](https://docs.wendung.app/api-reference/page) for manual capture.

**consent** `'pending' | 'granted' | 'denied'` (default: granted)

The visitor's analytics choice at startup. `pending` allows only aggregate pageviews when `trackPageviews` is `'auto'`; otherwise it stops collection. `granted` enables full analytics. `denied` stops all collection, discards queued events, and removes stored SDK identifiers.

Pass the saved choice on every load. The SDK does not store it. Use [`setConsent()`](https://docs.wendung.app/api-reference/set-consent) when the choice changes. See the [consent guide](https://docs.wendung.app/guides/consent.md) for the setup and data limits.

## Errors

`init()` throws synchronously if the configuration is invalid:

| Error message | Cause |
| - | - |
| `Missing required configuration` | `apiKey` was missing or empty |
| `Invalid endpoint URL` | `endpoint` could not be parsed as a URL |
| `Endpoint must use https:// (http:// allowed for localhost)` | `endpoint` uses `http://` with a non-local hostname |
| `trackPageviews must be true, false, or "auto"` | `trackPageviews` was set to another value |
| `consent must be "pending", "granted", or "denied"` | `consent` was set to another value |

## Complete example

The snippet below shows every option. Only `apiKey` is required.

```ts theme={null}
Wendung.init({
  apiKey: 'pk_your_publishable_key',
  debug: import.meta.env.DEV, // or: process.env.NODE_ENV !== 'production'
  flushInterval: 10000,
  maxBatchSize: 25,
  trackPageviews: 'auto',
  consent: 'pending',
})
```

## See also

* [Quickstart](https://docs.wendung.app/quickstart.md): the minimal setup, in context.
* [Debugging](https://docs.wendung.app/configuration/debugging.md): what `debug: true` logs and how to interpret warnings.
* [`step()`](https://docs.wendung.app/api-reference/step) and [`identify()`](https://docs.wendung.app/api-reference/identify): the methods you'll call after `init()`.


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