Tenant tokens
POST /v1/orgs/{orgId}/tenants/{tenantId}/token, and what a Tenant token can call.
A Tenant token acts as one Tenant. Your backend exchanges its Organisation Key for one, then calls /v1/agents/* with it. Sessions, machines and events are the Tenant's, and the Organisation pays.
Exchange
curl -s -X POST "$SAI_API_URL/v1/orgs/$ORG_ID/tenants/$TENANT_ID/token" \
-H "Authorization: Bearer $SAI_ORG_KEY"No body.
{
"token": "eyJhbGciOiJSUzI1NiIs...",
"expiresAt": 1790003600000,
"tenantId": "Xk2p9QzR4tLm8vNa3bCd"
}The token lasts one hour. expiresAt is Unix time in milliseconds. There is no refresh token: exchange again before it expires. Reuse a token for its hour rather than exchanging for every request.
The caller is the Organisation's own key, or a signed-in owner or admin of the Organisation (the console's Playground does this).
Use it
Send the token in Authorization, like an API key:
curl -s "$SAI_API_URL/v1/agents/message" \
-H "Authorization: Bearer $TENANT_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "message": "Open the calendar and read today’s appointments" }'GET /v1/agents/auth shows who the token acts as:
{
"ok": true,
"userId": "Xk2p9QzR4tLm8vNa3bCd",
"authType": "firebase",
"tenantId": "Xk2p9QzR4tLm8vNa3bCd",
"orgId": "org_3f9a1c0b7e2d4a6f8c10"
}What a Tenant token can call
GET /v1/agents/machines lists the Tenant's enrolled machines. Pass one as machineId on /message.
Every other route answers 403:
{ "error": "not_available_for_tenant", "message": "This route is not available for a Tenant." }That includes turns, learn, judge, uploads, direct control, the account and keys, and /v1/orgs and /v1/tenants. A Tenant token cannot create or wake a cloud computer.
When a token stops working
A token is checked on every request, not only at the exchange:
A revoked key or a removed member stops its tokens within a minute.