Authentication
Every call to the zkao API uses an API token. There are two kinds.
A project token belongs to exactly one project. It carries a set of scopes and can be narrowed further to some repositories, an expiry date, and a spend limit.
An organization token reaches every project of one organization, including projects created later. See Organization tokens.
There are two ways to get either kind: approve the CLI in your browser, or create a token by hand.
Browser approval
Section titled “Browser approval”zkao loginThe CLI starts a device authorization flow:
- It prints a URL and a short code, and opens the URL in your browser.
- On the Authorize a CLI page, you confirm that the code matches the one in your terminal.
- You pick a project, review the requested scopes, and approve. You can also set a repository allowlist, an expiry, and a spend limit there.
- The CLI receives the token and saves it to
~/.zkao/config.json.
Only approve a login you started yourself. Approving mints a real token for the project you select.
By default the CLI requests read, scans:launch, findings:write, and guidance:write.
The approval page pre-ticks them, and the approver can change them.
To request other scopes, pass --scope:
zkao login --scope read publishzkao login --project <projectId> preselects a project on the approval page.
You can approve several projects in one login. Each gets its own saved token, and the first becomes the active project.
Use --no-browser to print the URL without opening a browser.
A whole organization
Section titled “A whole organization”zkao login --org # or: zkao login --org <slug or id>--org asks for one organization token instead of a token per project.
The approval page then offers the whole organization, and a slug or id preselects it.
Only an owner or admin of the organization can approve it.
--org also requests projects:write and repositories:write, on top of the default scopes.
When the approver picks the organization, the CLI prints:
Authorized for every project of organization "<name>" (<id>).The token is saved next to your project tokens. None of them is replaced. Then pick a project to work on:
zkao projects list # the organization's projectszkao config use <projectId> # make one activeOr pass --project <projectId> to a single command.
The approver can still pick single projects instead. The CLI then saves project tokens as usual.
Agents and CI
Section titled “Agents and CI”A bare zkao login blocks until someone approves in the browser.
That can take minutes and trip a command timeout.
Non-interactive callers split it in two:
zkao login --no-wait --no-browser # prints the URL and code, then exits# a person opens the URL and approveszkao login --resume # polls once and exitsRepeat zkao login --resume until it prints Authorized.
Still waiting for approval means nobody has approved yet.
--resume --timeout <seconds> waits up to that long instead of polling once.
Several logins can be pending at once. --resume finishes whichever is approved first and keeps the rest.
A pending login expires 15 minutes after it starts. Both commands print the time it expires.
Tell the person approving, since an expired URL and code stop working.
Start a new login when --resume reports that it expired.
Tokens created by hand
Section titled “Tokens created by hand”A project admin can create a token under Project Settings → Integrations in the zkao app. Choose a name, the scopes, and optionally a repository allowlist, an expiry, and a spend limit.
The token is shown once, together with the project id. It looks like this:
zkao_proj_<keyId>_<secret>Store it as a secret. zkao cannot show it again.
Hand it to the CLI or SDK through environment variables:
export ZKAO_API_TOKEN=zkao_proj_...export ZKAO_PROJECT_ID=<projectId>Or save it to the config file:
zkao config set --token zkao_proj_... --project <projectId>Scopes
Section titled “Scopes”A token carries a subset of these scopes:
| Scope | Allows |
|---|---|
read |
List and read repositories, scans, findings, presets, and billing. |
findings:write |
Comment on findings, change severity and resolution, override the triage verdict, pin a note. |
guidance:write |
Update a repository’s guidance, manage its audit areas, and answer questions from Continuous Security analyses. |
scans:launch |
Launch and cancel scans. |
regression-tests:write |
Generate regression tests and create or retry their pull requests. |
publish |
Publish a finding or a scan as a public page. |
advisories:write |
Record which versions a security advisory affects. |
contacts:read |
Read the advisory contact list. |
contacts:write |
Add an advisory contact. |
automations:write |
Select Continuous Security analyses, configure schedules and budgets, and prepare a branch’s next analysis. |
Only an organization token can carry these two:
| Scope | Allows |
|---|---|
projects:write |
Create and rename projects. |
repositories:write |
Connect repositories and move them between projects. |
A call that needs a scope the token lacks returns 403 forbidden.
The two contact scopes are held apart from the others. That list is who learns
about a vulnerability before the public does, so neither read nor
advisories:write reaches it.
Organization tokens
Section titled “Organization tokens”An organization token looks like this:
zkao_org_<keyId>_<secret>An owner or admin of the organization approves one with zkao login --org.
- It works on every
/projects/{projectId}/...route, for every project of its organization. Send it the same way as a project token. - It reaches projects created after the token was.
- It has no repository allowlist.
- A project of another organization returns
404. - Its spend limit and its request limit each count across the whole organization.
It can also call the /organizations/{organizationId}/... routes, which a project token cannot:
| Action | CLI | Scope |
|---|---|---|
| List the organization’s projects | zkao projects list |
read |
| Create a project | zkao projects create <name> |
projects:write |
| Rename a project | zkao projects rename <projectId> <name> |
projects:write |
| Connect a GitHub repository to a project | zkao repos add <owner/name> |
repositories:write |
| Move a repository to another project | zkao repos move <repositoryId> --to <projectId> |
repositories:write |
A project token that calls one of these routes gets 403.
Connecting a repository runs the same checks as the dashboard. A private repository needs the zkao GitHub App installed for it. The member who created the token needs access to it on GitHub, with a verified GitHub account.
No token can manage members, create tokens, archive or delete projects, or buy credits. Do those in the app.
With the SDK or plain HTTP, pass the organization token as the token and the project’s id as the project id:
export ZKAO_API_TOKEN=zkao_org_...export ZKAO_PROJECT_ID=<projectId>Limits on a token
Section titled “Limits on a token”- Repository allowlist. The token only sees the listed repositories. An empty list means every repository in the project.
- Expiry. The token stops working after this date.
- Spend limit. The most credits the token may commit to scans, triage resumptions, and regression tests in the current billing period. A request past the limit returns
429.
Regression test requests require a token whose creator remains a project admin with verified GitHub write access.
The GitHub App must have Contents and Pull requests write permissions for that repository.
The default CLI login does not request regression-tests:write.
Grant it explicitly when you want to create test pull requests.
zkao whoami (or GET /token) returns the token’s kind, project, organization, scopes, allowlist, expiry, and spend limit.
For an organization token, kind is organization and project is null.
Any valid token can call it, whatever its scopes.
Errors
Section titled “Errors”| Status | Meaning |
|---|---|
401 unauthorized |
The token is missing, malformed, expired, or revoked. The response does not say which. |
403 forbidden |
The token is valid but lacks the scope this call needs. Also a project token on an organization route. |
404 not_found |
The resource is outside the token’s project or repository allowlist. zkao does not confirm that it exists. |
A token used against another project’s id gets a 404 whose message names the token’s own project.
Send the token only in the Authorization: Bearer header.
A token passed in the query string is rejected with 400.
Where the CLI stores credentials
Section titled “Where the CLI stores credentials”The CLI writes ~/.zkao/config.json with owner-only permissions.
It keeps one token per project, so logging in to a second project does not drop the first.
It keeps organization tokens next to them, one per organization.
An organization login never replaces a project token.
zkao config show # active settings, saved projects and organizations (tokens masked)zkao config use <projectId> # switch the active projectzkao config use-org <org> # switch the active organization, by id or slugzkao config use <projectId> also works for a project with no token of its own, when an organization token is saved.
Settings resolve in this order, highest first:
- Flags:
--token,--project,--base-url. - Environment:
ZKAO_API_TOKEN,ZKAO_PROJECT_ID,ZKAO_URL. - The saved config file.
From the config file, the CLI picks the token for the project in use like this:
- The token saved for that project.
- Otherwise the token of the active organization, with that organization’s base URL.
So a project’s own token always wins for that project. The organization commands always use the organization token.
Revoking a token
Section titled “Revoking a token”Revoke a project token under Project Settings → Integrations. Revoke an organization token in the organization’s settings. It stops working at once. A token also stops working when its project or organization is archived.
