Skip to main content

API keys

You can use API keys to programmatically access Tower's APIs, and in general you can access any endpoint with an API key.

How to create an API key

To create an API key, go to your team settings, then to API Keys, and click Create new API key.

Create API key Create API key second step

After giving it a name, and clicking Create, you'll see your new key in the table.

Newly created API key

How to use an API key

You can use the API key by adding it to the X-API-Key header of any Tower API request. Note that all Tower API keys are prefixed with sk-.

Example

curl 'https://api.tower.dev/v1/apps' \
-H 'X-API-Key: sk-FAKE+0gUsddrrdNawuhd4NHCaSN/63YXPIG7aZ3kxjT0'

Each Tower API endpoint has a scope that your API key must have to perform the action, which is listed on the API documentation pages under the Authorization section. If your API key does not have the correct scope you'll receive a 403 Forbidden in response.

Reducing the scope of the API key

By default, API keys are created with the permissions from the account that created them; if you create an API key as an account with the Admin role, the API key will also have the Admin role.

However, in some cases you may want to create API keys with a reduced set of privileges, such as when you know the API key should only be used for specific actions. You can create a reduced permission API key using the create-api-key API, passing scopes as a parameter in the body. See Available scopes for a list of scopes you can provide, and note that you can't create an API key with more privileges than your current account.

curl 'https://api.tower.dev/v1/api-keys' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'X-API-Key: sk-FAKE+0gUsddrrdNawuhd4NHCaSN/63YXPIG7aZ3kxjT0' \
-d '{
"name": "Can only perform runs",
"scopes": "apps:run"
}'

See the Create API Key documentation for more details about how to create API keys, including about other parameters like team.

Available scopes

The following is a list of available scopes you can add to an API key.

KeyDescription
api_keysAccess to all API key operations.
api_keys:readRead access for API keys.
api_keys:createCreate access for API keys.
api_keys:deleteDelete access for API keys.
appsAccess to all apps operations.
apps:readRead access for apps.
apps:runAllows the API to run apps.
apps:deployAllows the API key to be used to deploy a new app version.
apps:createCreate access for apps.
apps:updateUpdate access for apps (e.g. renaming app).
apps:deleteDelete access for apps.
catalogsAccess to all Tower catalog operations.
catalogs:readRead access for catalogs.
catalogs:createCreate access for catalogs.
catalogs:updateUpdate access for catalogs.
catalogs:deleteDelete access for catalogs.
catalogs:exportExport access for catalogs.
envsAccess to all environment operations.
envs:createCreate access for environments.
envs:readRead access for environments.
envs:updateUpdate access for environments.
notificationsAccess to all notification operations.
notifications:readRead access for notifications.
notifications:deleteDelete access for notifications.
runsAccess to all run operations.
runs:readRead access for runs.
runs:cancelAllows for canceling an active run.
runs:logsRead access for run logs, including the stream of logs.
runnersAccess to all self-hosted runner operations.
runners:readRead access to runners.
runners:credentials:createAllows for creating credentials for self-hosted runners.
sandboxAccess to all Tower sandbox operations.
sandbox:secrets:createAllows for creating a new secret in a sandbox.
schedulesAccess to all schedules operations.
schedules:createCreate access for schedules.
schedules:readRead access for schedules.
schedules:updateUpdate access for schedules.
schedules:deleteDelete access for schedules.
secretsAccess to all secrets operations.
secrets:readRead access for secrets.
secrets:createCreate access for secrets.
secrets:updateUpdate access for secrets.
secrets:deleteDelete access for secrets.
teamsAccess to all team operations.
teams:createCreate access for teams.
teams:readRead access for teams.
teams:updateUpdate access for teams.
teams:deleteDelete access for teams.
webhooksAccess to all webhooks operations.
webhooks:readRead access for webhooks.
webhooks:createCreate access for webhooks.
webhooks:updateUpdate access for webhooks.
webhooks:deleteDelete access for webhooks.