Article · 2 min read · Security and privacy
kubespin: API tokens
An API token lets a script, CI job or test use kubespin’s API as you.
An API token lets a script, CI job or test use kubespin’s API as you.
Make one
- Go to Settings › API tokens.
- Give it a Name, such as “smoke tests”.
- Choose what it Can do: Read only, or Read and change.
- Choose when it Expires: in 7 days, 30 days, 90 days or a year.
- Make a token.
The token is shown once. Copy it now.
Use it
Send it in the Authorization header. Tokens start kat_.
curl -H "Authorization: Bearer $KUBESPIN_TOKEN" https://kubespin.io/api/v1/servers
What a token can’t do
- Anything that asks you to confirm it’s you: sign-in changes, revealing secrets, deleting your account.
- Make other tokens.
Keeping track
The list shows each token’s name, its first characters, what it can do, when it was last used and when it expires. Revoke stops it at once.
In a team, the team’s tokens are covered by the API and push tokens permission. See kubespin: Set up a team.
Good practice
- One token per job, named after it, so you can revoke one without breaking the others.
- Read only unless the job changes things.
- The shortest expiry that suits.
- Keep it in your CI’s secret store, never in a repository.
From the command line
kubespin login --token kat_…, or KUBESPIN_TOKEN in the environment, uses a token with the kubespin command. For your own use at a terminal, kubespin login signs in through your browser instead. See kubespin: The command line and CLI sessions.