Authentication & scopes
Every request to the Comwit Cloud API at https://api.cloud.comwit.io is
authenticated with a bearer token sent in the Authorization header:
Authorization: Bearer <token>If you have never used the API before, the short version is: you get a personal
access token (it starts with cwt_), and you send it on every call. This page
explains the two kinds of tokens, what scopes are, and how to obtain your token
with the comwit CLI or the console.
Token classes
Section titled “Token classes”There are two classes of token. As a user, you only ever use the first one.
cwt_<hex> — user personal access token (what you use)
Section titled “cwt_<hex> — user personal access token (what you use)”A personal access token (PAT) is tied to your user account. It starts with
the prefix cwt_ followed by a hex string. A cwt_ token is scoped: it can
only perform the actions its scopes allow, and it can only touch projects you
are a member of.
On every request, the API verifies the token and enforces both scope and project membership. If the token lacks the required scope, or you are not a member of the target project, the request is rejected.
PLATFORM_API_SERVER_TOKEN — internal operator/web token (not for you)
Section titled “PLATFORM_API_SERVER_TOKEN — internal operator/web token (not for you)”PLATFORM_API_SERVER_TOKEN is a shared, global-access token used internally by
the Comwit Cloud console (apps/web) and by operators. It bypasses scope and
membership checks, so it is powerful and is not issued to CLI or API end
users.
When the console makes a change on a user’s behalf using this internal token, it
adds an X-Comwit-Actor-User-Id header so that audit logs and console writes are
attributed to the real user. Direct cwt_ callers never send that header — the
API uses the user id from the introspected token itself.
Scopes
Section titled “Scopes”A cwt_ token carries one or more scopes. Each scope grants a specific class of
action:
| Scope | Grants |
|---|---|
project:read | List projects you can access |
database:read | List/inspect project databases |
database:write | Create databases |
app:read | List/inspect apps, builds, env, domains |
app:write | Create/delete apps, set env, attach hostnames |
app:deploy | Deploy builds, roll back |
domain:read | List/inspect project domains and DNS records |
domain:write | Onboard domains, manage DNS records |
domain:purchase | Registrar purchase |
Operator-only routes
Section titled “Operator-only routes”Some routes are reserved for operators and the console. A cwt_ user token is
rejected with 403 on:
/v1/status- the non-project
/v1/databases*family - hidden legacy aliases
These routes require the internal operator token, not a user PAT.
Getting a cwt_ token
Section titled “Getting a cwt_ token”You can obtain a cwt_ token two ways: through CLI device login (recommended)
or by creating a personal access token in the console.
Option A — CLI device login (recommended)
Section titled “Option A — CLI device login (recommended)”If you have the comwit CLI installed, run:
comwit loginThis starts the device flow:
- The CLI calls
POST /v1/auth/deviceand receives auser_codeand averification_uri. - The CLI opens your browser to that URL. While signed in to the console, you approve the displayed code.
- The CLI polls
POST /v1/auth/device/tokenuntil it receives yourcwt_token.
The token is saved to ~/.config/comwit/config.json. To pin a default project at
the same time:
comwit login --project <projectId>Option B — dashboard personal access token
Section titled “Option B — dashboard personal access token”You can also create a scoped cwt_ token directly in the console at /tokens.
Once you have it, hand it to the CLI:
comwit login --token cwt_xxx --project <projectId>CLI config and resolution order
Section titled “CLI config and resolution order”The CLI resolves your token, project, and API host in a fixed order. Knowing this order makes it easy to override settings per command or per environment.
- Token / config file — read from
~/.config/comwit/config.json, which holds{ "token", "default_project" }. Override the path with theCOMWIT_CONFIGenvironment variable; otherwise it falls back to$XDG_CONFIG_HOME/comwit/config.json. - Project — the
--projectflag wins, then theCOMWIT_PROJECTenvironment variable, thendefault_projectfrom the config file. - API host — defaults to
https://api.cloud.comwit.io.
Using a token with raw HTTP
Section titled “Using a token with raw HTTP”The CLI is convenient, but you can call the API directly with any HTTP client.
Send your cwt_ token in the Authorization header:
curl -H "Authorization: Bearer cwt_xxx" \ https://api.cloud.comwit.io/v1/projectsWhat rejection looks like
Section titled “What rejection looks like”A request that asks for an action outside your token’s scopes, or that targets a
project you are not a member of, is rejected with HTTP 403. The operator-only
routes listed above also return 403 for cwt_ tokens.
For the full error shape and how to retry safely, see Errors & idempotency.
Next steps
Section titled “Next steps”- API overview — base URL, versioning, and request basics.
- Install the CLI — get the
comwitbinary. - Errors & idempotency — status codes and retries.