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

# Authenticating to Kosli

> How to get an API token for the Kosli CLI and API, and where to manage credentials.

Most interactions with Kosli — from the CLI, the API, or CI/CD pipelines — require an API token. This page covers the quickest path to getting one and points to the deeper documentation for each topic.

## Pick a credential type

| Use case | Credential | Where to manage it |
| - | - | - |
| CI/CD, runtime reporters, automation | **Service account API key** (recommended) | [Service accounts](https://docs.kosli.com/administration/authentication/service_accounts.md) |
| Interactive scripts tied to your user | **Personal API key** | [Personal API keys](https://docs.kosli.com/user/personal_api_keys.md) |

> [!TIP]
>
> For anything automated, use a service account. Personal API keys inherit your user's permissions across every organization you belong to, which is rarely what you want for a pipeline.

## Quick start: get a token

**1. Sign in to Kosli**

Open the Kosli web app and sign in:

* EU: [app.kosli.com](https://app.kosli.com)
* US: [app.us.kosli.com](https://app.us.kosli.com)

Depending on how your organization is set up, you'll sign in with single sign-on, [Magic Link](https://docs.kosli.com/administration/authentication/magic_link.md) or [GitHub](https://docs.kosli.com/administration/authentication/github_login.md).

**2. Create a key**

* **For CI/CD**, follow [Service accounts](https://docs.kosli.com/administration/authentication/service_accounts.md) to create a service account and generate its first API key.
* **For your own scripts**, follow [Personal API keys](https://docs.kosli.com/user/personal_api_keys.md) to generate a key tied to your user.

**3. Copy the key immediately**

Kosli stores only a hash of the token, so the original is shown once and cannot be retrieved later. Paste it straight into your secret store.

## Use the token

Pass the token as a bearer token when calling the API directly:

```shell theme={"theme":"dracula","languages":{"custom":["/languages/rego.json"]}}
curl -H "Authorization: Bearer <<your-api-key>>" \
  https://app.kosli.com/api/v2/environments/<<your-org-name>>
```

For CLI usage, basic auth, and full examples, see [API authentication methods](https://docs.kosli.com/administration/authentication/api_authentication_methods.md).

## See also

* [Single sign-on](https://docs.kosli.com/administration/authentication/single_sign_on.md) — configure sign-in through your identity provider.
* [Magic Link](https://docs.kosli.com/administration/authentication/magic_link.md) — sign in with an emailed link, without an identity provider.
* [GitHub sign-in](https://docs.kosli.com/administration/authentication/github_login.md) — sign in with a GitHub account, including GitHub IP allow lists.
* [Service accounts](https://docs.kosli.com/administration/authentication/service_accounts.md) — admin lifecycle for machine credentials.
* [API key rotation](https://docs.kosli.com/administration/authentication/api_key_rotation.md) — how rotation works, with a [step-by-step tutorial](https://docs.kosli.com/tutorials/rotating_api_keys.md).
* [Roles in Kosli](https://docs.kosli.com/administration/managing_users/roles_in_kosli.md) — what users and service accounts can do at each role.


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