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

# API Key

> Manage your API key for authenticating with the WSAPI

Your API key authenticates every request to the WSAPI. Each account has a unique API key that grants access to all instances under that account.

## Finding your API key

<Steps>
  <Step title="Log in to your dashboard">
    Go to [wsapi.chat/app/settings](https://wsapi.chat/app/settings).
  </Step>

  <Step title="Create your API Key">
    Find the **API Keys** section and click on **Generate Api Key**.
  </Step>

  <Step title="Copy your key">
    Click the copy button next to your API key. You'll use this in the `X-Api-Key` header for all API requests.

    <Warning>
      Store your API Key securely. You won't be able to see it again after you navigate away. If you lose it, you'll need to generate a new one.
    </Warning>
  </Step>
</Steps>

## Using your API key

Include the `X-Api-Key` header in every request alongside the `X-Instance-Id` header:

```bash theme={null}
curl -X GET https://api.wsapi.chat/chats \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "X-Instance-Id: YOUR_INSTANCE_ID"
```

## Security best practices

* **Never expose your key in client-side code** — keep it server-side only
* **Don't commit keys to version control** — use environment variables instead
* **Rotate immediately if compromised** — generate a new key from your dashboard
* **Use environment variables** in your application:

```bash theme={null}
export WSAPI_API_KEY="your_api_key_here"
export WSAPI_INSTANCE_ID="your_instance_id_here"
```

## Rotating your API key

If you lost your API key or suspect it has been exposed, rotate it using the **Rotate API Key** button in the same section of your dashboard. This will invalidate the old key and generate a new one immediately.

<Note>
  After rotating your API key, update all applications and integrations that use the old key.
</Note>
