Authentication
How clients get, send, refresh and lose access tokens, and how social sign-in and KYC fit in.
The API uses JSON Web Tokens. Signing in returns two tokens:
| Token | Used for | Lifetime |
|---|---|---|
| Access token | Sent with every protected request | JWT_ACCESS_EXPIRY on the server. 15 minutes if unset. |
| Refresh token | Getting a new access token | JWT_REFRESH_EXPIRY on the server. 7 days if unset. |
Sending the token
GET /api/v1/user/profile
Authorization: Bearer eyJhbGciOiJIUzI1NiIs...On every protected request the server verifies the token and loads the user. The token carries the user's id, email, role and a session id.
Two places accept the token another way:
- The server-sent events stream (
GET /api/v1/stream/events) also accepts?token=<access token>, because a browserEventSourcecannot set headers. - The Socket.IO handshake takes it as
auth.token(orquery.token), without theBearerprefix.
Getting tokens
Sign up
POST /auth/signup creates an unverified account and emails a verification link (web) or a 4-digit code valid for 15 minutes (when the body has isMobile: true). No tokens are returned. The role defaults to TENANT; ADMIN cannot be chosen.
Verify the email
The verification page calls GET /auth/verify-email?token=.... Mobile apps send the code to POST /auth/verify-email-otp. POST /auth/resend-verification sends a new link or code and invalidates the old one.
Sign in
POST /auth/signin with email and password returns accessToken, refreshToken and a short user object. Unverified and deactivated accounts are refused.
Google and Apple
| Flow | Endpoints |
|---|---|
| Google on the web | GET /auth/google returns data.authUrl. Send the browser there. Google redirects back to the web app, which forwards the code to GET /auth/google/callback. That returns the same body as sign-in. |
| Google on mobile | The app signs in with the Google SDK and sends the ID token to POST /auth/google/native. |
| Apple on iOS | The app sends the identity token (and, the first time, the user's name) to POST /auth/apple/native. |
Social sign-in creates the account on first use, already email-verified and without a password. An existing account with the same email is linked instead.
Refreshing
When a request fails with 401 Token has expired, call POST /auth/refresh-token with the refresh token. It returns a new access token; the refresh token itself is not rotated.
One refresh token per account
The account stores a single refresh token. Signing in on another device replaces it, so the first device's refresh token stops working and that device must sign in again.
Signing out
| Action | Endpoint | Effect |
|---|---|---|
| Sign out this device | POST /auth/signout | Clears the refresh token and the session. Always answers 200. |
| Sign out everywhere | POST /user/logout-all-devices | Clears the refresh token and every session. |
| Change password | POST /user/change-password | Replaces the password. |
| Reset password | POST /auth/forgot-password, then POST /auth/reset-password | Replaces the password and clears the refresh token. |
Access tokens are not revoked
None of these actions invalidates access tokens that were already issued. They keep working until they expire. The server also does not re-check whether the account is still active on each request, so a deactivated or deleted account's access token works until it expires. Keep JWT_ACCESS_EXPIRY short.
Sessions and two-factor
Each sign-in records a session (device, browser, location from the IP); the 10 most recent are kept and listed by GET /user/active-sessions. A sign-in from a new device sends a "New Login Detected" notification.
POST /user/enable-2fa and POST /user/disable-2fa only store a preference today. Sign-in does not ask for a second factor.
KYC
Agents and landlords must be KYC-verified to create listings.
| Endpoint | Purpose |
|---|---|
GET /auth/kyc/status | The current status and which step is next |
POST /auth/kyc/verify | Look up a NIN, driver's licence or CAC number. Only a NIN whose record matches the account's name verifies the account. |
POST /auth/kyc/nin | The first step of a two-step NIN flow. The second step (liveness) does not exist yet, so use /auth/kyc/verify instead. |
Errors you will see
| Status | Message | Cause |
|---|---|---|
| 401 | Authentication required. Please provide a valid token. | No Authorization header |
| 401 | Token has expired | Refresh and retry |
| 401 | Invalid token | Malformed, or signed with another secret |
| 401 | User not found | The account no longer exists |
| 403 | Access denied. This action requires one of the following roles: ... | Wrong role for the endpoint |
HomeLink Hub