Skip to main content
A service token is an API credential that belongs to your organisation. It authenticates as a service account - a principal Ankra owns, carrying a role you chose - rather than as the person who created it. That difference matters the day someone leaves. A personal API token is tied to its owner’s membership, so removing them from the organisation stops every token they minted. If one of those was deploying your production cluster, the pipeline fails with a 401 and nothing in the deploy log explains why.
Personal API tokens still exist and are still the right choice for your own scripting and CLI use. Service tokens are for anything that runs without a person behind it: CI/CD, Terraform, agents, integrations.

Personal token or service token?


Create one

1

Open API and automation

Go to Identity & access → API and automation (/next/organisation/automation) and click Create token in the Service tokens section. The page requires the members.manage permission, so it is visible to owners and admins; anyone else reads “Your role cannot see service tokens”. That covers reading the list too - knowing which standing credentials exist, and what each one can do, is administrator-only.
2

Name the service account

In Create a service token, choose A new one under Service account and fill in Service account name, or choose One the organisation already has. Name it after the thing that will use it - ci-deploy, terraform, backup-runner - not after yourself. The name is how you will recognise it in the audit log a year from now. Label names this one token.
3

Pick its role

Pick the Role. The token carries this role and nothing else. Pick the narrowest one that does the job: a pipeline that deploys stacks does not need to manage members or read billing. See Roles & Access for what each built-in role holds.You can only grant a role whose permissions you already hold yourself. A token is usable the moment it is created, so this stops “can manage members” from quietly becoming “can escalate to owner”.
4

Pick what it is for

Under What can it do?, choose Full API access (the REST API, the CLI, Terraform and integrations), Editor tools: read and change or Editor tools: read only (the MCP server only). See REST or MCP - pick one.
5

Pick its project

The Project list offers the organisation’s projects and defaults to the one you are working in. The token is pinned to the project you choose: it reads and writes there and nowhere else, and the list of service tokens says which project each one acts in. A token for a pipeline that deploys one team’s clusters belongs in that team’s project.
6

Pick how long it lasts

Expires after offers 30 days, 90 days (the default) and 1 year. The field shows the date it stops working, and Needs you shows the token two weeks before that date.
7

Copy the token

Click Create token. The dialog becomes Copy the token now: “This is the only time Ankra shows it.” Put it straight into the consuming system’s secret store - GitHub Actions secrets, GitLab CI variables, your Terraform backend - then click Done. The token is listed under Service tokens with its project, and reads Never used until its first call.

Use it

