Docs
Live demo
POST/api/v2/api-tokens/organization
Signed-in sessionConsole session only

Issue a token that acts on behalf of the organization for automation and integrations. Needs tokens:manage. The token holds a built-in role (admin or viewer) or a custom role or both. Together they cannot hold a permission the caller does not have. The issuing member becomes its responsible member: on every request the token gets the permissions of its roles that this member still has, and it stops working while this member is not an organization member or has none of them, until another member with tokens:manage takes it over. The secret is in the response once.

Request body application/json · APITokenCreateRequest

Required3 of 10 fields
namestringrequired

Name that tells what the token is for.

max length 100
rolestringrequired

Built-in role the token is issued with. The permissions of the role and of custom_role must be permissions of the caller. An organization token needs admin, viewer or a custom role.

adminvieweruser
expires_atstring · date-timerequired

When the token expires: at least one hour ahead and at most the longest lifetime of the organization policy (GET /api-tokens/policy. 90 days by default, 7 days for a token with allow_security_changes, 30 days with allow_installation_admin, never more than 366 days). A later date within ten minutes of the limit is lowered to it. A later one answers 400.

Optional7 fields
custom_role_idstring · uuid

Custom role the token holds on top of its built-in role.

can be null
allowed_networksarray of string

IP addresses or networks (CIDR, IPv4 /16 or narrower, IPv6 /32 or narrower) the token is accepted from. A request from any other address answers 401 auth.api_token_invalid with details.reason=network without naming the networks. Empty accepts every network unless the organization policy requires networks for new tokens (then 400). A replaced secret keeps the networks of the token.

max items 30
allow_security_changesboolean

Lets the token make the security changes that the console confirms with a second factor: the organization security policy, required two-factor authentication, trusted networks, and members' passwords, password reset links, external sign-in, email, two-factor reset and unlock. Only a token whose roles hold security:manage can have it. Omitted means false.

allow_installation_adminboolean

Lets a personal token administer the installation within its owner's installation rights: health, maintenance mode, the audit of every organization, the upgrade preflight and the operations of the installation. Only an installation administrator can issue it, and the token stays valid for at most 30 days. The token keeps the installation rights its owner held at issuance and never more. Omitted means false.

allow_token_managementboolean

Lets the token list, issue, replace, take over and revoke API tokens. A token it issues holds no permission or right this token lacks, expires no later than this token and is revoked with it. It replaces secrets and takes over tokens only within itself and the tokens it issued. Omitted means false.

allow_credentials_readboolean

Lets the token call GET /identities/{id}/credentials for the credentials its owner may view: their own, and with the admin role those of any member. The right stands in for the second factor the console asks for, so every read is recorded and counted toward the hourly limit. It is given only at issuance, after the second-factor confirmation of the creator. A token issued with another token gets it only when that token has it. Without it the token answers 403 auth.api_token_not_allowed (details.reason=api_token_credentials_read_not_allowed). Omitted means false.

agentboolean

Marks a personal token as the connection of an AI agent through POST /mcp: the console lists such tokens under AI agents, and a new secret keeps the mark. The mark gives no right, and without allow_credentials_read the token gets no SSH certificate from POST /ssh/certificates. An organization token with the mark answers 400. Omitted means false.

Responses

201

Created: the token and its secret, shown once

APITokenIssuedResponse · 2 fields
tokenAPITokenResponserequired
30 fields
idstring · uuidrequired
kindstringrequired
personalorganization
namestringrequired
rolestringrequired

Built-in role the token was issued with. It never grows.

adminvieweruser
custom_roleOrgCustomRoleRefrequired

Custom role the token holds on top of its built-in role.

can be null
2 fields
idstring · uuidrequired
namestringrequired
effective_rolestringrequired

The widest built-in role whose permissions the token has now. Null when it does not authenticate.

adminvieweruser
can be null
effective_permissionsarray of string (OrgPermission)required

What the token may do now: the permissions of its roles that the member behind the token also has. Empty when it does not authenticate.

access:applyaccess:manageaccess:readapplications:manageapplications:readaudit:readdrift:managedrift:readidentities:manageidentities:readjobs:managejobs:readmembers:managemembers:readnotifications:managenotifications:readorganization:readsecurity:managesecurity:readtargets:managetargets:readtokens:managetokens:read
statusstringrequired

active works with all permissions of its roles. Limited works with fewer because the bound member has fewer permissions now. Inactive does not work because the bound member is not a member any more (member_missing) or, for an organization token, the responsible administrator lost read access (member_without_access).

