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:- Create an thrust identity or log in through the Thrust application at onthrust.com
- However your username in top right corner at onthrust.com and click the API Key to copy it.
- Include the API key in all API requests as Bearer API_KEY
Authentication Flow
Using the API Key
Include your JWT token in theAuthorization header of every API request:
Using the Token
Include your JWT token in theAuthorization 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:- The API returns a
401 Unauthorizederror - Error message:
"Invalid or expired authentication token" - 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
Security Best Practices
Recommended Practices
-
Store tokens securely
- Use secure storage (localStorage with encryption, or httpOnly cookies)
- Never commit tokens to version control
-
Implement token refresh
- Refresh tokens before they expire
- Handle token expiration gracefully
-
Use HTTPS only
- Always use HTTPS for API requests
- Tokens sent over HTTP can be intercepted
-
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:
401 error.
Next Steps
Quickstart
Make your first authenticated API call
API Reference
Explore available endpoints
