Get an access token, include it in every request, and handle token refresh and access keys for webhook signing.
Every request to the TagPay API (except merchant registration) requires a valid access token. This page explains how to get a token, how to use it, when it expires, and how to handle expiry gracefully.
Call POST /auth/login with your merchant account email and password. The API returns tokens in response headers, not in the response body.
POST https://api.tagpay.ng/v1/auth/login
The email and password values must be Base64-encoded before sending. The server decodes them server-side before validation. Example: Buffer.from("[email protected]").toString("base64") in Node.js, or echo -n "[email protected]" | base64 in bash.
If your account has not been verified, the login response will include "requiresVerification": true and the API will send a new verification code to your email. Verify your account using PUT /merchant/verify before attempting to log in again.
Access tokens expire. When a request returns 401 Unauthorized, use your refresh token to obtain a new token pair without asking the user to log in again.
POST https://api.tagpay.ng/v1/auth/refresh/token
Pass the refresh token in the X-Refresh-Token request header (not in the body).
curl -X POST https://api.tagpay.ng/v1/auth/refresh/token \ -H "X-Refresh-Token: d4f9a2c1e8b3..."
The API rotates the token pair on every refresh. Store the new X-Access-Token and X-Refresh-Token from the response headers and discard the old ones.Response headers (on success)
Each refresh token can only be used once. Once you call /auth/refresh/token, the previous token pair is invalidated. If your refresh token is expired or invalid, the user must log in again.
In addition to your access token, TagPay gives you a public key and private key for your merchant account. These are used to sign and verify webhook payloads — they are not used for API authentication.
Your private key is sensitive. Do not expose it in client-side code or commit it to version control. Store it as an environment variable or in a secrets manager.
The access token is missing, expired, or invalid. Refresh the token or log in again.
403
FORBIDDEN
The token is valid but your account does not have permission for this action. Check that your account is active and has the required role.
400
ACCOUNT_LOCKED
Your merchant account has been locked from login. Contact TagPay support to resolve this.
Always check for a 401 response in your HTTP client and implement automatic token refresh. Users should never see an authentication error if your refresh logic is in place.