Skip to content

Authentication

Perform a login operation to retrieve an access and refresh token pair.

POST /v1/auth/login

Access tokens are used for all API calls and refresh tokens are used to get new access tokens without logging in again.

Sample

json
POST /v1/auth/login
{
    "username": "{{$randomUserName}}",
    "password": "{{$randomPassword}}"
}

Auth: None (public).

Request body

FieldTypeRequiredDescription
usernamestringYesThe username (required).
passwordstringYesThe password (required).
json
{
  "username": "string",
  "password": "string"
}

Responses

StatusDescription
200The login succeeded and an access and refresh token pair was returned.
400The request failed validation, the error object will contain further information.
401The login failed because of incorrect credentials or because the account requires additional verification.
422The request payload is invalid, the error object will contain further information.
429Too many requests are being sent concurrently or rate limiting has taken effect.
500An unexpected error occurred, the error object will contain further information.

Response body

FieldTypeRequiredDescription
successbooleanNoGets a value indicating whether the operation was successful.
resultobjectNoProvides token information for successful login and refresh operations.
json
{
  "success": true,
  "result": {
    "refreshToken": "string",
    "accessToken": "string",
    "accessTokenValidForSeconds": 0
  }
}

Code samples

ts
// @vantagepay/vantagepay
import { ApiError } from '@vantagepay/vantagepay'

try {
  const tokens = await client.auth.login('233555666112', 'Password123!')
  console.log(tokens.accessToken, tokens.refreshToken)
} catch (error) {
  if (error instanceof ApiError) {
    if (error.statusCode === 401 && error.result?.mustChangePassword) {
      await client.auth.changePassword('Password123!', 'NewPassword456!')
    } else if (error.statusCode === 401 && (error.result?.mustValidatePhoneNumber || error.result?.mustValidateEmailAddress)) {
      await client.auth.resendOtp()
      await client.auth.validateOtp('123456')
    } else {
      console.error(error.statusCode, error.message)
    }
  } else {
    throw error
  }
}
csharp
// VantagePay.SDK
using VantagePay.SDK.Exceptions;

try
{
    var tokens = await client.Authentication.LoginAsync("233555666112", "Password123!");
    Console.WriteLine($"{tokens?.AccessToken} / {tokens?.RefreshToken}");
}
catch (ApiAuthorizationException ex)
{
    if (ex.ErrorResponse?.MustChangePassword == true)
    {
        await client.Authentication.ChangePasswordAsync("Password123!", "NewPassword456!");
    }
    else if (ex.ErrorResponse?.MustValidatePhoneNumber == true || ex.ErrorResponse?.MustValidateEmailAddress == true)
    {
        await client.Authentication.ResendOtpAsync();
        await client.Authentication.ValidateOtpAsync("123456");
    }
}

Perform a logout operation to clear your currently active refresh token so that it can no longer be used to generate access tokens.

POST /v1/auth/logout

Sample - Refresh Token required in authorization bearer header

json
POST /v1/auth/logout

Auth: Refresh token (Bearer).

Responses

StatusDescription
200The logout succeeded and the most recently active refresh token is no longer valid.
400The request failed validation, the error object will contain further information.
401The authorization information provided is not valid, authentication is required to access this resource.
403The authorization header does not contain the correct type or you do not have access to this resource.
422The request payload is invalid, the error object will contain further information.
429Too many requests are being sent concurrently or rate limiting has taken effect.
500An unexpected error occurred, the error object will contain further information.

Response body

FieldTypeRequiredDescription
successbooleanNoGets a value indicating whether the operation was successful.
json
{
  "success": true
}

Code samples

ts
// @vantagepay/vantagepay
await client.auth.logout()
csharp
// VantagePay.SDK
await client.Authentication.LogoutAsync();

Perform a token refresh operation to retrieve a new access and refresh token pair.

POST /v1/auth/refresh

Sample - Refresh Token required in authorization bearer header

json
POST /v1/auth/refresh

Auth: Refresh token (Bearer).

Responses

StatusDescription
200The refresh succeeded and a new access and refresh token pair was returned.
400The request failed validation, the error object will contain further information.
401The refresh failed and new tokens need be retrieved using the /login end-point.
403The authorization header does not contain the correct type or you do not have access to this resource.
422The request payload is invalid, the error object will contain further information.
429Too many requests are being sent concurrently or rate limiting has taken effect.
500An unexpected error occurred, the error object will contain further information.

