Authorization: Bearer header with a valid token.
| Method | Format | Best for |
|---|---|---|
| Session token | 32-char random string | CLI (default) |
| Personal Access Token | cnap_pat_... | CI/CD, scripts |
| OAuth2 JWT | eyJ... (JWT) | Custom integrations |
cnap auth login).
For CI/CD and scripts, Personal Access Tokens (PATs) are recommended.
CLI Authentication
The fastest way to get started is with the CLI:The CLI stores your token in
~/.cnap/config.yaml. Run cnap auth status to check your current session.Session Tokens
When you runcnap auth login, the CLI stores a session token. Sessions are long-lived (1 year) and auto-refresh on every use, so active sessions effectively never expire.
If your session ever expires, just log in again:
Personal Access Tokens
PATs are long-lived tokens prefixed withcnap_pat_. They’re the recommended approach for CI/CD pipelines, scripts, and automated workflows.
Create a token via the CLI
~/.cnap/config.yaml.
Create a token via the dashboard
You can also create PATs from the CNAP dashboard at Account > Access Tokens.Create a token via the API
If you already have a valid token, you can create additional PATs programmatically:List and revoke tokens
- CLI
- curl
Workspace Scoping
Many endpoints operate within a workspace context. Pass the workspace ID via theX-Workspace-Id header:
403 Forbidden error.
Security
- CNAP never stores plaintext tokens. PATs are hashed before storage.
- PATs can have an expiration date. Expired tokens are rejected automatically.
- Each PAT tracks its last used timestamp for auditing.
- Revoked tokens are deleted immediately and cannot be recovered.
- Session tokens are validated server-side on every request and can be revoked via
cnap auth logout.