Skip to Content
HomeLink Hub
Authentication

Sign in with email and password

POST
/api/v1/auth/signin

Access: Public, no token needed. Also requires: Email verified; Account active.

Checks the credentials and returns an access token, a refresh token and a short user summary. The access token is a JWT carrying user_id, email, session_id, username and role; send it as Authorization: Bearer <token>. The access token lasts JWT_ACCESS_EXPIRY (15 minutes by default) and the refresh token JWT_REFRESH_EXPIRY (7 days by default).

A session record is stored for the device (device name and browser are derived from the User-Agent header, location is the first X-Forwarded-For address or the request IP); only the 10 most recent sessions are kept. The account holds one refresh token, so signing in overwrites the previous one and refresh tokens issued to other devices stop working. If the account already had at least one session, a new_device_login notification ("New Login Detected") is created: it is delivered over the notifications:new socket event and as a push only if the user's systemUpdates.inApp preference is on (off by default), and by email if systemUpdates.email is on (on by default).

The twoFactorEnabled flag is not consulted here: there is no second step. Accounts created through Google or Apple have no password; signing in to one with a password fails with a 500 (see responses). Soft-deleted accounts are inactive and get the 403 "deactivated" response.

Request Body

application/json
  1. body
email*string

Account email (lower-cased and trimmed before lookup).

Formatemail
password*string

Account password.

Response Body

Signed in

application/json
  1. response
status*integer
success*boolean
message*string
data*
Example Request
curl -X POST 'http://localhost:4000/api/v1/auth/signin' \  -H 'Content-Type: application/json' \  -d '{  "email": "adaeze.okonkwo@example.com",  "password": "S3cure-Passw0rd"}'
Example Response
{  "status": 200,  "success": true,  "message": "Sign in successful.",  "data": {    "accessToken": "eyJhbGciOiJIUzI1NiIs...",    "refreshToken": "eyJhbGciOiJIUzI1NiIs...",    "user": {      "id": "665f1c2e9b1d4a0012ab34cd",      "firstName": "Adaeze",      "lastName": "Okonkwo",      "email": "adaeze.okonkwo@example.com",      "role": "AGENT",      "avatar": "https://cdn.example.com/avatars/adaeze-okonkwo.jpg",      "isKYCVerified": true    }  }}