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

# Authentication

The BaClique API uses API keys to authenticate requests. Each key is tied to your account and has full access to your data.

## API Key Format

```
sk_live_example123456789
```

* `sk_` = Secret Key prefix
* `live_` = Live mode (production)
* Followed by 32+ random characters

## Using Your API Key

Include your key in the `Authorization` header:

<CodeGroup>
  ```bash cURL theme={null}
  curl https://api.baclique.com/v1/campaigns \
    -H "Authorization: Bearer sk_live_YOUR_API_KEY"
  ```

  ```javascript JavaScript theme={null}
  fetch('https://api.baclique.com/v1/campaigns', {
    headers: {
      'Authorization': 'Bearer sk_live_YOUR_API_KEY'
    }
  });
  ```
</CodeGroup>

## Security Best Practices

1. **Never commit API keys** to version control
2. **Use environment variables** to store keys
3. **Rotate keys regularly** if you suspect a leak
4. **Use different keys** for development and production
5. **Limit exposure** - only your backend should use the API key

### Environment Variable Example

```bash theme={null}
# .env file (never commit this!)
BACLIQUE_API_KEY=sk_live_your_key_here
```

```javascript theme={null}
// Node.js
const apiKey = process.env.BACLIQUE_API_KEY;

fetch('https://api.baclique.com/v1/campaigns', {
  headers: {
    'Authorization': `Bearer ${apiKey}`
  }
});
```

## Rate Limiting

* **100 requests per minute** per API key
* Rate limit headers are included in responses:

```
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 95
X-RateLimit-Reset: 1705765200
```

When exceeded:

```json theme={null}
{
  "error": "Rate limit exceeded. 100 requests per minute."
}
```

## Errors

| Status | Error                      | Solution                        |
| ------ | -------------------------- | ------------------------------- |
| 401    | Invalid or missing API key | Check your Authorization header |
| 403    | PRO plan required          | Upgrade your subscription       |
| 429    | Rate limit exceeded        | Wait and retry with backoff     |
