Clokeep Clokeep Docs
Documentation API Reference
DevelopersCreate and manage API tokens
Developers View as Markdown

Create and manage API tokens

Choose what a token may do and how long it lasts, keep it safe, replace it, and know when it stops working.

An API token, which some tools call an API key, lets a script call the Clokeep API as you. The click-by-click steps to create one are in the API introduction. This page covers the choices you make and how to look after a token once you have it.

Prerequisites

  • The Admin role in the client the script works on. Only an Admin can create tokens. API Tokens, under Access in the sidebar, is also shown to an Operator or Viewer who still holds tokens there from when they were an Admin.

Choose what the token may do

When you click Create token, you decide three things.

  • Token name: name it after the script or the machine that uses it, such as CI pipeline. With one token per script, you can revoke one without stopping the others.
  • Abilities: tick Read for a script that only reads, such as a report or a monitor. Tick Write for a script that runs backups, queues restores or changes records. A token without Write gets 403 on every call that changes something.
  • Expiration: the token stops working after 1 hour, 5 hours, 24 hours, 1 month or 6 months, or with Does not expire only when you revoke it. The default is 1 month. Pick the shortest time that fits the job.

Store the token

The token appears once, in the API token created dialog. Clokeep cannot show it again. If you lose it, revoke it and create a new one.

Put the token where your script reads its secrets, such as an environment variable or your CI's secret settings. Keep it out of code repositories and logs. Anyone who has the token can call the API as you, with your role, until the token expires or you revoke it.

The API Tokens page lists your tokens with their Abilities, Last used at, Created at and Expires at. It never shows a token's value.

The API Tokens page with one token named Deploy script, with the read ability, its last use, creation and expiry times, and a Revoke action

The API Tokens page. Last used at shows when a token last made a call.

Replace a token

You can have several tokens at once, so you can replace one without a gap.

Create the new token

Create a token with the same abilities as the old one, and give it a name you can tell apart, such as CI pipeline 2.

Switch the script over

Put the new token where the script reads it.

Check that the old token is idle

On API Tokens, the new token's Last used at shows a time after the script's next run. The old token's Last used at stops changing.

Revoke the old token

Click Revoke next to the old token and confirm with Revoke token.

An expired token stays on the list until you revoke it.

Revoke a token

Click Revoke next to the token and confirm with Revoke token. A Token revoked message appears. The token's next call gets 401.

The page lists only the tokens you created in the client you are in. You cannot see or revoke another user's tokens there. An Admin revokes them on the user's page instead: see Revoke a user's API tokens.

When a token stops working

A token belongs to you and to the client you created it in. Clokeep checks both on every request.

  • Another client. A token works only in the client it was created in. For a script that works on two clients, create a token in each.
  • Your role changes. The token keeps working within the new role. A Viewer's token can still read, but every change gets 403 with Your role does not permit this action. A Customer's token gets that answer on every call. As an Operator or Viewer, you can still open API Tokens to see and revoke your tokens, but only an Admin can create new ones. See Users and roles.
  • Your account is disabled. Every call gets 403 with This account is disabled. The tokens are kept, and work again when the account is enabled again.
  • You are removed from the client. Your tokens for that client are deleted. Their next call gets 401.
  • The token expires or is revoked. Every call gets 401. An Admin of the client can revoke your tokens too.

Next steps

Esc
↑↓to navigate↵to openEscto close