Authentication
Learn how to authenticate your applications with Kopai.
API Tokens
Section titled “API Tokens”Kopai uses bearer tokens for API authentication. All OTLP requests must include your token in the Authorization header.
Creating a Token
Section titled “Creating a Token”- Navigate to Settings → Access Tokens
- Click Generate New Token
- Give your token a descriptive name
- Copy the token immediately (it won’t be shown again)
Using Your Token
Section titled “Using Your Token”Include your token in the Authorization header:
Authorization: Bearer YOUR_TOKENOr set via environment variable:
export OTEL_EXPORTER_OTLP_HEADERS="Authorization=Bearer YOUR_TOKEN"Token Best Practices
Section titled “Token Best Practices”- Use separate tokens for different environments (dev, staging, prod)
- Rotate tokens regularly
- Never commit tokens to source control
- Revoke unused tokens promptly
CLI Authentication
Section titled “CLI Authentication”To query traces, logs, and metrics from the terminal, create a read-only CLI token.
Create a CLI Token
Section titled “Create a CLI Token”- Navigate to Settings → Access Tokens
- Click Generate New Token
- Select CLI as the token type
- Give your token a descriptive name
- Copy the token immediately (it won’t be shown again)
npx @kopai/cli loginPaste your CLI token at the prompt. The token is saved to .kopairc in the current directory.
| Flag | Description |
|---|---|
--url <url> | Set the Kopai server URL (default: https://kopai.app) |
--global | Save to ~/.kopairc instead of ./.kopairc |
--config <path> | Use a custom config file path |
If .kopairc is not in your .gitignore, the CLI will warn you.
Logout
Section titled “Logout”npx @kopai/cli logoutRemoves the token from .kopairc. Other config fields (like url) are preserved.
| Flag | Description |
|---|---|
--global | Remove token from ~/.kopairc |
--config <path> | Use a custom config file path |
Verify Authentication
Section titled “Verify Authentication”npx @kopai/cli whoamiDisplays your token prefix and server URL. Validates the token against the server if reachable.
Config File
Section titled “Config File”The CLI stores credentials in .kopairc:
{ "url": "https://kopai.app", "token": "kpi_..."}Resolution order: --config flag → ./.kopairc → ~/.kopairc
Token Expiry
Section titled “Token Expiry”CLI tokens expire after 90 days. When your token expires:
- Create a new CLI token in the dashboard (Settings → Access Tokens)
- Run
npx @kopai/cli loginand paste the new token