Introduction
ServITech uses JWT (JSON Web Tokens) for secure API authentication. This system provides stateless authentication, allowing clients to authenticate once and receive a token for subsequent requests.Authentication Flow
- Register - Create a new user account with email, password, name, and phone
- Login - Authenticate with email and password to receive a JWT token
- Authorized Requests - Include the JWT token in the
Authorizationheader - Logout - Invalidate the current token (optional)
- Password Reset - Request a password reset link via email
JWT Token Details
The ServITech API uses the tymon/jwt-auth package with the following configuration:HMAC SHA-256 signing algorithm for token security
Default token lifetime (configurable via
JWT_TTL environment variable)Time window for token refresh after expiration
Token blacklist enabled for logout functionality
Token Claims
Each JWT token includes the following required claims:iss- Issuer (your API)iat- Issued at timestampexp- Expiration timestampnbf- Not before timestampsub- Subject (user ID)jti- JWT ID (unique token identifier)
Protected Routes
Some endpoints require authentication. Include the JWT token in your requests:Public Endpoints
POST /auth/login- User loginPOST /auth/register- User registrationPOST /auth/reset-password- Send password reset linkPUT /auth/reset-password- Reset password with token
Protected Endpoints
POST /auth/logout- User logout (requires valid token)- All
/user/*routes - User profile management - All
/support-request/*routes - Support ticket management
Admin-Only Endpoints
Require authentication AND admin role:- All
/category/*routes - All
/repair-request/*routes
The API supports localization through the
Accept-Language header. Supported languages include en (English) and es (Spanish).User Roles
The system supports role-based access control:- USER - Default role assigned on registration
- ADMIN - Administrative role with elevated permissions
Next Steps
Login
Authenticate and receive a JWT token
Register
Create a new user account
JWT Tokens
Learn about token lifecycle and management
Password Reset
Reset forgotten passwords