Create session token
/session-token
A session token is a short-lived, tenant-scoped credential your backend mints for one of your customers and hands to their browser. It is what Truto's embedded connections widget runs on: the widget keeps the token in memory only and calls Truto directly with it, so your end users never hold an API key and your backend never has to proxy Truto traffic.
A session token is the lowest-trust credential this API issues. It is confined to a fixed allowlist of nine routes — GET /environment-integration (the catalog), GET /integrated-account (that tenant's connections), GET /link-ui/{id} (widget configuration and branding), POST /link-token (connect and reauth), POST /integrated-account/refresh-credentials, POST /integrated-account/form-token (reopen a post-connect form), DELETE /integrated-account/{id}, POST /session-token/renew and GET /session-token/me — and on every one of them the tenant and environment filters are forced from the token itself, never from anything the browser sends. Every other route answers 403.
Who may mint one
An API token or a signed-in dashboard user session. A session token cannot mint another one — that call is refused with 403.
API-token callers may omit environment_id; it defaults to the single environment the API token is scoped to. User-session callers must send it, because a user can reach several environments and there is no safe default.
Lifetime
expires_in is how long this token lives before it stops authenticating; max_lifetime is the wall no amount of renewing can move. The effective TTL is min(expires_in, max_lifetime), so a max_lifetime smaller than expires_in shortens the first window rather than being ignored. Use POST /session-token/renew to slide the token forward, and DELETE /session-token as a kill switch.
Narrowing the origins
allowed_origins is recorded on the session and reflected in allowed_origins_count, but it is not enforced: the widget can be framed by any origin in the environment's Connections widget settings, whatever the session declares. Requested origins the environment does not already allow are dropped silently. Omit the field entirely to inherit the environment's list.
Request Body
Recorded on the session and reflected in allowed_origins_count. It is not enforced: the widget can be framed by any origin in the environment's Connections widget settings. Entries the environment doesn't allow are dropped. Omit to inherit the environment's list.
["https://app.acme.com"]Create the tenant when it does not exist yet, instead of failing with 404. Useful for first-run customers whose tenant row has not materialized.
falseThe environment the tenant belongs to. Required for user-session auth. Defaults to the API token's own environment for API-token auth.
8a2b104d-74a6-47f2-b93e-c6b611e82391Seconds until the token expires. Clamped to max_lifetime when that is smaller.
900Whether POST /session-token/renew may slide this token forward. A non-refreshable session must be re-minted instead.
trueSeconds from issue until the absolute ceiling on this session. Renewal can never extend past it.
43200The tenant this session is scoped to. The tenant must already exist in the environment unless create_tenant_if_missing is true. Free-form up to 255 characters, excluding control characters, leading or trailing whitespace, and the dot segments . and ...
acme-1Response Body
When this token stops authenticating unless it is renewed.
2026-07-28T11:45:00.000ZThe absolute ceiling. No renewal can carry the session past this.
2026-07-28T23:30:00.000ZThe session token. Send it in the Authorization header as a bearer token.
1ba1f401-7183-47c5-9e39-e8e257e3c795Errors
| Status | Description |
|---|---|
400 | Missing or malformed body, a tenant_id outside the allowed pattern, an out-of-range expires_in / max_lifetime, or user-session auth without environment_id. |
401 | No credential, or an expired one. |
403 | The caller is not an API token or user session (a session token cannot mint another), or does not have access to the requested environment. |
404 | No such tenant in that environment, and create_tenant_if_missing was not set. |
curl -X POST 'https://api.truto.one/session-token' \
-H 'Authorization: Bearer <your_api_token>' \
-H 'Content-Type: application/json' \
-d '{
"tenant_id": "acme-1",
"environment_id": "8a2b104d-74a6-47f2-b93e-c6b611e82391",
"expires_in": 900,
"is_refreshable": true,
"max_lifetime": 43200,
"allowed_origins": [
"https://app.acme.com"
],
"create_tenant_if_missing": false
}'const body = {
"tenant_id": "acme-1",
"environment_id": "8a2b104d-74a6-47f2-b93e-c6b611e82391",
"expires_in": 900,
"is_refreshable": true,
"max_lifetime": 43200,
"allowed_origins": [
"https://app.acme.com"
],
"create_tenant_if_missing": false
};
const response = await fetch('https://api.truto.one/session-token', {
method: 'POST',
headers: {
'Authorization': 'Bearer <your_api_token>',
'Content-Type': 'application/json',
},
body: JSON.stringify(body),
});
const data = await response.json();
console.log(data);import requests
url = "https://api.truto.one/session-token"
headers = {
"Authorization": "Bearer <your_api_token>",
"Content-Type": "application/json",
}
params = {
}
payload = {
"tenant_id": "acme-1",
"environment_id": "8a2b104d-74a6-47f2-b93e-c6b611e82391",
"expires_in": 900,
"is_refreshable": True,
"max_lifetime": 43200,
"allowed_origins": [
"https://app.acme.com"
],
"create_tenant_if_missing": False
}
response = requests.post(url, headers=headers, params=params, json=payload)
print(response.json())