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

# configure()

> Initialize the Encore Web SDK: EncoreConfig contract (apiKey required; redemptionMode, logLevel), configure-once semantics, boolean return, and the getConfiguration() snapshot. Identity is an auto-generated anonymous UUID; attach your real user id with identify().

Configures the SDK. Must be called once, before any other SDK method.

## Signature

```typescript theme={null}
function configure(config: EncoreConfig): boolean
```

Returns `true` on success. On invalid input it logs the validation error and returns
`false`; it does not throw.

<Warning>
  **Configure-once:** only the first successful call is honored. Subsequent calls log a
  warning and are ignored; reload the page to reconfigure.
</Warning>

## Structure

```typescript theme={null}
interface EncoreConfig {
  apiKey: string;                              // required: your publishable key (pk_...)
  logLevel?: 'none' | 'debug';                 // default 'none'
  redemptionMode?: 'deferred' | 'immediate';   // app-wide default: 'deferred'; overridable per placement
}
```

`configure()` carries connection and behavior settings only; there is no user id in it.
The SDK generates an anonymous UUID on first load and persists it in `localStorage` (the
same visitor keeps the same id across reloads); attach your real user id with
[`identify()`](/publishers/web/sdk-reference/identify) once you know it.

## Field Reference

| Field            | Type     | Required | Default      | Description                                                                                                                                                                                                                                                                                                                         |
| ---------------- | -------- | -------- | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `apiKey`         | `string` | Yes      | -            | Publishable key (`pk_...`) from the [Dashboard](https://dashboard.encorekit.com). Safe in client-side code.                                                                                                                                                                                                                         |
| `logLevel`       | `string` | No       | `'none'`     | `'debug'` for verbose console logging during integration. Changeable later with `Encore.setLogLevel(level)`.                                                                                                                                                                                                                        |
| `redemptionMode` | `string` | No       | `'deferred'` | The **app-wide default** claim↔redeem coupling; a placement's own `redemptionMode` option overrides it per surface. `'deferred'`: `show()` records the claim, `redeem()` fires the redirect later. `'immediate'`: claiming opens the advertiser tab in one step. See [Redemption Modes](/publishers/web/concepts/redemption-modes). |

Offer-surface copy is not configured here: per-surface heading copy is set via a
placement's `header` option (see
[`placement()`](/publishers/web/sdk-reference/placement)); campaign copy is managed
remotely per campaign.

## Examples

```javascript theme={null}
import Encore from '@encorekit/web-sdk';

// Minimal: anonymous id auto-generated
Encore.configure({ apiKey: 'pk_live_yourpublishablekey' });

// Typical production setup
Encore.configure({
  apiKey: import.meta.env.VITE_ENCORE_API_KEY,
  redemptionMode: 'immediate',                 // app-wide default; placements can override per surface
  logLevel: import.meta.env.DEV ? 'debug' : 'none',
});
```

React apps can use the provider instead (same options as props); see the
[React guide](/publishers/web/frameworks/react):

```tsx theme={null}
import { EncoreProvider } from '@encorekit/web-sdk/react';

<EncoreProvider apiKey={import.meta.env.VITE_ENCORE_API_KEY}>
  {children}
</EncoreProvider>
```

## Inspecting the live configuration

```typescript theme={null}
function isConfigured(): boolean
function getConfiguration(): {
  apiKey: string;
  baseURL: string;
  analyticsBaseURL: string;
  logLevel: string;
  redemptionMode: 'deferred' | 'immediate';
} | null
```

`getConfiguration()` returns a read-only snapshot of what the SDK is actually using
(including the resolved endpoint URLs), or `null` before a successful `configure()`.

```javascript theme={null}
Encore.isConfigured();                         // true
Encore.getConfiguration()?.redemptionMode;     // 'deferred' | 'immediate'
Encore.getCurrentUserId();                     // the anonymous UUID, or your identify()'d id
Encore.getVersion();                           // the SDK version string
```

## Related

* [`identify()`](/publishers/web/sdk-reference/identify): attach your stable user id
* [`show()`](/publishers/web/sdk-reference/show): present offers
* [Redemption Modes](/publishers/web/concepts/redemption-modes): choosing `redemptionMode`
