CTRLctrl docs

API keys

An API key lets a script, a CI job or the CLI act on your account through https://api.getctrl.dev. Keys look like ctrl_ followed by 32 hex characters.

Create a key#

  1. Open Account in the dashboard and scroll to ctrl keys.
  2. Select create api key and give it a name, 1 to 64 characters. Name it after where it will be used, such as the CI job.
  3. Copy the key straight away. CTRL stores only a hash of it, so it can't be shown again.

You can have up to 10 named keys per account. Revoke one before you create an eleventh.

To create one from the API instead:

curl -X POST https://api.getctrl.dev/v1/account/api-keys \
  -H "Authorization: Bearer $CTRL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "github-actions"}'

The response holds the key in api_key, along with its id, name, prefix and created_at. This is the only time the full key is returned.

Use a key#

Send it as a bearer token on every request:

curl https://api.getctrl.dev/v1/apps \
  -H "Authorization: Bearer $CTRL_API_KEY"

A missing, malformed or unknown key gets 401 with {"error": "invalid api key"}.

Keep keys in your CI provider's secret store or an environment variable, not in your repository.

See and revoke keys#

The ctrl keys list shows each key's name, its first characters (such as ctrl_1a2b...), when it was created and when it was last used. Last used is updated at most once a minute.

Select revoke to delete a key. It stops working on the next request.

The same from the API:

# List keys (never includes the keys themselves)
curl https://api.getctrl.dev/v1/account/api-keys \
  -H "Authorization: Bearer $CTRL_API_KEY"

# Revoke one by its id
curl -X DELETE https://api.getctrl.dev/v1/account/api-keys/<id> \
  -H "Authorization: Bearer $CTRL_API_KEY"

The legacy key#

Accounts also have one older key, under legacy api key on the same page. generate new api key replaces it, and the old one stops working immediately. Through the API this is POST /v1/account/api-key, which returns the new key in api_key.

Prefer named keys: each one can be revoked without breaking the others.

Scopes#

Keys have no scopes yet. Every key can do everything your account can, including creating and deleting apps and managing other keys. Give each place its own key so you can revoke it alone.

Rate limits#

Limits are counted per 60 seconds:

What Limit Counted per
Writes (POST, PUT, PATCH, DELETE) 120 account
Deploys: creating an app, redeploy, rollback, creating an environment 10 account
Sign-in with GitHub 20 client IP

Reads (GET) are not limited. A deploy counts against both the deploy limit and the write limit.

Over a limit, the API answers 429 with a Retry-After: 60 header:

{ "error": "too many requests, try again in a minute" }

Every key action is audited#

Creating, revoking and replacing keys appear in your account's audit log: ctrl audit at the bottom of the Account page.

See Security for how keys are stored.