Response body

FieldTypeRequiredDescription
successbooleanNoGets a value indicating whether the operation was successful.
resultobjectNoProvides token information for successful login and refresh operations.
json
{
  "success": true,
  "result": {
    "refreshToken": "string",
    "accessToken": "string",
    "accessTokenValidForSeconds": 0
  }
}

Code samples

ts
// @vantagepay/vantagepay
// The SDK refreshes automatically; call refresh() to force a new token pair.
const tokens = await client.auth.refresh()
csharp
// VantagePay.SDK
// The SDK refreshes automatically; call RefreshAsync() to force a new token pair.
var tokens = await client.Authentication.RefreshAsync();

Checks the liveness of a user's face by analyzing a series of images.

POST /v1/auth/liveness

Auth: Access token (Bearer).

Request body

FieldTypeRequiredDescription
base64Imagesarray<string>?NoGets the ordered collection of Base64-encoded face-capture images used for liveness detection.
json
{
  "base64Images": [
    "string"
  ]
}

Responses

StatusDescription
200The request was successful but does not return any results.
400The request failed validation, the error object will contain further information.
401The authorization information provided is not valid, authentication is required to access this resource.
403The authorization header does not contain the correct type or you do not have access to this resource.
422The request payload is invalid, the error object will contain further information.
429Too many requests are being sent concurrently or rate limiting has taken effect.
500An unexpected error occurred, the error object will contain further information.

Response body

FieldTypeRequiredDescription
successbooleanNoGets a value indicating whether the operation was successful.
resultNone, OneRangeOfMotion, MultipleRangesOfMotion, AllRangesOfMotionNoControls the strictness of facial liveness movement detection during a KYC liveness check.
json
{
  "success": true,
  "result": "None"
}

Code samples

ts
// @vantagepay/vantagepay
const level = await client.auth.checkLiveness([image1Base64, image2Base64])
// FaceMovementDetectionLevel indicates the confidence of the liveness check.
csharp
// VantagePay.SDK
var level = await client.Authentication.CheckLivenessAsync(new[] { image1Base64, image2Base64 });

Checks the quality of a facial image.

POST /v1/auth/face-check

Auth: Access token (Bearer).

Request body

FieldTypeRequiredDescription
base64Imagestring?NoGets the Base64-encoded selfie image to use for facial comparison.
json
{
  "base64Image": "string"
}

Responses

StatusDescription
200The request was successful but does not return any results.
400The request failed validation, the error object will contain further information.
401The authorization information provided is not valid, authentication is required to access this resource.
403The authorization header does not contain the correct type or you do not have access to this resource.
422The request payload is invalid, the error object will contain further information.
429Too many requests are being sent concurrently or rate limiting has taken effect.
500An unexpected error occurred, the error object will contain further information.

Response body

FieldTypeRequiredDescription
successbooleanNoGets a value indicating whether the operation was successful.
resultobjectNoThe result of a facial image quality check performed prior to a KYC biometric submission.
json
{
  "success": true,
  "result": {
    "faceCount": 0,
    "containsNoise": true,
    "isLowQuality": true,
    "isOverExposed": true,
    "isUnderExposed": true,
    "isBlurry": true,
    "isWearingMask": true,
    "foreheadNotIncluded": true,
    "eyesNotIncluded": true,
    "mouthNotIncluded": true,
    "problems": []
  }
}

Code samples

ts
// @vantagepay/vantagepay
const result = await client.auth.checkFace(selfieBase64)
console.log(result.isValid, result.qualityScore)
csharp
// VantagePay.SDK
var result = await client.Authentication.CheckFaceAsync(selfieBase64);

Change a user's password.

POST /v1/auth/password/change

Auth: Access token (Bearer).

Request body

FieldTypeRequiredDescription
oldPasswordstring?NoThe user's current/old password. Required when the user is already authenticated.
newPasswordstringYesThe new password to set (required).
resetCodestring?NoA password-reset code sent to the user by email or SMS. Required when calling the anonymous (unauthenticated) endpoint.
userReferencestring?NoThe unique reference of the user account to update. Not required when the user is already authenticated.
json
{
  "oldPassword": "string",
  "newPassword": "string",
  "resetCode": "00000000-0000-0000-0000-000000000000",
  "userReference": "00000000-0000-0000-0000-000000000000"
}

