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

# Authentication

> How to authenticate your ScoutLayer API requests.

Every request to the ScoutLayer API must include a valid API key. You can pass it in one of two ways:

## Option 1 — X-API-Key header (recommended)

```http theme={null}
X-API-Key: YOUR_API_KEY
```

<CodeGroup>
  ```bash cURL theme={null}
  curl https://api.scoutlayer.io/v1/shopify/apps/klaviyo \
    -H "X-API-Key: YOUR_API_KEY"
  ```

  ```typescript TypeScript theme={null}
  const res = await fetch(
    "https://api.scoutlayer.io/v1/shopify/apps/klaviyo",
    { headers: { "X-API-Key": "YOUR_API_KEY" } }
  );
  ```

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

  res = httpx.get(
      "https://api.scoutlayer.io/v1/shopify/apps/klaviyo",
      headers={"X-API-Key": "YOUR_API_KEY"},
  )
  ```
</CodeGroup>

## Option 2 — Authorization: Bearer header

```http theme={null}
Authorization: Bearer YOUR_API_KEY
```

<CodeGroup>
  ```bash cURL theme={null}
  curl https://api.scoutlayer.io/v1/shopify/apps/klaviyo \
    -H "Authorization: Bearer YOUR_API_KEY"
  ```

  ```typescript TypeScript theme={null}
  const res = await fetch(
    "https://api.scoutlayer.io/v1/shopify/apps/klaviyo",
    { headers: { "Authorization": "Bearer YOUR_API_KEY" } }
  );
  ```

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

  res = httpx.get(
      "https://api.scoutlayer.io/v1/shopify/apps/klaviyo",
      headers={"Authorization": "Bearer YOUR_API_KEY"},
  )
  ```
</CodeGroup>

## Getting your API key

1. Open the [dashboard](https://app.scoutlayer.io/settings/api-keys).
2. Click **New API key**, give it a name, and copy the key immediately — it won't be shown again.

<Warning>
  Keep your API key secret. Never commit it to source control or expose it in client-side code. Use environment variables or a secrets manager.
</Warning>

## Error responses

| Status                 | Meaning                                                                                                            |
| ---------------------- | ------------------------------------------------------------------------------------------------------------------ |
| `401 Unauthorized`     | Missing or invalid API key.                                                                                        |
| `402 Payment Required` | Valid key, but your credit balance is zero. [Top up in the dashboard](https://app.scoutlayer.io/settings/billing). |
