Skip to main content

API Keys

An API key lets a script or another tool call the Stratos API as you, without logging in through a browser. Stratos creates the key; you copy its secret to wherever the tool keeps its credentials.

Who can create keys​

The API_KEYS_ENABLED environment variable (Helm chart value console.apiKeysEnabled) decides:

ValueWho can create and use keys
disabledNobody.
admin_only (default)Stratos administrators.
all_usersEvery user.

The user menu offers API Keys only to users who can create keys.

Creating a key​

  1. Open the user menu and choose API Keys.
  2. Click + (Create API Key) and give the key a description, such as the name of the tool that will use it. The description is only a label, so you can tell your keys apart later.
  3. Choose when the key expires: in 30, 90 (the default) or 365 days, on a date you pick, or never.
  4. Click Create. The next step shows the key's secret, hidden until you click the eye button, with a copy button beside it.
  5. Click Done.

The secret is shown once. Stratos keeps no way to show it again, so copy it before you click Done. If you lose it, delete the key and create a new one.

When a key expires​

The API Keys page lists each key's expiry in its Expires column. From a day before a key expires until a week after, the page shows a message about it with Create replacement, which opens the create dialog with the same description. Put the new secret wherever the tool keeps it, then delete the old key.

A request with an expired key is refused with 401 and the message API key expired on <date and time in UTC>. Keys created before expiry existed never expire.

The latest expiry date accepted is 19 January 2038, because some databases Stratos supports cannot store a later one. Never is not affected.

Using a key​

Send the secret in an Authentication header with the Bearer scheme. Note the header name: it is Authentication, not the more usual Authorization.

Authentication: Bearer <secret>

A key works on the API's stable routes:

RouteDoes
GET /api/v1/endpointsLists the endpoints you can see
POST /api/v1/tokensConnects an endpoint
DELETE /api/v1/tokens/<endpoint guid>Disconnects an endpoint
GET /api/v1/proxy/<endpoint guid>/<path>Sends one request to an endpoint you are connected to

Keys cannot create or delete keys; that takes a browser login.

For example, keep the header in a file only you can read, so the secret appears in no command line or shell history. Create ~/.stratos-api-key in an editor with the single line Authentication: Bearer <secret>, then:

chmod 600 ~/.stratos-api-key
curl -H @"$HOME/.stratos-api-key" https://<stratos-address>/api/v1/endpoints

Deleting a key​

The API Keys page lists your keys by description. Delete a key from its row's actions (Delete, then confirm); a tool still using it is refused, as a request without a key would be.