Responses

StatusDescription
200The request was successful and the password was changed.
400The request failed validation, the error object will contain further information.
401The request was successful but does not return any results.
422The request payload is invalid, the error object will contain further information.
429Too many requests are being sent concurrently or rate limiting has taken effect.
500An unexpected error occurred, the error object will contain further information.

Response body

FieldTypeRequiredDescription
successbooleanNoGets a value indicating whether the operation was successful.
resultobjectNoProvides token information for successful login and refresh operations.
json
{
  "success": true,
  "result": {
    "refreshToken": "string",
    "accessToken": "string",
    "accessTokenValidForSeconds": 0
  }
}

Code samples

ts
// @vantagepay/vantagepay
const tokens = await client.auth.changePassword('OldPassword123!', 'NewPassword456!')
csharp
// VantagePay.SDK
var tokens = await client.Authentication.ChangePasswordAsync("OldPassword123!", "NewPassword456!");

Validate OTP request.

POST /v1/auth/otp/validate

Auth: Access token (Bearer).

Request body

FieldTypeRequiredDescription
otpValuestringYesThe OTP value entered by the user (required).
json
{
  "otpValue": "string"
}

Responses

StatusDescription
200The request was successful and the correct OTP value was supplied.
400The request failed validation, the error object will contain further information.
401The authorization information provided is not valid, authentication is required to access this resource.
403The authorization header does not contain the correct type or you do not have access to this resource.
422The request payload is invalid, the error object will contain further information.
429Too many requests are being sent concurrently or rate limiting has taken effect.
500An unexpected error occurred, the error object will contain further information.

Response body

FieldTypeRequiredDescription
successbooleanNoGets a value indicating whether the operation was successful.
resultobjectNoProvides token information for successful login and refresh operations.
json
{
  "success": true,
  "result": {
    "refreshToken": "string",
    "accessToken": "string",
    "accessTokenValidForSeconds": 0
  }
}

Code samples

ts
// @vantagepay/vantagepay
const tokens = await client.auth.validateOtp('123456')
if (tokens) {
  console.log('OTP accepted, session established')
}
csharp
// VantagePay.SDK
var tokens = await client.Authentication.ValidateOtpAsync("123456");

Request a new OTP to be sent.

POST /v1/auth/otp/resend

Auth: Access token (Bearer).

Responses

StatusDescription
200The request was successful and a new OTP was sent to the merchant mobile number.
400The request failed validation, the error object will contain further information.
401The authorization information provided is not valid, authentication is required to access this resource.
403The authorization header does not contain the correct type or you do not have access to this resource.
422The request payload is invalid, the error object will contain further information.
429Too many requests are being sent concurrently or rate limiting has taken effect.
500An unexpected error occurred, the error object will contain further information.

Response body

FieldTypeRequiredDescription
successbooleanNoGets a value indicating whether the operation was successful.
json
{
  "success": true
}

Code samples

ts
// @vantagepay/vantagepay
await client.auth.resendOtp()
csharp
// VantagePay.SDK
await client.Authentication.ResendOtpAsync();

Send a temporary password to the email addresses associated with the specified username.

POST /v1/auth/password/forgot

To prevent timing-based enumeration, the response is always delayed to a minimum of 3 seconds regardless of whether the account exists.

Auth: Access token (Bearer).

Request body

FieldTypeRequiredDescription
usernamestringYesThe username (email address or mobile number) of the account to reset (required).
json
{
  "username": "string"
}

Responses

StatusDescription
200The request was processed. A temporary password will have been sent if the account was found and had verified email addresses.
400The request failed validation, the error object will contain further information.
422The request payload is invalid, the error object will contain further information.
429Too many requests are being sent concurrently or rate limiting has taken effect.
500An unexpected error occurred, the error object will contain further information.

Response body

FieldTypeRequiredDescription
successbooleanNoGets a value indicating whether the operation was successful.
json
{
  "success": true
}

Code samples

ts
// @vantagepay/vantagepay
await client.auth.forgotPassword('233555666112')
csharp
// VantagePay.SDK
await client.Authentication.ForgotPasswordAsync("233555666112");

Re-sends email verification for a user.

POST /v1/auth/email/verify/resend

Auth: Access token (Bearer).

Responses

