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

# Authentication

> API key, basic auth, and custom HTTP headers for Chromiumly and Gotenberg.

Chromiumly supports API key auth (hosted API), basic auth (Gotenberg 8.4+), and custom HTTP headers.

## API key (hosted API)

Used for the hosted API at `https://api.chromiumly.dev`. When both API key and basic auth are set, the API key takes precedence.

**Environment:**

```bash theme={null}
CHROMIUMLY_API_KEY=your-api-key
```

**Code:**

```typescript theme={null}
import { Chromiumly } from "chromiumly";

Chromiumly.configure({ apiKey: "your-api-key" });
```

See [Configuration](/configuration) for full setup.

## Basic authentication

Gotenberg supports basic auth from [v8.4.0](https://github.com/gotenberg/gotenberg/releases/tag/v8.4.0). Example Docker run:

```bash theme={null}
docker run --rm -p 3000:3000 \
  -e GOTENBERG_API_BASIC_AUTH_USERNAME=user \
  -e GOTENBERG_API_BASIC_AUTH_PASSWORD=pass \
  gotenberg/gotenberg:8.4.0 gotenberg --api-enable-basic-auth
```

Configure Chromiumly via environment:

```bash theme={null}
GOTENBERG_ENDPOINT=http://localhost:3000
GOTENBERG_API_BASIC_AUTH_USERNAME=user
GOTENBERG_API_BASIC_AUTH_PASSWORD=pass
```

Or with the `config` library:

```json theme={null}
{
  "gotenberg": {
    "endpoint": "http://localhost:3000",
    "api": {
      "basicAuth": {
        "username": "user",
        "password": "pass"
      }
    }
  }
}
```

Or in code:

```typescript theme={null}
Chromiumly.configure({
  endpoint: "http://localhost:3000",
  username: "user",
  password: "pass",
});
```

## Custom HTTP headers

For Bearer tokens or other headers, use `customHttpHeaders`:

```typescript theme={null}
const token = await getToken();

Chromiumly.configure({
  endpoint: "http://localhost:3000",
  customHttpHeaders: {
    Authorization: `Bearer ${token}`,
    "X-Custom-Header": "value",
  },
});
```

These headers are sent with every request to Gotenberg (or the hosted API when using an API key).
