> ## 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

<ParamField body="apiKey" type="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](/help/settings#api-keys) in the dashboard.
</ParamField>

<ParamField body="endpoint" type="string" default="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]`.
</ParamField>

<ParamField body="debug" type="boolean" default="false">
  Enable SDK lifecycle logging in the browser console, prefixed with `[Wendung]`. Intended for development; disable in production. See [Debugging](/configuration/debugging) for the full list of messages. Warnings are emitted regardless of this setting.
</ParamField>

<ParamField body="flushInterval" type="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.
</ParamField>

<ParamField body="maxBatchSize" type="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.
</ParamField>

<ParamField body="trackPageviews" type="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](/help/sites). See [`page()`](/api-reference/page) for manual capture.
</ParamField>

<ParamField body="consent" type="'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()`](/api-reference/set-consent) when the choice changes. See the [consent guide](/guides/consent) for the setup and data limits.
</ParamField>

## 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](/quickstart): the minimal setup, in context.
* [Debugging](/configuration/debugging): what `debug: true` logs and how to interpret warnings.
* [`step()`](/api-reference/step) and [`identify()`](/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.