Authentication & User Management

Handles user onboarding, token issuance, session handling, role access, and identity management.


πŸ”Έ POST /sign-up – Register New User

Registers a new user and sends a verification OTP to their email.

Request Body:

{
  "email": "[email protected]",
  "first_name": "John",
  "last_name": "Doe",
  "password": "strongpassword123"
}

πŸ” Auth Required: No πŸ“© Sends OTP to email

βœ… cURL

curl -X POST https://api.yourdomain.com/sign-up \
  -H "Content-Type: application/json" \
  -d '{
    "email": "[email protected]",
    "first_name": "John",
    "last_name": "Doe",
    "password": "strongpassword123"
  }'

βœ… JS Example


πŸ”Έ POST /sign-in – Authenticate & Get JWT Token

Logs in a user and returns a token for future requests.

Request:

Response:

πŸ” Auth Required: No

βœ… cURL

βœ… JS Example


πŸ”Έ GET /me – Get Current User

Returns profile info of the authenticated user.

πŸ” Auth Required: βœ… Yes (Bearer Token)

βœ… cURL

βœ… JS Example


πŸ”Έ GET /logout – Logout User

Invalidates the current JWT token.

πŸ” Auth Required: βœ… Yes

βœ… cURL


πŸ”Έ POST /send-otp – Send OTP to Email

Sends a one-time verification code to a user's email.

Request:

πŸ” Auth Required: ❌ No

βœ… cURL


πŸ”Έ POST /password-reset/request – Start Reset Flow

Sends OTP to email for resetting password.

βœ… cURL


πŸ”Έ POST /password-reset/confirm – Confirm New Password

Request:

βœ… cURL


πŸ”Έ GET /all-users – List All Users (Admin Only)

πŸ” Auth Required: βœ… Admin

βœ… cURL


πŸ”Έ GET /users/{user_id} – Get User by ID

Returns details of a specific user (admin access).

βœ… cURL


πŸ”Έ POST /users/{user_id}/change-role/{new_role_id} – Change Role

Changes the user's role (e.g., to admin, user, etc.).

βœ… cURL


πŸ”Έ PUT /{user_id} – Update Profile

Update user details like name or password.

βœ… cURL


πŸ”Έ DELETE /{user_id} – Delete Account

Permanently deletes a user account.

βœ… cURL


πŸ”Έ GET /by-email/{email} – Lookup User by Email

Finds a user using their email address.

βœ… cURL


πŸ”Έ POST /google – Login with Google OAuth

Log in using Google. Typically done via frontend OAuth provider like Google SDK. The server endpoint exchanges the token and responds with a JWT.

βœ… cURL

Last updated