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

# Authentication

> How to authenticate with the Humic API using API keys.

The Humic API uses **API keys** to authenticate requests. Each API key is scoped to a single design system.

## Creating an API key

1. Open your design system in the [Humic dashboard](https://humic.dev)
2. Go to **Settings** → **API Keys**
3. Click **Create API Key** and give it a name

Your key will look like `sk_live_...`. Store it securely — you won't be able to see it again.

<Warning>
  API keys grant read access to your design system's tokens, scales, and primitives. Treat them like passwords.
</Warning>

## Using the API key

Pass your key in the `Authorization` header:

```bash theme={null}
curl https://humic.dev/api/v1/tokens \
  -H "Authorization: Bearer sk_live_your_key_here"
```

All endpoints under `/api/v1/tokens`, `/api/v1/primitives`, `/api/v1/project`, and `/api/v1/export/*` use this authentication method.

## CLI tokens

The CLI uses a separate authentication method. When you run `humic login`, a **CLI token** is created and stored locally at `~/.config/humic/credentials`. CLI tokens expire after 90 days.

For CI environments, you can authenticate with a token directly:

```bash theme={null}
npx @humicdev/cli login --token $HUMIC_CLI_TOKEN
```

Create CLI tokens in the dashboard under **Settings** → **CLI Tokens**.

## Error responses

| Status | Meaning                                |
| ------ | -------------------------------------- |
| `401`  | Missing or invalid API key             |
| `403`  | Valid key but insufficient permissions |
| `429`  | Rate limit exceeded                    |

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