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

# Authentication

> Authenticate your API requests using an API key.

All requests to the Conversion API must include a valid API key. API keys are scoped to a single business and grant full access to that business's data.

## API key format

API keys follow this format:

```
sk_live_<key_id>_<secret>
```

You can generate and manage API keys from the **Settings > API Keys** page in the Conversion dashboard.

<Warning>
  Treat your API key like a password. Do not expose it in client-side code, public repositories, or browser requests. Always make API calls from a secure server environment.
</Warning>

## Authenticating requests

Include your API key in the `X-API-Key` header of every request.

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST https://pub-api.conversion.ai/api/v2/contacts \
    -H "Content-Type: application/json" \
    -H "X-API-Key: sk_live_abc123_def456" \
    -d '{
      "email": "jane@example.com"
    }'
  ```

  ```javascript Node.js theme={null}
  const response = await fetch("https://pub-api.conversion.ai/api/v2/contacts", {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
      "X-API-Key": "sk_live_abc123_def456",
    },
    body: JSON.stringify({
      email: "jane@example.com",
    }),
  });

  const data = await response.json();
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      "https://pub-api.conversion.ai/api/v2/contacts",
      headers={
          "Content-Type": "application/json",
          "X-API-Key": "sk_live_abc123_def456",
      },
      json={
          "email": "jane@example.com",
      },
  )

  data = response.json()
  ```
</RequestExample>

## Error responses

If the API key is missing or invalid, the API returns a `401 Unauthorized` response.

<CodeGroup>
  ```json Missing API key theme={null}
  {
    "error": {
      "code": "unauthorized",
      "message": "API key is required"
    }
  }
  ```

  ```json Invalid API key theme={null}
  {
    "error": {
      "code": "unauthorized",
      "message": "Invalid API key"
    }
  }
  ```
</CodeGroup>