StatusDescription
200Email verification resend operation succeeded.
400Email verification resend operation failed due to invalid request input.
401The authorization information provided is not valid, authentication is required to access this resource.
403The authorization header does not contain the correct type or you do not have access to this resource.
422The request payload is invalid, the error object will contain further information.
429Too many requests are being sent concurrently or rate limiting has taken effect.
500An unexpected error occurred, the error object will contain further information.

Response body

FieldTypeRequiredDescription
successbooleanNoGets a value indicating whether the operation was successful.
json
{
  "success": true
}

Code samples

ts
// @vantagepay/vantagepay
await client.auth.resendEmailAddressVerification()
csharp
// VantagePay.SDK
await client.Authentication.ResendEmailAddressVerificationAsync();

Verifies an email address using a verification code.

GET /v1/auth/email/verify/{reference}/{verificationCode}

Auth: Access token (Bearer).

Parameters

NameInRequiredDescription
referencepathYesThe reference of the entity that requested the verification.
verificationCodepathYesThe verification code sent to the user's email address.

Responses

StatusDescription
200Email verification operation succeeded. Returns an Microsoft.AspNetCore.Mvc.ActionResult.
400Email verification operation failed due to invalid request input. Returns a BadRequest result.
422The request payload is invalid, the error object will contain further information.
429Too many requests are being sent concurrently or rate limiting has taken effect.
500An unexpected error occurred, the error object will contain further information.

Response body

FieldTypeRequiredDescription
successbooleanNoGets a value indicating whether the operation was successful.
json
{
  "success": true
}

Code samples

ts
// @vantagepay/vantagepay
// Confirms an email address from the link sent to the user. This is not intended to be called directly.
csharp
// VantagePay.SDK
// Confirms an email address from the link sent to the user. This is not intended to be called directly.

Create a user.

POST /v1/user/create

Sample

json
POST v1/user/create
{
  "username": "{{$randomUserName}}",
  "password": "{{$randomPassword}}"
}

Auth: Access token (Bearer).

Request body

FieldTypeRequiredDescription
usernamestringYesThe username (required).
passwordstringYesThe password (required).
isLockedOutbooleanNotrue if the user account is currently locked out.
reasonForLockoutstring?NoThe reason the user account was locked out, if applicable.
json
{
  "username": "string",
  "password": "string",
  "isLockedOut": true,
  "reasonForLockout": "string"
}

Responses

StatusDescription
200The user was created successfully and a new user reference was returned.
400The request failed validation, the error object will contain further information.
401The authorization information provided is not valid, authentication is required to access this resource.
403The authorization header does not contain the correct type or you do not have access to this resource.
422The request payload is invalid, the error object will contain further information.
429Too many requests are being sent concurrently or rate limiting has taken effect.
500An unexpected error occurred, the error object will contain further information.

Response body

FieldTypeRequiredDescription
successbooleanNoGets a value indicating whether the operation was successful.
resultstringNoGets the response payload.
json
{
  "success": true,
  "result": "00000000-0000-0000-0000-000000000000"
}

Code samples

ts
// @vantagepay/vantagepay
// Server-side only - requires an admin API key (use the .NET VantagePayAdminClient).
csharp
// VantagePay.SDK
// Server-side only - requires an admin API key.
var userReference = await adminClient.Users.CreateUserAsync("partner.user", "StrongPassword123!");

Deactivate a user.

DELETE /v1/user/deactivate/{userReference}

Auth: Access token (Bearer).

Parameters

NameInRequiredDescription
userReferencepathYesThe globally unique user reference (UUID) to deactivate.

Responses

StatusDescription
200The user was deactivate successfully.
400The request failed validation, the error object will contain further information.
401The authorization information provided is not valid, authentication is required to access this resource.
403The authorization header does not contain the correct type or you do not have access to this resource.
422The request payload is invalid, the error object will contain further information.
429Too many requests are being sent concurrently or rate limiting has taken effect.
500An unexpected error occurred, the error object will contain further information.

Response body

FieldTypeRequiredDescription
successbooleanNoGets a value indicating whether the operation was successful.
json
{
  "success": true
}

Code samples

ts
// @vantagepay/vantagepay
// Server-side only - requires an admin API key (use the .NET VantagePayAdminClient).
csharp
// VantagePay.SDK
await adminClient.Users.DeactivateUserAsync(Guid.Parse("3c3d3e3f-4a4b-4c4d-5e5f-6a6b7c7d8e8f"));

