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

# Authentication

> How to authenticate with the Raccoon AI Agents API

All API requests require authentication using a Bearer token in the `Authorization` header.

## Getting an API Key

1. Log in to [Raccoon AI](https://raccoonai.tech/app)
2. Click your profile picture in the top right
3. Select **Manage Account**
4. Go to **API Keys**
5. Click **Add new key**
6. Copy and securely store your API key

<video controls autoPlay muted loop playsInline className="w-full aspect-video rounded-xl" src="https://cdn.raccoonai.tech/assets/api-key.mp4" />

<Warning>
  API keys are shown only once. If you lose your key, you'll need to generate a new one.
</Warning>

## Using Your API Key

Include your API key in the `Authorization` header of all requests:

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

### Example Request

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET https://api.raccoonai.tech/chats \
    -H "Authorization: Bearer sk_live_abc123xyz"
  ```

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

  API_KEY = "sk_live_abc123xyz"

  response = requests.get(
      "https://api.raccoonai.tech/chats",
      headers={"Authorization": f"Bearer {API_KEY}"}
  )
  ```

  ```javascript JavaScript theme={null}
  const API_KEY = "sk_live_abc123xyz";

  const response = await fetch("https://api.raccoonai.tech/chats", {
    headers: { "Authorization": `Bearer ${API_KEY}` }
  });
  ```
</CodeGroup>

## WebSocket Authentication

For WebSocket connections, pass the token as a query parameter:

```
wss://api.raccoonai.tech/ws/chat/{taskId}?token=YOUR_API_KEY&message_id={messageId}&last_stream_entry_id=0-0
```

## Authentication Errors

### 401 Unauthorized

Returned when the API key is missing or invalid:

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

### 403 Forbidden

Returned when the API key doesn't have permission for the requested resource:

```json theme={null}
{
  "error": "forbidden",
  "message": "You don't have access to this resource"
}
```