A service token authenticates exactly like a personal one:
These behaviours differ from a personal token, all deliberate:
  • It cannot switch organisations. The X-Ankra-Organisation-Id header (what ankra --org uses) is refused. A service account belongs to one organisation and there is nowhere else for it to go, so “this credential reaches this organisation and no other” is something you can rely on.
  • It cannot use the personal account surface. /org/account/* - profile, MFA, personal tokens - is refused, so a service token can never mint further credentials for itself outside the page administrators watch.
  • It cannot use the portal’s read routes. A GET under /api/v1 that has no /api/v1 route of its own is served from the portal’s route only to a personal token with no scopes and no project pin, so a service token gets 403 there. See Base URL.
  • A pinned token cannot leave its project. A service token created with a project is pinned to it: X-Ankra-Project-Id naming another project and project_id=all on a cost or Security Center route are refused, as are the organisation’s compliance documents (framework scores, the compliance report, evidence deliveries) and organisation-wide routes such as the organisation’s settings, billing changes and the audit log (403 Pinned tokens cannot act outside their project), and a token whose project is deleted stops authenticating with 403 The project this token is pinned to no longer exists, until you mint one in the project that replaced it. Service tokens created before projects were released carry no pin: they act in the project X-Ankra-Project-Id names and otherwise in the Default project, and they reach whatever their role reaches across the organisation. Rotate one into a pinned token when you want the project boundary.

Rotate without downtime

Rotating means overlapping the old credential and the new one, never a gap.
1

Make a replacement

In the token’s menu, choose Make a replacement…. The new token goes to the existing service account rather than to a new one. Both tokens work, both carry the same role, and the account keeps one continuous audit history across the rotation.
2

Update the consuming system

Replace the secret in your CI, Terraform, or integration, and let it run once to confirm the new token works.
3

Revoke the old token

The dialog reminds you: “Once <name> is swapped out where it is used, revoke it.” Choose Revoke… in the old token’s menu and confirm with Revoke token. Revoking stops that one credential immediately and leaves the account’s other tokens untouched.
The same lifecycle runs from the terminal. ankra tokens create <account> --service --role <role> mints a token for a service account (a name the organisation already has adds a token to that account, and --role must then be the role it holds), ankra tokens list --service lists the organisation’s service tokens with the account and role of each, and ankra tokens rotate <token_id> --service renews one, keeping the old token working for an overlap you set with --overlap-hours (24 hours by default). Listing and minting need the members.manage permission.

Revoke and delete

Revoke stops a token working, immediately. Do this the moment you suspect a credential has leaked - it takes effect within the authentication cache window and does not wait for the token’s expiry. In the portal both are in the token’s menu: Revoke… (confirm with Revoke token) and, once it is revoked or expired, Remove from the list… (confirm with Remove token). A revoked token stays listed so you can see when it stopped. Delete removes an already-revoked token from the list. A token must be revoked before it can be deleted, so a credential can never disappear from the page while still working somewhere. Both work from the terminal too: ankra tokens revoke <token_id> --service and ankra tokens delete <token_id> --service act on the organisation’s service tokens, and ankra tokens list --service shows the ids. Both need the members.manage permission and exit 7 without it. Without --service the same commands look only among your personal tokens, so a service token’s id is refused as unknown and the error says to add the flag.
Deleting an account’s last token also stands the service account down: it keeps its history, so past actions stay attributable, but it loses its role. A token minted under that name later starts from nothing and needs its role granted again deliberately. The account itself stays a member of the organisation: when ankra tokens delete <token_id> --service removed the account’s last token it prints the ankra org remove <account_id> that removes the account, and ankra tokens list --service -o json carries each token’s account_id.

REST or MCP - pick one

Creating a token asks what it is for, and the two answers are mutually exclusive:
  • Full API access - the default. Works with the REST API, the ankra CLI, Terraform, and integrations.
  • Editor tools: read and change or Editor tools: read only - the MCP server only, for agents such as Cursor or Claude Code. Read only carries mcp:read; read and change adds mcp:write for the mutating tools (apply, scale, delete).
An MCP token reaches the hosted MCP server and nothing else. The REST API, the CLI, Terraform and every integration will refuse it - an agent’s credential must not double as a general-purpose API key.The refusal is an HTTP 403, and clients commonly report that as a bad credential. So if an integration says your token was not accepted and the token is new and unexpired, check you did not create it as an MCP token: mint a REST one instead.

GitHub Actions without a stored token

A GitHub Actions workflow can sign in to Ankra with its own GitHub identity instead of a token kept in a GitHub secret. You trust one repository, and a job from it receives a token that lasts minutes and carries the role you chose.
Go to Identity & access → Sign-in and security, find GitHub Actions sign-in and click Add trust policy. Fill in Policy name, GitHub owner, Repository, Owner ID and Repository ID, and narrow it with Allowed branch or tag, GitHub environment and Reusable workflow ref. Pick the Ankra role (Viewer, Member, Operator or Admin) and the Token lifetime (minutes), then click Add trust policy. The policy is listed; a policy with no branch or tag reads Unrestricted ref. Open Use this in your GitHub workflow for the lines to paste. Setting up trust policies needs an organisation administrator.
In the workflow, allow GitHub to issue an identity token and sign in after installing the Ankra CLI:
Pull request runs are refused unless the policy opts in (--allow-pull-request); pull_request_target runs never are. On a persistent runner, finish with ankra logout --local-only. Run the workflow once successfully before you delete the old token secret.

What is recorded

Every mint, revoke, and delete is written to the audit log with the administrator who did it, the service account, and the role involved. Actions the token itself takes are attributed to its service account, not to whoever created it - which is the point: a year later the log says ci-deploy restarted that workload, not a colleague who has since left.

Roles & Access

What each role can do, and how scopes narrow it.

API reference

Authenticating and calling the REST API.

Audit log

Reviewing who did what, including token lifecycle events.

CI/CD

Wiring a pipeline that deploys through Ankra.