NexGate is a social commerce platform that provides secure authentication services with OTP-based verification. This documentation covers the complete authentication API including registration, login,
API Response Standards
All API responses follow a consistent structure to ensure predictable client integration.
Success Response Structure
{"success":true,"httpStatus":"OK","message":"Operation completed successfully","action_time":"2024-09-07T15:30:45","data":{// Response data object}}
Error Response Structure
{"success":false,"httpStatus":"BAD_REQUEST","message":"Error description","action_time":"2024-09-07T15:30:45","data":"Detailed error information or validation errors"}
Response Fields Specification
Field
Type
Description
success
boolean
Indicates if the request was successful
httpStatus
string
HTTP status code as string
message
string
Human-readable message describing the result
action_time
string
ISO 8601 timestamp of when the response was generated
data
object/string
Response payload or error details
Base Configuration
API Base URL
Required Headers
Authentication Headers (for protected endpoints)
Authentication Flow
The NexGate authentication system follows a secure OTP-based verification process:
Flow Diagram
Key Security Features
OTP-based verification for all critical operations
JWT tokens with configurable expiration
Rate limiting on OTP requests
Automatic username generation
Multi-channel OTP delivery support
API Endpoints
Endpoint Access Levels
🔓 PUBLIC - No authentication required
🔒 PROTECTED - Requires valid access token
1. User Registration
🔓 PUBLIC ENDPOINT - No authentication required
Endpoint:POST /register
Description: Creates a new user account and sends verification OTP to the specified channel.
Request Specification
Request Body Schema
Field
Type
Constraints
Required
Description
phoneNumber
string
E.164 format
✅
International phone number
password
string
Min 8 chars, complexity rules
✅
User password
email
string
Valid email format
✅
User email address
firstName
string
Max 30 characters
✅
User's first name
lastName
string
Max 30 characters
✅
User's last name
middleName
string
Max 30 characters
✅
User's middle name
verificationChannel
enum
See verification channels
✅
OTP delivery method
⚠️ Password Complexity Rules
Minimum 8 characters
At least one uppercase letter (A-Z)
At least one lowercase letter (a-z)
At least one digit (0-9)
At least one special character (@$!%*?&#)
Success Response (200 OK)
Error Responses
User Already Exists (400)
Validation Errors (422)
2. Verify Registration OTP
🔓 PUBLIC ENDPOINT - No authentication required
Endpoint:POST /verify-otp
Description: Verifies the OTP sent during registration and completes account setup.
Request Specification
Request Body Schema
Field
Type
Constraints
Required
Description
tempToken
string
Valid JWT token
✅
Temporary token from registration
otpCode
string
Exactly 6 digits
✅
OTP received via verification channel
Success Response (200 OK)
Error Responses
Invalid OTP (403)
Token Expired (403)
Max Attempts Exceeded (403)
3. Resend OTP
🔓 PUBLIC ENDPOINT - No authentication required
Endpoint:POST /resend-otp
Description: Resends OTP for registration, login, or password reset operations.
Request Specification
Request Body Schema
Field
Type
Constraints
Required
Description
tempToken
string
Valid JWT token
✅
Temporary token from previous operation
Success Response (200 OK)
Error Responses
Rate Limit Exceeded (400)
Invalid Token (403)
4. User Login
🔓 PUBLIC ENDPOINT - No authentication required
Endpoint:POST /login
Description: Authenticates user credentials and sends login OTP.
Request Specification
Request Body Schema
Field
Type
Constraints
Required
Description
identifier
string
Email, username, or phone
✅
User identifier
password
string
User's password
✅
Account password
Success Response (200 OK)
Error Responses
User Not Found (404)
Invalid Credentials (401)
5. Request Password Reset
🔓 PUBLIC ENDPOINT - No authentication required
Endpoint:POST /psw-reset-otp
Description: Initiates password reset process by sending OTP to user's email.
Request Specification
Request Body Schema
Field
Type
Constraints
Required
Description
email
string
Valid email format
✅
Registered email address
Success Response (200 OK)
Error Responses
Account Not Found (404)
Account Not Verified (403)
6. Reset Password
🔓 PUBLIC ENDPOINT - No authentication required
Endpoint:POST /reset-password
Description: Completes password reset using OTP verification.
Request Specification
Request Body Schema
Field
Type
Constraints
Required
Description
tempToken
string
Valid JWT token
✅
Token from password reset request
code
string
6-digit OTP
✅
OTP received via email
newPassword
string
Password complexity rules
✅
New password
Success Response (200 OK)
Error Responses
Invalid OTP (403)
Password Validation Error (422)
7. Refresh Token
🔓 PUBLIC ENDPOINT - No authentication required
Endpoint:POST /refreshToken
Description: Generates a new access token using a valid refresh token.
{
"success": false,
"httpStatus": "UNPROCESSABLE_ENTITY",
"message": "Validation failed",
"action_time": "2024-09-07T15:30:45",
"data": {
"email": "Email should be valid",
"password": "Password must be at least 8 characters long, contain at least one uppercase letter, one lowercase letter, one digit, and one special character",
"phoneNumber": "Phone number must be in valid international format (e.g., +1234567890)"
}
}
POST /api/v1/auth/verify-otp
Content-Type: application/json
{
"tempToken": "eyJhbGciOiJIUzI1NiJ9...",
"otpCode": "123456"
}
POST /api/v1/auth/psw-reset-otp
Content-Type: application/json
{
"email": "gilfoyle@piedpiper.com"
}
{
"success": true,
"httpStatus": "OK",
"message": "Password reset OTP sent successfully",
"action_time": "2024-09-07T16:15:45",
"data": {
"tempToken": "eyJhbGciOiJIUzI1NiJ9...",
"message": "Password reset OTP has been sent to your email",
"expireAt": "2024-09-07T16:25:45"
}
}
{
"success": false,
"httpStatus": "NOT_FOUND",
"message": "No account found with this email",
"action_time": "2024-09-07T16:15:45",
"data": "No account found with this email"
}
{
"success": false,
"httpStatus": "FORBIDDEN",
"message": "Account is not verified. Please complete registration first.",
"action_time": "2024-09-07T16:15:45",
"data": "Account is not verified. Please complete registration first."
}
{
"success": true,
"httpStatus": "OK",
"message": "Password reset successfully",
"action_time": "2024-09-07T16:20:45",
"data": "Your password has been updated. You can now login with your new password."
}
{
"success": false,
"httpStatus": "UNPROCESSABLE_ENTITY",
"message": "Validation failed",
"action_time": "2024-09-07T16:20:45",
"data": {
"newPassword": "Password must be at least 8 characters long, contain at least one uppercase letter, one lowercase letter, one digit, and one special character"
}
}
POST /api/v1/auth/refreshToken
Content-Type: application/json
{
"refreshToken": "eyJhbGciOiJIUzI1NiJ9.REFRESH_TOKEN..."
}