Thrust Carbon

Authentication

Authenticate requests with Bearer tokens, and create, expire, and refresh API keys.

We use HTTP header authentication using Bearer tokens. To create your API key, login to the Thrust Calculator, head to Account (top right corner) > Organisation settings > API Keys > Add API Key.

To authorize your request, set the Authorization header to Bearer {your-api-key}.

For example, if your API key was weiuh8b9hw, then your Authorization header would look like Authorization: Bearer weiuh8b9hw.

Please visit this page to learn more about Bearer authorization: https://swagger.io/docs/specification/authentication/bearer-authentication/

Expiring API keys

When creating an API key for the first time through the website, you have the option of setting an expiry time. After this expiry time, the API key will no longer be able to access the API.

We recommend always setting an expiry for API keys and regularly refreshing them to ensure only authorised use of the API occurs.

When creating an expiring API key, you will be given both the API key for accessing the API and a refresh token, which can be used to create a new API key with the same properties as this key.

Make sure to securely store both the API key and refresh token - you can only view them once.

Refreshing API keys

If you need to continue accessing the API after your API key has expired, a request can be sent to the /api/2/token/refresh endpoint for creating a new API key with the same properties.

Two approaches to refreshing API keys can be taken and are discussed below.

Refreshing on expiry

Another approach to refreshing API keys is to refresh the API key after it has expired. When an API key has expired, the API will respond with a status code of 401. At this point the client knows that the API key has expired and it should request a new one. After a new key has been generated, you can retry the failed request.

This approach also handles scenarios where the API key has been revoked or otherwise declared invalid.

Refreshing before expiry

One approach to refreshing API keys is for the client to monitor when its API key will expire. When the API key is close to expiring, the client can request a new API key from the API.

On this page