Skip to main content

Overview

The Thrust API uses JWT tokens or API Key for authentication. Most endpoints require a valid JWT token passed as a Bearer token in the Authorization header.

Getting a JWT Token

To authenticate with the Thrust API, you need to:
  1. Create an thrust identity or log in through the Thrust application at onthrust.com
  2. However your username in top right corner at onthrust.com and click the API Key to copy it.
  3. Include the API key in all API requests as Bearer API_KEY

Authentication Flow

Using the API Key

Include your JWT token in the Authorization header of every API request:

Using the Token

Include your JWT token in the Authorization header of every API request:

Header Format

Token Claims

The JWT token contains the following claims:

Authentication Examples

Token Lifecycle

Token Expiration

JWT tokens expire after a set period. When a token expires:
  1. The API returns a 401 Unauthorized error
  2. Error message: "Invalid or expired authentication token"
  3. Your application should refresh the token or prompt re-authentication

Handling Expired Tokens

Optional Authentication

Some endpoints support optional authentication:
  • /get-tokens - Returns public token data, with user-specific vote data if authenticated
  • /get-posts - Shows public posts, with user votes if authenticated
  • /get-topics - Returns topics, with user-specific data if authenticated
For these endpoints, you can make requests without a token, but you’ll receive limited data.

Security Best Practices

Never expose your JWT tokens in client-side code, public repositories, or logs.
  1. Store tokens securely
    • Use secure storage (localStorage with encryption, or httpOnly cookies)
    • Never commit tokens to version control
  2. Implement token refresh
    • Refresh tokens before they expire
    • Handle token expiration gracefully
  3. Use HTTPS only
    • Always use HTTPS for API requests
    • Tokens sent over HTTP can be intercepted
  4. Validate on the server
    • The API validates all tokens server-side
    • Never trust client-side validation alone

Common Authentication Errors

Testing Authentication

Use the /get-notifications endpoint to test your authentication:
If authentication is successful, you’ll receive your notifications. Otherwise, you’ll get a 401 error.

Next Steps

Quickstart

Make your first authenticated API call

API Reference

Explore available endpoints