Learn how to authenticate with the Stratify API using JWT tokens, manage API keys, and implement secure authentication flows.
Base URL: http://localhost:8000/api/v1 (development)
Production URL: https://api.stratify.app/v1
Stratify API uses JWT (JSON Web Tokens) for authentication:
Short-lived token (15 minutes) for API requests. Include in Authorization header.
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...Long-lived token (7 days) to obtain new access tokens without re-logging in.
/api/v1/auth/registerCreate a new user account.
Request Body:
{
"email": "user@example.com",
"password": "SecurePass123!",
"full_name": "John Doe"
}Response (201 Created):
{
"success": true,
"data": {
"user_id": "123e4567-e89b-12d3-a456-426614174000",
"email": "user@example.com",
"verification_required": true
},
"message": "Registration successful. Check email for verification."
}/api/v1/auth/loginAuthenticate user and receive tokens.
Request Body:
{
"email": "user@example.com",
"password": "SecurePass123!"
}Response (200 OK):
{
"success": true,
"data": {
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"token_type": "bearer",
"expires_in": 900
}
}/api/v1/auth/refreshGet new access token using refresh token.
Request Body:
{
"refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}Response (200 OK):
{
"success": true,
"data": {
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"expires_in": 900
}
}Include the access token in the Authorization header for all API requests:
Example Request:
curl -X GET "http://localhost:8000/api/v1/watchlists" \ -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \ -H "Content-Type: application/json"
Never expose tokens in client-side code. Use secure HTTP-only cookies or encrypted storage.
Implement automatic refresh logic. When you receive 401 Unauthorized, use refresh token to get new access token.
Always use HTTPS (not HTTP) in production to encrypt tokens in transit.
| Code | Status | Meaning |
|---|---|---|
| INVALID_CREDENTIALS | 401 | Wrong email/password |
| TOKEN_EXPIRED | 401 | Access token expired, refresh needed |
| EMAIL_NOT_VERIFIED | 403 | User must verify email first |
| ACCOUNT_DISABLED | 403 | Account suspended or banned |
| EMAIL_EXISTS | 409 | Email already registered |