Torii user guide — contents

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 /v1 on the same address as the console. On the hosted service that is https://torii.minatolabs.com/v1. There is one version, v1.
  • Authentication. Every route under /v1, except the source-request form, needs an API token sent as Authorization: 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 an items array.
  • Everything is audited. Reads, writes and refusals are written to your organisation's audit log.
A first call
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:

PermissionRoles that hold it
AssetsReadAll five roles
AssetsWriteOwner, admin, security
AssetsDeleteOwner, admin
FindingsReadAll five roles
PolicyReadAll five roles
PolicyWriteOwner, admin, security
TokensCreateOwner, admin, security, developer
TokensRevokeOwner, admin, security
TokensReadAllOwner, admin
AuditReadOwner, admin, security

The full role table, including permissions no route uses yet, is in Organisations and roles.

Organisation and audit

RoutePermissionWhat it does
GET /v1/organisationAssetsReadYour organisation: id, name, slug, plan, the repository, host and seat limits, retention in days, and when it was created.
GET /v1/audit-eventsAuditReadYour audit log, newest first. limit is 100 by default, from 1 to 1000.
GET /v1/healthAuditReadWhether 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.

CollectionList and readDelete
/v1/repositoriesAssetsReadAssetsDelete
/v1/hostsAssetsReadAssetsDelete
/v1/cloud-accountsAssetsReadAssetsDelete
/v1/domainsAssetsReadAssetsDelete
/v1/hostnamesAssetsReadAssetsDelete
/v1/workspacesAssetsReadAssetsDelete

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

RoutePermissionWhat it does
GET /v1/api-tokensTokensReadAllEvery API token in your organisation, without values. Also one by id.
POST /v1/api-tokensTokensCreateCreate an API token: name, role, expires_in_days. The value is returned once.
POST /v1/api-tokens/{id}/revokeTokensRevokeRevoke an API token. 204, or 404 if it is already revoked.
POST /v1/agent-enrolment-tokensTokensCreateCreate an enrolment token: label, ttl_minutes, max_uses. The value is returned once.
POST /v1/agent-enrolment-tokens/{id}/revokeTokensRevokeRevoke an enrolment token. 204, or 404.
POST /v1/agent-enrolment/redeemAssetsWriteRedeem 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

RoutePermissionWhat it does
GET /v1/agent-packagesAssetsReadThe 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}/downloadAssetsReadThe package itself. Its SHA-256 is also in the X-Torii-Package-Sha256 header.
GET /v1/agent-packages/{release_id}/sourceAssetsReadThe 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

RoutePermissionWhat it does
GET /v1/source/installationsAssetsReadYour code-host installations.
GET /v1/source/installations/{id}/repositoriesAssetsReadWhich repositories are selected for an installation, and which could be.
POST /v1/source/installations/{id}/repositories/selectAssetsWriteSelect a repository: repository_id and full_name. Queues its first scan.
POST /v1/source/installations/{id}/repositories/deselectAssetsWriteStop scanning a repository: repository_id.

No live GitHub connection can be made on the hosted service yet; see Adding assets.

Cloud accounts and domains

RoutePermissionWhat it does
POST /v1/cloud-accountsAssetsWriteRecord 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/rotateAssetsWriteIssue a new external id. The connection goes back to pending trust.
GET /v1/cloud-accounts/{id}/schedulePolicyReadThe account's scan schedule.
PUT /v1/cloud-accounts/{id}/schedulePolicyWriteSet schedule to weekly, daily or off. A missing or unknown value is refused.
POST /v1/domainsAssetsWriteClaim a domain: domain. Returns the TXT record to publish. 409 if already claimed.
POST /v1/domains/{id}/verifyAssetsWriteAsks for verification. Today it always answers unverified.

Policy and findings

RoutePermissionWhat it does
GET /v1/settings/secret-verificationPolicyReadWhether secret verification is on, with the full disclosure text and the list of destinations.
PUT /v1/settings/secret-verificationPolicyWriteTurn it on or off: enabled, true or false. A missing value is refused, never read as on.
GET /v1/findings-store/summaryFindingsReadA count of your findings and the ids Torii uses for you in its findings store.

Routes without a token

RouteWhat it does
GET /healthzAnswers {"status":"ok"} and nothing else.
GET /readyzWhether the service is ready to serve, with no detail.
POST /v1/source-requestsThe 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 bodies
{"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>"}
StatusMeaning
400The body is missing, malformed, or not JSON.
401No token, or a token that is malformed, expired, revoked or from another organisation. Always the same body.
403Your token's role lacks the permission in required.
404Not found in your organisation, whether or not it exists elsewhere.
409Already exists, for example a cloud account or domain connected twice.
413The body is larger than 1 MiB.
429Too many requests. Retry-After says to wait 60 seconds.
500Something 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.