Authentication Flow
This document explains how authentication works in ThreatWinds.
Authentication Methods
ThreatWinds supports two primary authentication methods:
| Authentication Method | Description |
|---|---|
| Bearer Token Authentication | Using an Authorization header with a bearer token |
| API Key Authentication | Using API key and API secret headers |
Authentication Flow
Bearer Token Authentication
- User Login:
- The client sends the session request to the Auth API
- The Auth API creates a session, returning a Bearer token and verification ID, and sends a verification code through email
- The client calls
PUT /session/verificationwith theverificationCodeIDand thecodeto validate the session
- Authenticated Request:
- The client includes the bearer token in the
Authorizationheader of subsequent requests - The platform validates the token and checks if the user has the required roles for the requested resource
- If authorized, the request is processed normally
- The client includes the bearer token in the
API Key Authentication
- API Key Creation (user-created):
- The client creates an API key and secret through the Auth API
- The Auth API returns the key, secret, and verification ID, and sends an email with the verification code
- The client verifies the creation of the key through the Auth API
- API Key Creation (admin-created):
- An admin creates a user with
POST /admin/user. The API key pair is pre-verified —verifiedistruein the response and no verification code is sent. - The key is immediately usable.
- An admin creates a user with
- Authenticated Request:
- The client includes the API key and secret in the request headers (
api-keyandapi-secret) - The platform validates the key and secret and checks if the API key has the required roles for the requested resource
- If authorized, the request is processed normally
- The client includes the API key and secret in the request headers (
Partner User Creation
A partner can create end-users on behalf of their customers via POST /partners/user. Partner-created users are automatically marked as verified — they bypass identity verification entirely. No verification code is sent. The response shape and notify flag behave the same as admin user creation; only the "user" role is allowed.
See Partner for details.
Identity Verification
After registration, users can optionally verify their identity. The verification process is progressive:
- User initiates verification —
POST /api/auth/v2/verifycreates a verification session and returns aclientSecretand a hostedurl. - Document & selfie capture — The frontend either renders the verification modal using the
clientSecret, or redirects the user to the hosted verificationurl. The user uploads a government-issued ID and completes a live selfie. - Compliance screening — When the identity check is approved, the backend records the result and triggers an automated compliance screen against PEP and sanctions databases.
- Verification outcome:
- Screening clears — The user is marked as verified.
- Screening flags a hit — The verification attempt is recorded as failed, the attempt counter increments, and the user remains unverified. They may retry if attempts remain.
Users can check progress at any time via GET /api/auth/v2/verify/status.
For full details, see Identity Verification.
Session Management
When using bearer token authentication:
| Aspect | Description |
|---|---|
| Session Lifetime | Sessions have a limited lifetime |
| Refresh Responsibility | The client is responsible for refreshing the session before it expires |
| Management Endpoints | The Auth API provides endpoints for session management (create, refresh, validate, revoke) |
Best Practices
| Application Type | Recommended Authentication | Security Practices |
|---|---|---|
| Web Applications | Bearer token authentication | • Store the token securely (for example, in an HTTP-only cookie) • Implement token refresh logic |
| Server-to-Server Communication | API key authentication | • Store the API key and secret securely |
| Mobile Applications | Bearer token authentication | • Store the token securely in the device’s secure storage • Implement token refresh logic |
Related Documentation
| Documentation | Description |
|---|---|
| Email Authentication | Managing email addresses for authentication |
| Identity Verification | Verifying user identity through document and selfie |
| Session Management | Creating and managing user sessions |
| Key Pair Management | Creating and managing API keys |
| User Management | Creating and managing user accounts |
Error Response Headers
For responses with status codes other than 200 and 202, the following headers are included:
| Header | Description |
|---|---|
| x-error | Human-readable error message describing what went wrong |
| x-error-id | Unique identifier for error tracking and support |
Error Codes
| Status Code | Description | Possible Cause |
|---|---|---|
| 400 | Bad Request | Invalid request parameters or malformed JSON |
| 401 | Unauthorized | Missing or invalid authentication credentials |
| 403 | Forbidden | Authenticated user lacks permission for this operation |
| 404 | Not Found | The requested resource does not exist |
| 500 | Internal Server Error | Server-side error; please contact support if persistent |