Create a user and link to all merchants based on the mobile number.

POST /v1/merchant/user

Auth: Access token (Bearer).

Request body

FieldTypeRequiredDescription
emailAddressstring?NoThe email address registered to this merchant account.
mobileNumberstring?NoThe mobile number registered to this merchant account, in international format.
usernamestringYesThe username (required).
passwordstringYesThe password (required).
isLockedOutbooleanNotrue if the user account is currently locked out.
reasonForLockoutstring?NoThe reason the user account was locked out, if applicable.
json
{
  "emailAddress": "string",
  "mobileNumber": "string",
  "username": "string",
  "password": "string",
  "isLockedOut": true,
  "reasonForLockout": "string"
}

Responses

StatusDescription
200The user was created successfully, linked to existing merchants and logged in.
400The request failed validation, the error object will contain further information.
401The authorization information provided is not valid, authentication is required to access this resource.
403The authorization header does not contain the correct type or you do not have access to this resource.
422The request payload is invalid, the error object will contain further information.
429Too many requests are being sent concurrently or rate limiting has taken effect.
500An unexpected error occurred, the error object will contain further information.

Response body

FieldTypeRequiredDescription
successbooleanNoGets a value indicating whether the operation was successful.
resultobjectNoProvides token information for successful login and refresh operations.
json
{
  "success": true,
  "result": {
    "refreshToken": "string",
    "accessToken": "string",
    "accessTokenValidForSeconds": 0
  }
}

Code samples

ts
// @vantagepay/vantagepay
// Requires a name-validated session (see POST /v1/merchant/validate/name).
const tokens = await client.merchants.createUser('cashier01', 'StrongPassword123!', '233555666112', 'customer@example.com')
csharp
// VantagePay.SDK
var tokens = await client.Merchants.CreateUserAsync("cashier01", "StrongPassword123!", "233555666112", "customer@example.com");

Get a list of merchant information linked to your account.

GET /v1/merchant/user

Auth: Access token (Bearer).

Responses

StatusDescription
200The request was successful but does not return any results.
400The request failed validation, the error object will contain further information.
401The authorization information provided is not valid, authentication is required to access this resource.
403The authorization header does not contain the correct type or you do not have access to this resource.
422The request payload is invalid, the error object will contain further information.
429Too many requests are being sent concurrently or rate limiting has taken effect.
500An unexpected error occurred, the error object will contain further information.

Response body

FieldTypeRequiredDescription
successbooleanNoGets a value indicating whether the operation was successful.
resultarray<object>?NoGets the response payload.
json
{
  "success": true,
  "result": [
    {}
  ]
}

Code samples

ts
// @vantagepay/vantagepay
const merchants = await client.merchants.getUserMerchants()
csharp
// VantagePay.SDK
var merchants = await client.Merchants.GetUserMerchantsAsync();

Switch to another merchant account that is linked to your user.

POST /v1/merchant/user/switch/{merchantReference}

Auth: Access token (Bearer).

Parameters

NameInRequiredDescription
merchantReferencepathYesA globally unique internal merchant reference (UUID).

Responses

StatusDescription
200The request was successful but does not return any results.
400The request failed validation, the error object will contain further information.
401The authorization information provided is not valid, authentication is required to access this resource.
403The authorization header does not contain the correct type or you do not have access to this resource.
422The request payload is invalid, the error object will contain further information.
429Too many requests are being sent concurrently or rate limiting has taken effect.
500An unexpected error occurred, the error object will contain further information.

Response body

FieldTypeRequiredDescription
successbooleanNoGets a value indicating whether the operation was successful.
resultobjectNoProvides token information for successful login and refresh operations.
json
{
  "success": true,
  "result": {
    "refreshToken": "string",
    "accessToken": "string",
    "accessTokenValidForSeconds": 0
  }
}

Code samples

ts
// @vantagepay/vantagepay
const tokens = await client.merchants.switchToMerchant('3fa85f64-5717-4562-b3fc-2c963f66afa6')
csharp
// VantagePay.SDK
var tokens = await client.Merchants.SwitchToMerchantAsync(Guid.Parse("3fa85f64-5717-4562-b3fc-2c963f66afa6"));

Payments for Africa