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

# Authentication

> How to authenticate with the Kathan API

# Authentication

The Kathan API requires both a Bearer token and an `X-User-ID` header for secure access to all endpoints except health checks.

## Bearer Token Format

Include your API key and user id in the headers:

```
Authorization: Bearer sk_live_your_api_key_here
X-User-ID: user_xxx
```

## Example Request

```bash theme={null}
curl -H "Authorization: Bearer sk_live_your_key" \
  -H "X-User-ID: user_xxx" \
  "https://api.staging.kathan.tech/protected"
```

## Response

```json theme={null}
{
  "message": "Hello, user user_xxx!",
  "user_id": "user_xxx"
}
```

## Rate Limits

* **Development**: 100 requests/minute
* **Production**: 1,000 requests/minute
* **Enterprise**: Custom limits

Rate limit headers are included in responses:

```
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 99
X-RateLimit-Reset: 1640995200
```

## Error Responses

**401 Unauthorized**

```json theme={null}
{
  "detail": "Invalid authentication credentials"
}
```

**429 Too Many Requests**

```json theme={null}
{
  "detail": "Rate limit exceeded"
}
```
