Documentation Index
Fetch the complete documentation index at: https://mintlify.com/LavenderEdit/Portfolio/llms.txt
Use this file to discover all available pages before exploring further.
Overview
The Portfolio Hub API uses JWT (JSON Web Tokens) for authentication. After registering or logging in, you’ll receive a token that must be included in theAuthorization header for protected endpoints.
Authentication Flow
Register or Login
Obtain a JWT token by registering a new account or logging in with existing credentials.
Include Token in Requests
Add the token to the
Authorization header as a Bearer token for all authenticated requests.Registering a New Account
Create a new user account to receive a JWT token.Endpoint
Request Body
User’s full name (3-120 characters)
Valid email address (max 150 characters). Must be unique.
Password (8-100 characters)
Example Request
Example Response
Upon successful registration, a profile is automatically created with a unique slug based on the full name.
Error Responses
Logging In
Authenticate with existing credentials to receive a JWT token.Endpoint
Request Body
Valid email address
Account password
Example Request
Example Response
Error Response
401 Unauthorized - Invalid Credentials
Using the JWT Token
Once you have a token, include it in theAuthorization header for all authenticated requests.
Authorization Header Format
Example Authenticated Request
JWT Token Structure
The JWT token includes the following claims:Standard Claims
Subject - the user’s email address
Issued At - Unix timestamp when the token was created
Expiration - Unix timestamp when the token expires
Custom Claims
The user’s profile ID for quick profile access
The user’s unique identifier
Example Decoded Token
Token Expiration
JWT tokens have a limited lifetime configured by the server administrator via theJWT_EXPIRATION_TIME environment variable (in minutes).
The default expiration time is configured server-side. When your token expires, you’ll receive a 401 Unauthorized response and need to login again.
Handling Expired Tokens
When a token expires, requests will fail with:401 Unauthorized
Token Security
The API uses HMAC-SHA256 for token signing, ensuring tokens cannot be tampered with.Security Configuration
- Algorithm: HMAC with SHA-256 (HS256)
- Secret Key: Configured via
JWT_SECRET_KEYenvironment variable - Session Management: Stateless (no server-side sessions)
Security Best Practices
Do:
- Store tokens securely (e.g., in-memory or secure storage)
- Use HTTPS to prevent token interception
- Implement token refresh logic before expiration
- Clear tokens on logout
- Validate tokens on every request
Protected Endpoints
User Endpoints (/api/me/**)
Require valid JWT token with any authenticated user:
GET /api/me/profile- Get current user’s profilePUT /api/me/profile- Update current user’s profilePUT /api/me/settings/contact-email- Update contact email- All resource management endpoints (projects, skills, experience, etc.)
Admin Endpoints (/api/admin/**)
Require JWT token with ROLE_ADMIN authority:
- Administrative functions for managing global resources
Accessing User Information
When authenticated, the API automatically extracts user information from the token:Troubleshooting
Common Authentication Errors
| Issue | Cause | Solution |
|---|---|---|
401 Unauthorized | Missing or invalid token | Ensure token is included with “Bearer ” prefix |
401 Unauthorized | Expired token | Login again to get a fresh token |
403 Forbidden | Insufficient permissions | Verify user has required role (e.g., ROLE_ADMIN) |
400 Bad Request | Malformed header | Check Authorization header format |