Docs · Torii
API reference
Every route the Torii API serves today, the permission each one needs, and what it answers when something is wrong. The API is the same one the console uses behind the scenes.
The basics
- Address. The API is served under
/v1on the same address as the console. On the hosted service that ishttps://torii.minatolabs.com/v1. There is one version,v1. - Authentication. Every route under
/v1, except the source-request form, needs an API token sent asAuthorization: Bearer. A browser session cookie is not accepted. API tokens explains how to get one. - Your organisation only. A token belongs to one organisation, and every route answers inside it. No route takes an organisation id, and something in another organisation answers exactly like something that does not exist.
- JSON, in snake case. Request bodies must be sent with
Content-Type: application/json. Lists come back as an object with anitemsarray. - Everything is audited. Reads, writes and refusals are written to your organisation's audit log.
curl -sS "$TORII_CONTROL_PLANE_URL/v1/organisation" \ -H "Authorization: Bearer $TORII_API_TOKEN"
For how API access works across minatolabs products, see API and MCP access.
Permissions and roles
Each route below names the permission it needs. A refused request answers 403 with that name in required. These are the roles that hold each one:
| Permission | Roles that hold it |
|---|---|
| AssetsRead | All five roles |
| AssetsWrite | Owner, admin, security |
| AssetsDelete | Owner, admin |
| FindingsRead | All five roles |
| PolicyRead | All five roles |
| PolicyWrite | Owner, admin, security |
| TokensCreate | Owner, admin, security, developer |
| TokensRevoke | Owner, admin, security |
| TokensReadAll | Owner, admin |
| AuditRead | Owner, admin, security |
The full role table, including permissions no route uses yet, is in Organisations and roles.
Organisation and audit
| Route | Permission | What it does |
|---|---|---|
GET /v1/organisation | AssetsRead | Your organisation: id, name, slug, plan, the repository, host and seat limits, retention in days, and when it was created. |
GET /v1/audit-events | AuditRead | Your audit log, newest first. limit is 100 by default, from 1 to 1000. |
GET /v1/health | AuditRead | Whether the service is up, for operators. |
Assets
Six collections share one shape: list, read one by id, and delete one by id. Ids are UUIDs.
| Collection | List and read | Delete |
|---|---|---|
/v1/repositories | AssetsRead | AssetsDelete |
/v1/hosts | AssetsRead | AssetsDelete |
/v1/cloud-accounts | AssetsRead | AssetsDelete |
/v1/domains | AssetsRead | AssetsDelete |
/v1/hostnames | AssetsRead | AssetsDelete |
/v1/workspaces | AssetsRead | AssetsDelete |
A list is GET on the collection, one item is GET on the collection followed by / and the id, and removal is DELETE on the same address. A delete answers 204; an id that is not visible to you answers 404.
Tokens and enrolment
| Route | Permission | What it does |
|---|---|---|
GET /v1/api-tokens | TokensReadAll | Every API token in your organisation, without values. Also one by id. |
POST /v1/api-tokens | TokensCreate | Create an API token: name, role, expires_in_days. The value is returned once. |
POST /v1/api-tokens/{id}/revoke | TokensRevoke | Revoke an API token. 204, or 404 if it is already revoked. |
POST /v1/agent-enrolment-tokens | TokensCreate | Create an enrolment token: label, ttl_minutes, max_uses. The value is returned once. |
POST /v1/agent-enrolment-tokens/{id}/revoke | TokensRevoke | Revoke an enrolment token. 204, or 404. |
POST /v1/agent-enrolment/redeem | AssetsWrite | Redeem an enrolment token: token, hostname, operating_system. Adds the host. |
There is no route that lists enrolment tokens. Enrolling a host has the fields and limits.
Agent packages
| Route | Permission | What it does |
|---|---|---|
GET /v1/agent-packages | AssetsRead | The latest package for each operating system and processor: release_id, operating_system, arch, version, package_sha256 and the download path. |
GET /v1/agent-packages/{release_id}/download | AssetsRead | The package itself. Its SHA-256 is also in the X-Torii-Package-Sha256 header. |
GET /v1/agent-packages/{release_id}/source | AssetsRead | The corresponding source code for that release. Its SHA-256 is in X-Torii-Source-Sha256. |
Each download is recorded in your audit log. Where no package archive is set up, the list answers with an empty items and archive_configured set to false. If the archive fails its own integrity checks, these routes answer 503 with agent_packages_unavailable rather than serve anything.
Sources
| Route | Permission | What it does |
|---|---|---|
GET /v1/source/installations | AssetsRead | Your code-host installations. |
GET /v1/source/installations/{id}/repositories | AssetsRead | Which repositories are selected for an installation, and which could be. |
POST /v1/source/installations/{id}/repositories/select | AssetsWrite | Select a repository: repository_id and full_name. Queues its first scan. |
POST /v1/source/installations/{id}/repositories/deselect | AssetsWrite | Stop scanning a repository: repository_id. |
No live GitHub connection can be made on the hosted service yet; see Adding assets.
Cloud accounts and domains
| Route | Permission | What it does |
|---|---|---|
POST /v1/cloud-accounts | AssetsWrite | Record a connection: provider (aws, azure, gcp or oci), account_ref, role_reference, and directory_ref where the provider asks for one. Returns the external id once. 409 if it is already connected. |
POST /v1/cloud-accounts/{id}/external-id/rotate | AssetsWrite | Issue a new external id. The connection goes back to pending trust. |
GET /v1/cloud-accounts/{id}/schedule | PolicyRead | The account's scan schedule. |
PUT /v1/cloud-accounts/{id}/schedule | PolicyWrite | Set schedule to weekly, daily or off. A missing or unknown value is refused. |
POST /v1/domains | AssetsWrite | Claim a domain: domain. Returns the TXT record to publish. 409 if already claimed. |
POST /v1/domains/{id}/verify | AssetsWrite | Asks for verification. Today it always answers unverified. |
Policy and findings
| Route | Permission | What it does |
|---|---|---|
GET /v1/settings/secret-verification | PolicyRead | Whether secret verification is on, with the full disclosure text and the list of destinations. |
PUT /v1/settings/secret-verification | PolicyWrite | Turn it on or off: enabled, true or false. A missing value is refused, never read as on. |
GET /v1/findings-store/summary | FindingsRead | A count of your findings and the ids Torii uses for you in its findings store. |
Routes without a token
| Route | What it does |
|---|---|
GET /healthz | Answers {"status":"ok"} and nothing else. |
GET /readyz | Whether the service is ready to serve, with no detail. |
POST /v1/source-requests | The form behind the public source-request page. It is meant to be used through that page. |
/auth/… | Signing in and out of the console. These are for the browser, not for scripts. |
Errors and limits
Every error is a small JSON object with an error field. No error ever carries a stack trace or internal detail; an unexpected failure gives only a trace id that minatolabs can look up.
{"error":"unauthorized"}
{"error":"forbidden","required":"AssetsDelete"}
{"error":"not_found"}
{"error":"invalid_body"}
{"error":"payload_too_large"}
{"error":"rate_limited"}
{"error":"internal_error","trace_id":"<id>"}| Status | Meaning |
|---|---|
400 | The body is missing, malformed, or not JSON. |
401 | No token, or a token that is malformed, expired, revoked or from another organisation. Always the same body. |
403 | Your token's role lacks the permission in required. |
404 | Not found in your organisation, whether or not it exists elsewhere. |
409 | Already exists, for example a cloud account or domain connected twice. |
413 | The body is larger than 1 MiB. |
429 | Too many requests. Retry-After says to wait 60 seconds. |
500 | Something failed inside the service. The body carries a trace id. |
Rate limits
By default the service allows 600 requests a minute per organisation, 300 a minute per IP address, and 10 sign-in requests a minute per IP address. On the hosted service the per-address limits are shared by every caller for now, so a 429 can come from other people's traffic.
What the API cannot do yet
- List or read findings. There is no findings route beyond the summary, so neither the API nor the console can show a finding.
- Dismiss a finding, start a scan, or read scan history.
- Export findings as CSV, JSON or SARIF.
- Manage members: invite someone, change a role or remove a person.
- Add a hostname, or verify a domain for real.