Skip to main content

Overview

Use this endpoint to authenticate a merchant user with their email and password. On success, you receive an accessToken and refreshToken in the response headers, along with user and merchant details in the response body.
Email and password values must be Base64-encoded before sending. The server decodes them before validation.

Endpoint

POST https://api.tagpay.ng/v1/auth/login

Request

Headers

HeaderValueRequired
Content-Typeapplication/jsonYes

Body Parameters

email
string
required
The merchant’s email address, Base64-encoded. Must be a valid email format.
password
string
required
The merchant’s account password, Base64-encoded. Minimum 6 characters.
metadata
object
Optional device and session metadata used for activity logging and fraud detection.

Response

Headers

The server returns the tokens in response headers in addition to the body.
HeaderDescription
X-Access-TokenShort-lived JWT used to authenticate API requests
X-Refresh-TokenLong-lived token used to obtain a new access token

Body

status
boolean
true on a successful login.
data
object
Authenticated user information.
merchant
object
The merchant account linked to the authenticated user.
availableMerchants
array
A list of all active merchant accounts this user has access to.
hasMultipleMerchants
boolean
true if the user has access to more than one active merchant account.

Code Example

# Values are Base64-encoded:
# [email protected] → bWVyY2hhbnRAZXhhbXBsZS5jb20=
# password123          → cGFzc3dvcmQxMjM=

curl -X POST https://api.tagpay.ng/v1/auth/login \
  -H "Content-Type: application/json" \
  -D - \
  -d '{
    "email": "bWVyY2hhbnRAZXhhbXBsZS5jb20=",
    "password": "cGFzc3dvcmQxMjM=",
    "metadata": {
      "deviceFingerprint": "abc123fingerprint",
      "timezone": "Africa/Lagos",
      "language": "en-NG"
    }
  }'

Example Response

{
  "status": true,
  "data": {
    "id": "usr_01hxyz1234",
    "role": "MERCHANT",
    "email": "[email protected]",
    "firstName": "Amara",
    "lastName": "Okonkwo",
    "mode": "SANDBOX",
    "createdAt": "2024-01-15T10:30:00.000Z",
    "updatedAt": "2024-03-01T08:00:00.000Z"
  },
  "merchant": {
    "id": "mch_01hxyz5678",
    "businessName": "Okonkwo Payments Ltd",
    "businessType": "FINANCIAL-SERVICES",
    "email": "[email protected]",
    "role": "owner",
    "owner": true,
    "mode": "SANDBOX",
    "review": "ENABLED",
    "callbackURL": "https://yourapp.com/webhooks/tagpay",
    "sandboxCallbackURL": "https://yourapp.com/webhooks/tagpay-sandbox",
    "canDebitCustomer": true,
    "parentMerchant": null,
    "createdAt": "2024-01-15T10:30:00.000Z",
    "updatedAt": "2024-03-01T08:00:00.000Z"
  },
  "availableMerchants": [
    {
      "id": "mch_01hxyz5678",
      "businessName": "Okonkwo Payments Ltd",
      "role": "owner",
      "owner": true,
      "mode": "SANDBOX"
    }
  ],
  "hasMultipleMerchants": false
}

Unverified Account Response

If the user’s account has not been verified, the API sends a verification code to their email and returns:
{
  "requiresVerification": true,
  "message": "Account has not been verified. Kindly check your email for verification code"
}

Error Responses

StatusDescription
400ACCOUNT_LOCKED — The merchant’s login access has been locked by an administrator.
401Invalid email address or password.
401Account is currently disabled.
422Validation error — email or password failed schema validation.