Generate tokens

Create a SUPERWISE client ID and secret, then exchange them for a bearer token to call the REST API, the SDK, or the Sentinel CLI

Generate a SUPERWISE® client ID and secret key in your account settings, under Personal tokens or API tokens, then exchange them for a bearer token with one POST request. The bearer token authenticates every REST API call. The Python SDK and the Sentinel CLI take the client ID and secret directly and handle the exchange for you.

API token types: personal token and API token (admin)

Go to your account settings (by clicking on your name in the bottom left corner of the home screen). There, you can find two types of API tokens:

  1. Personal tokens, which are associated with your account directly. If a user is deleted, the token will be deleted as well.
  2. API tokens, for machine-to-machine communication (available only for admin users).

Generate a client ID and secret key

Step 1: Go to your account settings (by clicking on your name in the bottom left corner of the home screen).
Step 2: Click on Personal Tokens or API Tokens (according to the type of token you wish to generate and utilize).
Step 3: Click on Generate Token.
Step 4: Enter a token description - so it will be clear for everyone else, at any time, what this token is used for.
Step 5: Copy the Client ID and Secret Key and implement it where it is needed.

❗️

Warning

Never share your secret key in public repositories

📘

Note

Viewing both codes won't be available after step 5; Only copying will be available.

Superwise Personal Access Tokens page showing token details and option to generate a new token.

Exchange the client ID and secret for a bearer token

This is a client credentials exchange: send the client ID and secret to the SUPERWISE authentication endpoint, and it returns an access token.

curl -s -X POST https://authentication.superwise.ai/identity/resources/auth/v1/api-token \
  -H "Content-Type: application/json" \
  -d '{"clientId": "<CLIENT_ID>", "secret": "<SECRET_KEY>"}'

The response is JSON, and the token is in its accessToken field. Send it as a bearer token in the Authorization header of each API call. For example, to list your Sentinels:

TOKEN="<ACCESS_TOKEN>"
curl -s https://api.superwise.ai/v1/sentinels \
  -H "Authorization: Bearer $TOKEN"

The token is a JWT and is valid for 24 hours. When it expires, run the exchange again. The REST API page covers the main objects and calls, and the API reference documents the exchange itself.

Use the credentials without the exchange

  • Sentinel CLI. Run sentinel auth --client-credentials and paste the client ID and secret. See Install on macOS and Linux (CLI).
  • Python SDK. Set SUPERWISE_CLIENT_ID and SUPERWISE_CLIENT_SECRET, or pass client_id and client_secret to SuperwiseClient. The SDK requests and refreshes bearer tokens itself. See SDK.

Get Sentinel: Create a free SUPERWISE® account, then generate your first token.

See also


Did this page help you?