Register New User
Endpoint
Request Body
User’s full name. Maximum 100 characters.
Valid email address. Must be unique in the system.
User password. Must be at least 8 characters long. Will be hashed using BCrypt with strength 12.
Response
JWT Bearer token (HS256, 24-hour validity). Include this in the
Authorization header as Bearer <token> for authenticated requests.The registered user’s name.
The registered user’s email address (matches the JWT subject).
Status Codes
User successfully registered. Returns JWT token and user details.
Invalid input data. Response includes field-level validation errors.
Email address already registered.
Example Response
Login User
Endpoint
Request Body
Registered email address.
User password.
Response
JWT Bearer token (HS256, 24-hour validity). Include this in the
Authorization header as Bearer <token> for authenticated requests.The authenticated user’s name.
The authenticated user’s email address (matches the JWT subject).
Status Codes
User successfully authenticated. Returns JWT token and user details.
Invalid input data (e.g., malformed email).
Invalid credentials (email not found or incorrect password).
Example Response
Authentication Flow
- Register or Login: Call
/api/auth/registeror/api/auth/loginto obtain a JWT token - Store Token: Save the token securely (e.g., localStorage, secure cookie)
- Include in Requests: Add the token to the
Authorizationheader for authenticated endpoints: - Token Expiry: Tokens expire after 24 hours. Request a new token by logging in again
Security Notes
- Passwords are hashed using BCrypt with strength 12 (OWASP recommendation)
- JWT tokens are signed with HS256 algorithm
- Default token expiration: 24 hours (configurable via
JWT_EXPIRATION_MSenvironment variable) - The JWT secret key must be at least 32 characters and stored securely (use AWS SSM Parameter Store in production)