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

# Initialize API Key

> Learn how to generate and configure API keys for Namespace Offchain SDK operations, including address-based and domain-specific keys.

To interact with the offchain system, you'll need an API key. You can configure your API key either for all domains associated with an address (recommended) or for specific ENS domains.

### Get API Key from the Namespace App

<Card title="Get API Key" icon="link" href="/user-guide/dev-portal/api-keys" horizontal>
  Guide on how to get an API key from the Offchain section of the Namespace App.
</Card>

## Configuring Your API Key

<Tabs>
  <Tab title="Address-based API Key (Default)">
    Works with all ENS domains registered to your address:

    ```typescript theme={null}
    import { createOffchainClient } from "@thenamespace/offchain-manager";

    // During initialization
    const client = createOffchainClient({
      mode: "mainnet",
      defaultApiKey: "your-address-based-api-key"
    });

    // Or after initialization
    const client = createOffchainClient();
    client.setDefaultApiKey("your-address-based-api-key");
    ```
  </Tab>

  <Tab title="Domain-based API Keys">
    Works with specific ENS domains only:

    ```typescript theme={null}
    import { createOffchainClient } from "@thenamespace/offchain-manager";

    // During initialization
    const client = createOffchainClient({
      mode: "mainnet",
      domainApiKeys: {
        "example.eth": "your-domain-api-key",
        "test.eth": "another-domain-key"
      }
    });

    // Or after initialization
    const client = createOffchainClient();
    client.setApiKey("example.eth", "your-domain-api-key");
    ```
  </Tab>
</Tabs>

## API Key Types

* **Address-based API key**: Works with all ENS domains registered to your address
* **Domain-based API key**: Works with a specific ENS domain only

## Priority Order

1. Domain-specific API key (if set)
2. Default address-based API key