activelimitedinactiveexpiredrevoked
status_reasonstringrequired

Why a token is limited, inactive, expired or revoked. On an expired token, member_missing or member_without_access says a new secret would be inactive too, and policy_cap says the longest lifetime of the organization policy, applied to existing tokens, ended it. unused on a revoked token says the periodic check disabled it because it was not used within the days the policy allows. Such a token can't come back, create a new one.

role_loweredmember_missingmember_without_accessrevokedrotatedunusedpolicy_cap
can be null
token_hintstringrequired

Prefix and last characters of the secret, to recognize the token.

bound_memberAPITokenMemberRefrequired
2 fields
idstring · uuidrequired

Identity ID. Null when the identity was deleted.

can be null
labelstringrequired
created_byAPITokenMemberRefrequired
2 fields
idstring · uuidrequired

Identity ID. Null when the identity was deleted.

can be null
labelstringrequired
created_atstring · date-timerequired
expires_atstring · date-timerequired

When the token expires by its own terms, as issued.

policy_expires_atstring · date-timerequired

When the longest lifetime of the organization policy would end the token (created_at plus the limit for this token), present only when the lifetime exceeds the policy. The token stops at this moment only while the policy applies the limit to existing tokens (cap_existing). Otherwise it is informational.

can be null
lifetime_over_policybooleanrequired

The lifetime of the token exceeds the longest lifetime of the organization policy.

allow_security_changesbooleanrequired

The token may make the security changes that the console confirms with a second factor. Set when the token is issued and kept when its secret is replaced.

allow_installation_adminbooleanrequired

The personal token may administer the installation within the installation rights its owner held at issuance. Set when the token is issued and kept when its secret is replaced.

allow_token_managementbooleanrequired

The token may list, issue, replace, take over and revoke API tokens within its own permissions and rights. Set when the token is issued and kept when its secret is replaced.

allow_credentials_readbooleanrequired

The token may call GET /identities/{id}/credentials within its owner's rights. Set when the token is issued and kept when its secret is replaced.

agentbooleanrequired

The token connects an AI agent through POST /mcp. Set when the token is issued and kept when its secret is replaced. It gives no right, and without allow_credentials_read the token gets no SSH certificate.

agent_keystring · uuidrequired

For an agent token, the key that names the connection in the agent's client. It stays the same when the secret is replaced. Null for every other token.

can be null
agent_connected_atstring · date-timerequired

For an agent token, the first moment the MCP server at POST /mcp answered it successfully. Null until then and for every other token. A request that only carried the secret, without a successful MCP answer, does not set it. A new secret starts with null.

can be null
allowed_networksarray of stringrequired

Networks (CIDR) the token is accepted from. Empty means every network.

issued_by_token_idstring · uuidrequired

API token that issued this token or replaced its secret. Revoking that token revokes this one too. Null when a person issued it in the console.

can be null
last_used_atstring · date-timerequired

When the token last made a request, recorded at most once a minute.

can be null
last_used_ipstringrequired

Client address of the last recorded use, as the backend saw it: the address the trusted proxies forwarded, or the direct peer when no trusted proxy is configured.

can be null
revoked_atstring · date-timerequired
can be null
revoked_byAPITokenMemberRefrequired
can be null
2 fields
idstring · uuidrequired

Identity ID. Null when the identity was deleted.

can be null
labelstringrequired
replaced_by_idstring · uuidrequired

The token that replaced this one when its secret was rotated.

can be null
secretstringrequired

The token secret. Shown only in this response. Principal keeps only its SHA-256 digest.

400

Bad Request: missing name, unknown role or expiry out of range

401

Unauthorized: no console session or API token

403

Forbidden: the caller lacks the permission of the operation, the token's roles hold a permission the caller does not have (code api_token.role_exceeds_caller), the second factor was not confirmed recently (details.reason=mfa_reauth_required), or the request was made with an API token issued without allow_token_management (code auth.api_token_not_allowed, details.reason=api_token_management_not_allowed). A token issued with an API token holds no permission or right that token lacks, expires no later than it and is revoked with it. Through a token, secrets are replaced and tokens taken over only within that token and the tokens it issued. A replaced secret never expires later than the token that replaced it or the token that issued it.

409

Conflict: the limit of valid tokens is reached (code api_token.limit_reached)

Common errors: 413 429 503 504. They mean the same for every operation, see Errors.

↑ ↓ to moveEnter to openEsc to close