API Keys

v4.0.5

The API Keys page lets you create keys that external programs and scripts use to read data from the Supracontrol API - without a user logging in interactively.

Path: Settings → API keys (in the Infrastructure group)

Availability: This page is only visible when the API Keys feature is enabled on your Supracontrol deployment. If you do not see this page, contact your system administrator.
Access: Only Administrators can create API keys - a Superadmin can't. Each Administrator sees and revokes only their own keys.

Changes in version 4.0.5

  • Keys created before version 4.0.5 no longer work. Create new ones.
  • The old APIKEY header no longer works. Use Authorization: Bearer instead - see Using an API key.

What is an API key?

An API key gives a program read-only access to the Supracontrol API on behalf of the Administrator who created it.

API keys are useful for:

Who can create keys

Create an API key

1

Open the API Keys section

Go to Settings → API keys.

2

Open the creation dialog

Click Create (the + button) in the toolbar. If you have no keys yet, you can also click Create API key in the middle of the page.

3

Fill in the key details

FieldRequiredDescription
NameYesA descriptive label for this key (e.g. "Dashboard Integration", "Backup Script"). The name must be unique among your active keys
Expires afterYesHow long the key stays valid: 30, 90, 180 or 365 days. The default is 90 days. There are no keys that never expire
4

Save and copy the key

Click Save. The full key value is displayed - copy it now and put it straight into a safe place, such as a password manager or the secret settings of the program that will use it.

The dialog can't be closed until you tick I have copied the key. Then click Done.

Note: The Copy button doesn't work when Supracontrol is opened over plain http (without https). In that case, select the key in the box and copy it by hand.

The key is shown once

The full key value can't be shown again after you close the dialog. If the key is lost, create a new one.

Using an API key

Send the key in the Authorization header of every request, with the Bearer prefix. Keys start with sc_.

Terminal window
curl -H "Authorization: Bearer sc_XXXXXXXX" https://<api-address>/api/Location

Replace sc_XXXXXXXX with your key and <api-address> with the address of your Supracontrol Web API. That address can differ from the one you use to open Supracontrol in the browser, for example by using a different port. Ask your system administrator if you are not sure.

To keep the key out of the command itself, store it in an environment variable first. Adding -i prints the status code together with the response:

Terminal window
export SC_API_KEY="sc_XXXXXXXX"
curl -i -H "Authorization: Bearer $SC_API_KEY" https://<api-address>/api/Location

A valid key returns 200 and the list of locations as JSON.

RequestResult
Any read (GET)Allowed
A search sent as POST (e.g. POST api/Log/GetLogs)Allowed
Anything that changes dataRefused with 403 "API keys are read-only."
A read that returns secrets (e.g. camera passwords)Refused with 403 "API keys can't use this endpoint."
A request with an invalid, expired or revoked keyRefused with 401 "Invalid API key."
A request without the Authorization headerRefused with 401 "Missing authentication token."

A refused request returns the message in the response body. For a request that changes data:

{ "Errors": ["lngError0#API keys are read-only."] }

For an invalid, expired or revoked key:

{ "Errors": ["lngError0#Invalid API key."] }

Which endpoints a key can call

The API reference marks every endpoint that a key can call: its description ends with "API keys: allowed (read-only)." and it offers the Bearer option. No other endpoint does.

The API reference (API Explorer) is served by your own Supracontrol server and asks you to sign in:

https://<your-server>:8082/login.html

Replace <your-server> with the address of your Supracontrol server. The port can differ on your deployment - ask your system administrator if the page does not open.

Key list

The table lists your own keys.

ColumnDescription
StatusWhether the key is active, expired or revoked
NameThe display name given to this key
KeyThe short form of the key (e.g. sc_…a1b2). The full value is never shown here
Created onThe date and time this key was created
ExpiresThe date and time this key stops working
Last usedThe last time a request was made with this key, accurate to within a few minutes. Shows "Never" until the key is first used

The list opens filtered to Active keys. To see expired and revoked keys, clear the filter in the Status column header. They are shown greyed out.

The toolbar has these tools, plus a search bar:

ToolDescription
CreateOpens the dialog to create a new key
RevokeRevokes the selected key
RefreshReloads the list
Column settingsChooses which columns are shown

Revoke an API key

When a key is no longer needed or may have leaked, revoke it:

1

Select the key row

Click the key row you want to revoke.

2

Revoke and confirm

Click Revoke in the toolbar, then click Revoke in the confirmation dialog.

An expired key can be revoked too.

Revoking is immediate and can't be undone

Any program using the revoked key loses API access at once.

Rotate a key

To replace a key without interrupting the program that uses it:

  1. Create a new key.
  2. Switch the program to the new key.
  3. Revoke the old key.

When a key stops working by itself

A key also stops working when:

Security

Treat an API key like a password

  • Never put a key in source code or share it in chat.
  • Revoke a key at once if it may have leaked.
  • Supracontrol stores only a fingerprint (hash) of the key, so nobody can recover it - not even Supracontrol support.