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

# Authentication

> Learn how to authenticate your API requests using Bearer tokens

All API requests (except `/health`) require authentication using an API key passed as a Bearer token in the `Authorization` header.

## Get your API key

You can generate and manage your API keys from the [AiQL Dashboard](https://app.aiql.io).

## Making authenticated requests

Include your API key in the `Authorization` header with the `Bearer` scheme:

```bash theme={null}
curl https://api.aiql.io/workspaces \
  -H "Authorization: Bearer YOUR_API_KEY"
```

Replace `YOUR_API_KEY` with your actual API key from the dashboard.

## Workspace header

All ingestion, query, and request endpoints require the `AiQL-Workspace` header containing your workspace ID. This tells the API which workspace to operate on.

```bash theme={null}
curl https://api.aiql.io/ingestions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "AiQL-Workspace: YOUR_WORKSPACE_ID"
```

Replace `YOUR_WORKSPACE_ID` with your workspace ID from the dashboard. You can get your workspace ID by listing workspaces or from the dashboard URL.

## Example request

Here's a complete example of creating a workspace:

```bash theme={null}
curl -X POST https://api.aiql.io/workspaces \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'
```

## Public endpoints

The `/health` endpoint does not require authentication and can be accessed without an API key:

```bash theme={null}
curl https://api.aiql.io/health
```

<Warning>
  Keep your API keys secure and never commit them to version control. If you believe your API key has been compromised, regenerate it immediately from the dashboard.
</Warning>
