> ## 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 SDK with your public API key, purchase controller, and unlock mode

Configures the shared Encore instance for use throughout your app. Call it once, at app startup, before any other SDK method.

If your Encore flows include an in-app purchase, pass your [purchase controller](./purchase-controller) here. Both native SDKs bind the controller inside `configure` and expose no setter afterwards, so this is the only place to register it.

## Signature

```dart theme={null}
Future<void> configure({
  required String apiKey,
  EncorePurchaseController? purchaseController,
  EncoreLogLevel logLevel = EncoreLogLevel.none,
  EncoreUnlockMode unlock = EncoreUnlockMode.optimistic,
})
```

## Parameters

| Name                 | Type                                                 | Default                       | Description                                                                                                                                                                                                   |
| -------------------- | ---------------------------------------------------- | ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `apiKey`             | `String`                                             | *(required)*                  | Your Live Key or Test Key from the Encore Dashboard settings                                                                                                                                                  |
| `purchaseController` | [`EncorePurchaseController?`](./purchase-controller) | `null`                        | Your billing code, bound as the SDK's single purchase path. Omit it if your Encore flows have no in-app purchase. See [Configuring without a purchase controller](#configuring-without-a-purchase-controller) |
| `logLevel`           | [`EncoreLogLevel`](#encoreloglevel)                  | `EncoreLogLevel.none`         | Native logging verbosity                                                                                                                                                                                      |
| `unlock`             | [`EncoreUnlockMode`](#encoreunlockmode)              | `EncoreUnlockMode.optimistic` | How a claim grants access                                                                                                                                                                                     |

### EncoreLogLevel

```dart theme={null}
enum EncoreLogLevel { none, error, warn, info, debug }
```

Use `EncoreLogLevel.debug` during development to see detailed native logs, then `EncoreLogLevel.none` for production builds.

### EncoreUnlockMode

```dart theme={null}
enum EncoreUnlockMode { optimistic, strict }
```

| Value        | Behavior                                                                                                                                                                                                                                      |
| ------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `optimistic` | Records the claim and finishes. No in-sheet verification runs. The default                                                                                                                                                                    |
| `strict`     | Verifies the claim server-side on return, and persists unverified claims so they are re-checked across launches. Those settle later as [`EncoreStrictUnlockVerified`](./outcomes#late-strict-unlock-verification) on `Encore.shared.outcomes` |

Set once, at configure. It selects how a claim flow *runs*, never how a result is read: the presentation record is written identically in both modes.

### API keys

| Key type     | Format        | Description                                                                               |
| ------------ | ------------- | ----------------------------------------------------------------------------------------- |
| **Live Key** | `pk_live_...` | Production key with standard geo-filtering based on offers' configured regions            |
| **Test Key** | `pk_test_...` | Development key. Serves demo offers instead of your inventory, and bypasses geo-filtering |

<Info>
  Use the test key (`pk_test_...`) during development to exercise the entire entitlement lifecycle end to end. It serves a demo catalog, so the claim, the advertiser page, and the unlock all work without a live campaign or a real payout.

  **Your own offers do not appear under a test key.** For that, use the live key and accept that the traffic is recorded. See [what a test key serves](/publishers/offers-api/overview#what-a-test-key-serves).
</Info>

<Warning>
  Always use your live key (`pk_live_...`) in production builds.
</Warning>

## Usage

```dart theme={null}
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:encore_flutter/encore_flutter.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  await Encore.shared.configure(
    apiKey: 'pk_live_your_key',
    purchaseController: AppPurchases(),
    logLevel: kDebugMode ? EncoreLogLevel.debug : EncoreLogLevel.none,
    unlock: EncoreUnlockMode.strict,
  );

  runApp(const MyApp());
}
```

## Calling configure more than once

Call `configure()` exactly once. Repeat calls are not safe to rely on:

* **Android ignores a repeat call entirely**, controller included, so a controller the first call omitted can never be added.
* **A repeat call without a controller** clears the Dart-side controller while the native side still routes purchases to the plugin, so every later purchase records `EncorePublisherOutcome.failed`.

## Configuring without a purchase controller

If your Encore flows include no in-app purchase, omit the argument. The SDK then never attempts a purchase, and every presentation records `EncorePublisherOutcome.notAttempted`. That is a supported configuration.

<Note>
  Methods called before `configure()` do nothing: `identify()`, `setUserAttributes()`, and `reset()` complete without effect, and `show()` resolves `EncoreNotPresented` with `EncoreNotPresentedReason.notConfigured`.
</Note>

## Related

* [EncorePurchaseController](./purchase-controller): the shape of the `purchaseController` argument
* [outcomes](./outcomes): the stream that `EncoreUnlockMode.strict` feeds late verifications into
* [Configure the SDK](/publishers/flutter/quickstart/configure) for the step-by-step walkthrough
