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

# Authentication

> How to authenticate with the Fenra API

All Fenra API requests require an API key passed in the `X-Api-Key` header.

## Getting an API Key

1. Sign in to [app.fenra.io](https://app.fenra.io)
2. Go to **Settings → API Keys**
3. Click **Create New Key**
4. Copy the key immediately. It is only shown once.

## Using Your API Key

Include the key in the `X-Api-Key` header on every request:

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST 'https://ingest.fenra.io/usage/transactions' \
    -H 'Content-Type: application/json' \
    -H 'X-Api-Key: YOUR_API_KEY' \
    -d '{"provider": "openai", ...}'
  ```

  ```javascript Node.js theme={null}
  const response = await fetch('https://ingest.fenra.io/usage/transactions', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'X-Api-Key': process.env.FENRA_API_KEY
    },
    body: JSON.stringify(transaction)
  });
  ```

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

  response = requests.post(
      'https://ingest.fenra.io/usage/transactions',
      headers={
          'Content-Type': 'application/json',
          'X-Api-Key': os.getenv('FENRA_API_KEY')
      },
      json=transaction
  )
  ```
</CodeGroup>

## Error Response

Invalid or missing keys return `401 Unauthorized`:

```json theme={null}
{
  "error": {
    "code": "unauthorized",
    "message": "Invalid or missing API key"
  }
}
```

## Troubleshooting

If you're getting `401 Unauthorized`:

1. Verify the key exists in your dashboard
2. Check the key is active (not disabled)
3. Confirm the header name is `X-Api-Key` (case-sensitive)
4. Check for extra spaces or characters
