Skip to content
Using the API10c9466 · docs: authentication

Authentication

Make an API key, send it with every request, and see what a key can and can't do.

Every request to the API carries an API key as a bearer token:

Shell
curl -sS "https://api.cubecen.com/v1/users/me" \
  -H "Authorization: Bearer $CUBECEN_API_KEY"

GET /v1/users/me answers with the person the key acts as, so it is a quick way to check that a key works. A request with no key, or with a key that is unknown, expired or revoked, is refused with 401.

Make a key

Keys are made in the dashboard, under Settings → API keys. A key has:

  • Name. Up to 64 characters. It shows on the builds and deployments the key starts, so don't put a secret in it.
  • Access. Full can call every endpoint a key may use, within what its owner's role allows. Read-only can call only the endpoints marked read, such as listing and getting. Each endpoint in the reference says which it needs.
  • Expiry. 30, 90 or 365 days, or never. The default is 90 days.

The key's value starts with cbc_. It is shown once, when you make the key, and Cubecen keeps only a hash of it: a lost key can't be shown again. Make a new one instead and revoke the old one.

Treat a key like a password. Store it as a secret in your CI, never in your repository, and never in code that runs in a browser: a browser page can't call the API with a key anyway.

Every plan has API keys, Free included. A person can have up to 20 active keys in an organization.

What a key is

A key is personal. It belongs to the person who made it, and it works in one organization.

  • It acts as its owner, with the owner's role in that organization as it is now. A key never has more rights than its owner. If the owner's role loses a permission, the key gets 403 FORBIDDEN for what it can no longer do. A viewer can make Read-only keys only.
  • It works in one organization. Paths take that organization's slug or ID. Any other organization is refused with 403.
  • It stops when its owner leaves. When the owner is removed from the organization, their keys stop working. Signing out of the dashboard doesn't affect them.
  • It expires. At its expiry date it stops working and answers 401. A key can't be renewed: make a new one before it runs out.

Releases that a key starts say so. A build or deployment started with a key has trigger set to api, and api_key holds the key's id and name. A revoked key keeps its name on the releases it made.

To stop a key, revoke it on the same page. It stops working at its next request.

What a key can't do

A key can call the endpoints in the reference: your organization's plan and usage, projects, cubes, builds, deployments and releases, logs and metrics, variables and secrets, custom domains, previews, and the GitHub connections and repositories you can create cubes from.

These stay in the dashboard. A key that asks for them gets 403 and the code API_KEY_NOT_ALLOWED, whatever its access:

  • Members and invitations.
  • Connecting and disconnecting GitHub. Connect it once in the dashboard; after that, a key can create cubes from the repositories you gave Cubecen access to.
  • Billing.
  • Creating, changing and deleting organizations.
  • Making, listing and revoking API keys.
  • Signing in and out.

A Read-only key that calls an endpoint that changes something gets 403 FORBIDDEN.