Singapay Home Page
Logo Icon
  1. Security
  2. Get Access Token

Information

MethodPathFormatAuthentication
POST/api/v1.0/access-token/b2bjsonBasic Auth

Request Details

When making a request to obtain an access token using the Get Access Token endpoint, several key pieces of information are required. These details are crucial for successful authentication and access to the API resources.

Headers Structure

FieldValueTypeMandatoryLengthDescriptionExample
X-PARTNER-IDAlphanumericMandatory-api_key (please check in merchant dashboard)b3ed7d4b-a96c-6c08-b3c7-12c3124242d9
Acceptapplication/jsonAlphabeticMandatory-Give back response with JSON format
AuthorizationBasic [base64 encoded value]AlphanumericMandatory-base64 encoded value = base64_encode(clientId+”:”+secretClientId)Basic am9obkBleGFtcGxlLmNvbTphYmMxMjM=

Body Structure

FieldValueTypeMandatoryLengthDescriptionExample
grantTypeclient_credentialsAlphabeticMandatory---

Body Example

{
  "grantType": "client_credentials"
}

Response Details

The response section provides details about the response received from the server after making a request to obtain an access token using the Get Access Token endpoint. It includes information such as the HTTP status code, headers, and the body of the response. Understanding the response is crucial for handling authentication errors, successful token retrieval, and accessing API resources securely.

Response Structure

FieldTypeMandatoryLengthDescriptionExample
statusNumericMandatory3HTTP Status Code200
successBooleanMandatory1Indicates if the request was successfultrue
dataObjectConditional-Contains additional data (if available)-
> access_tokenAlphanumericMandatory344JWT TokeneyJ0eXAiOiJKV1Qi{…}
> token_typeAlphabeticMandatory-Type of tokenBearer
> expires_inNumericMandatory-Session duration in seconds3600

Response Example

Success: Here’s an example of a successful response.

{
  "status": 200,
  "success": true,
  "data": {
    "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9{...}",
    "token_type": "Bearer",
    "expires_in": "3600"
  }
}

Error: This is an example of an unsuccessful request.

{
  "status": 401,
  "success": false,
  "error": {
    "code": 401,
    "message": "Invalid credentials"
  }
}