Docs · Torii
Enrolling a host
Enrolment binds one machine to one organisation. The console gives you a single-use token and one command; run the command on the host and it downloads the agent, checks it, installs it and enrols the machine.
Before you start
- A role that may create tokens, to generate the enrolment token: owner, admin, security or developer.
- An API token with the owner, admin or security role, for the host to download the agent and redeem the enrolment token. Redeeming adds an asset, and those are the roles that may. Create one under Settings, API tokens with the Security role; API tokens shows how. If Security is not offered to you, ask an owner, admin or security member of your organisation.
- A terminal on the host with
curl, and the right to runsudo. The installer must run as root.
1. Generate an enrolment token
- In the console, open Settings, find the Hosts card and choose Add host. The dialog is titled Add a host.
- Under 1. Operating system, choose Linux or macOS. Choosing Windows shows Windows enrolment is not available yet and no button.
- Choose Generate enrolment token. The token appears under Copy this token now — it is shown once, with the time it expires.
Torii keeps only the token's SHA-256 hash, so there is no way to show it again; if you lose it, generate another. A token made in the console works for one host and expires after one hour. Closing the dialog, or switching to another operating system, clears the token from the dialog. The token itself stays valid until it expires or is used, and the console has no list of enrolment tokens to revoke it from, so generate one only when you are ready to run the command.
If your role cannot create tokens, the dialog answers Could not mint a token. followed by the reason.
Creating an enrolment token with the API
You can also create one through the API, which lets you choose how long it lives and how many hosts it may enrol:
curl -sS -X POST "$TORII_CONTROL_PLANE_URL/v1/agent-enrolment-tokens" \
-H "Authorization: Bearer $TORII_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{"label": "web-01", "ttl_minutes": 60, "max_uses": 1}'| Field | Default | Limits |
|---|---|---|
label | Required | A short name for the token, so you can recognise it later. It must start with a letter or digit and may contain letters, digits, spaces, dots and hyphens, up to 64 characters. |
ttl_minutes | 60 | From 1 minute to 24 hours. |
max_uses | 1 | Up to 100, for enrolling a batch of machines. |
A ttl_minutes or max_uses outside the limits is adjusted to the nearest allowed value, not refused, and the response states what you actually got. A label that breaks the rule is refused with 400 and invalid_label. Enrolment tokens start with toriienr_, which makes them easy to tell apart from API tokens. Keep the id from the response: it is the only way to revoke the token later.
2. Install and enrol, on the host
Below the token, the dialog shows 2. Install and enrol, on the host and one block of shell commands with the token already in it. For Linux it has this shape; the console fills in the real release names and SHA-256 values, and the macOS version checks the download with shasum -a 256 and reports macos:
(
set -e
TORII_CONTROL_PLANE_URL=https://torii.minatolabs.com
TORII_HOSTNAME=
TORII_API_TOKEN=
case "$(uname -m)" in
x86_64|amd64) TORII_RELEASE=<release for amd64> TORII_SHA=<its SHA-256> ;;
arm64|aarch64) TORII_RELEASE=<release for arm64> TORII_SHA=<its SHA-256> ;;
*) echo "No Torii agent package for this CPU ($(uname -m)) yet."; exit 1 ;;
esac
curl -fsS -H "Authorization: Bearer ${TORII_API_TOKEN:?set TORII_API_TOKEN first}" \
-o "$TORII_RELEASE.tar.gz" "$TORII_CONTROL_PLANE_URL/v1/agent-packages/$TORII_RELEASE/download"
echo "$TORII_SHA $TORII_RELEASE.tar.gz" | sha256sum -c -
tar -xzf "$TORII_RELEASE.tar.gz"
sudo "./$TORII_RELEASE/install.sh"
curl -sS -X POST "$TORII_CONTROL_PLANE_URL/v1/agent-enrolment/redeem" \
-H "Authorization: Bearer ${TORII_API_TOKEN:?set TORII_API_TOKEN first}" \
-H "Content-Type: application/json" \
-d "{\"token\":\"<enrolment token>\",\"hostname\":\"${TORII_HOSTNAME:?set TORII_HOSTNAME to the name this host should have in Torii}\",\"operating_system\":\"linux\"}"
)- Choose Copy above the block and paste it into a text editor.
- Fill in the two empty values.
TORII_HOSTNAMEis the name this host should have in Torii, for exampleweb-01.TORII_API_TOKENis the API token from Before you start. - Paste the whole block into a terminal on the host and press Enter.
sudoasks for the host's password when it reaches the install.
The block runs in order and stops at the first step that fails:
- It picks the package for the host's processor, or stops with
No Torii agent package for this CPU. - It downloads the package from Torii with your API token.
- It checks the download against the SHA-256 Torii published. A mismatch stops the block: nothing is installed and nothing is enrolled.
- It unpacks the package and runs its installer with
sudo. The host agent describes what the installer does and when it refuses. - It redeems the enrolment token, which binds the machine to your organisation and makes the host appear under Runtime.
TORII_CONTROL_PLANE_URL is the console's own address and is filled in. If a value is left empty, the command stops and says which one, and nothing is sent. The block contains no comment lines, so it pastes cleanly into zsh, the default shell on macOS.
If it worked, the last reply includes the host's name and an id. If it says enrolment_refused, the token was already used, has expired, or belongs to another organisation: generate a new one.
Set the hostname yourself
Torii identifies a host by its name within your organisation. Two enrolments that report the same name are treated as one host, and the later agent replaces the earlier one. That is the right outcome when you reinstall a machine and the wrong one for two different machines.
So the command does not read the name from whatever shell runs it. TORII_HOSTNAME is an explicit variable, and the command stops with an error if it is empty. Set it to the name of the machine you installed the agent on, especially if you run the command from somewhere else.
Use letters, digits, dots and hyphens only, starting and ending with a letter or digit. A name with any other character, such as an underscore, is not stored: the enrolment still succeeds, but the host does not appear in your host list.
What a refusal looks like
If the enrolment token is not accepted, the answer is a 401 with the same body in every case: unknown token, expired, revoked, already used up, or issued to a different organisation. Torii does not say which, because the difference would tell a stranger whether a token or an organisation exists.
| Status | Meaning |
|---|---|
400 | The request body is missing or malformed. This says nothing about the token. |
401 | The API token or the enrolment token was not accepted. |
403 | The API token is valid and its role may not add assets. |
Enrolling with the API alone
A script that installs the agent another way can redeem the token by itself. This is the last step of the console's block:
curl -sS -X POST "$TORII_CONTROL_PLANE_URL/v1/agent-enrolment/redeem" \
-H "Authorization: Bearer $TORII_API_TOKEN" \
-H "Content-Type: application/json" \
-d "{\"token\":\"<enrolment token>\",\"hostname\":\"web-01\",\"operating_system\":\"linux\"}"Check that it worked
The host appears in Settings under Hosts and in the Runtime view, marked Not reporting. The two planes explains the four statuses. From the API:
curl -sS "$TORII_CONTROL_PLANE_URL/v1/hosts" \ -H "Authorization: Bearer $TORII_API_TOKEN"
Each host carries its name, operating system, an agent id that Torii assigned, when it was enrolled and when it was last seen. You never choose the agent id: Torii generates it during enrolment. The last seen time stays empty today, because nothing records a report from an agent yet.
Revoking an enrolment token
If a token is exposed before it is used, revoke it. This needs the owner, admin or security role and the token's id, which only the API response gives you:
curl -sS -X POST "$TORII_CONTROL_PLANE_URL/v1/agent-enrolment-tokens/$ID/revoke" \ -H "Authorization: Bearer $TORII_API_TOKEN"
A token made in the console cannot be revoked by you, because the console does not show its id. It expires one hour after it was made, and it works only once.
Creating, redeeming and revoking are all written to the audit log. The token value itself never is.