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

# Authentication

> Learn how to securely authenticate using API keys.

## Overview

All API requests require authentication via **Bearer tokens**. This ensures secure and authorized access to your organization's data.

> [!NOTE]
>
> Tokens are tied to your organization.

## Creating API Keys

To generate an API key:

1. Go to your [API keys](https://app.halesis.com/api) in the dashboard.
2. Click **Create key** on the top right.
3. Enter a name and, optionally, select an expiry date.
4. Copy the token and store it securely.

> [!TIP]
>
> Never expose your API key in public repositories or frontend code.

## Using Bearer Tokens

Include your token in the `Authorization` header of every request:

```http theme={null}
Authorization: Bearer sk-abc123yourapikey
```

### Examples

**HTTP Request Example:**

```http theme={null}
GET /v1/models HTTP/1.1
Host: api.halesis.com
Authorization: Bearer sk-abc123yourapikey
Content-Type: application/json
```

**cURL Example:**

```bash theme={null}
curl -H "Authorization: Bearer sk-abc123yourapikey" \
     -H "Content-Type: application/json" \
     https://api.halesis.com/v1/models
```

## Token Management

> [accordion] Rotating API Keys
>
> It's a good practice to rotate your API keys periodically.
>
> 1. Generate a new key.
> 2. Update your environment variables.
> 3. Revoke the old key.

> [accordion] Revoking API Keys
>
> To revoke a key:
>
> 1. Go to [API keys](https://app.halesis.com/api)
> 2. Click on **Revoke** next to the key you want to disable.

## Common Issues

> [accordion] Invalid Token
>
> Ensure your token is correct, has no extra spaces, and is included in the `Authorization` header.

> [accordion] Expired Token
>
> If your request returns `401 Unauthorized`, check if the key was revoked or regenerated. Replace it with a valid key.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.