---
title: Request Access Token
slug: nicepay-api-snap-testing-request-access-token
description: Informasi tentang cara uji coba API SNAP - Request Access Token yang disediakan oleh NICEPAY
image: https://archbee-image-uploads.s3.amazonaws.com/ZHvSjR5ZrsoxwKbJa3xmo/sqF39yQXTu4eYJcwiDVwQ_rdrx9d8diaz-pgm07xfz2-test.png
docTags: 
createdAt: 2024-05-06T07:53:30.387Z
---

{
  "id": "Q7nh7Lloa6StyLcRfbiWx",
  "type": "api-oas-v2",
  "data": {
    "method": "POST",
    "url": "https://dev.nicepay.co.id/nicepay/v1.0/access-token/b2b",
    "servers": [
      {
        "url": "https://dev.nicepay.co.id/nicepay/v1.0/access-token/b2b"
      },
      {
        "url": "https://staging.nicepay.co.id/nicepay/v1.0/access-token/b2b"
      },
      {
        "url": "https://www.nicepay.co.id/nicepay/v1.0/access-token/b2b"
      }
    ],
    "name": "Request Access Token",
    "description": "",
    "contentType": "application/json",
    "request": {
      "pathParameters": [],
      "headerParameters": [
        {
          "kind": "required",
          "name": "X-SIGNATURE",
          "type": "string",
          "default": "icZEJ7mPLLNNs+DdQo94BnOl9ywU3LY1iU/OxMlB+sIwJr1OVGBWhhc1H8r033l3DZPuyWmhsm8TL4GbBlXsIAj92NYiNlG6mktfoDpYrdqzXgDMYLWKtrYiaai2wpelY+8KLP86iA6+LIE5gEpwSm7j8iFK6RTJKV12VEMszds="
        },
        {
          "kind": "required",
          "name": "X-CLIENT-KEY",
          "type": "string",
          "example": "IONPAYTEST"
        },
        {
          "kind": "required",
          "name": "X-TIMESTAMP",
          "type": "string",
          "example": "2022-08-04T23:59:59+07:00"
        }
      ],
      "queryParameters": [],
      "bodyDataParameters": [
        {
          "kind": "required",
          "name": "body",
          "type": "object",
          "example": "{\"grantType\":\"client_credentials\",\"additionalInfo\":{}}",
          "description": "",
          "customType": "b2b_body",
          "schema": [
            {
              "name": "grantType",
              "kind": "required",
              "type": "string",
              "example": "client_credentials"
            },
            {
              "name": "additionalInfo",
              "kind": "optional",
              "type": "object",
              "description": "",
              "example": "",
              "schema": []
            }
          ],
          "modelRef": "#/components/schemas/b2b_body",
          "complexItems": [
            {
              "name": "object",
              "schema": [
                {
                  "name": "grantType",
                  "kind": "required",
                  "type": "string",
                  "example": "client_credentials"
                },
                {
                  "name": "additionalInfo",
                  "kind": "optional",
                  "type": "object",
                  "description": "",
                  "example": "",
                  "schema": []
                }
              ],
              "modelRef": "#/components/schemas/Request-Access-Token",
              "customType": "Request-Access-Token"
            },
            {
              "name": "object",
              "schema": []
            }
          ],
          "complexType": "allOf",
          "isExpanded": true
        }
      ],
      "formDataParameters": [],
      "oAuthParameters": []
    },
    "responses": [
      {
        "statusCode": "200",
        "description": "Success",
        "jsonExample": "",
        "isExpanded": true,
        "subExamples": [
          {
            "label": "GENERATED",
            "code": "// Success\n{\n  \"responseCode\": \"2007300\",\n  \"responseMessage\": \"Successful\",\n  \"accessToken\": \"Xy8duZzAvv9bwDXxRxcb89tsuvk4MF4kx4lGfE4aCRVxR7XdERhbe1\",\n  \"tokenType\": \"Bearer\",\n  \"expiresIn\": \"900\"\n}"
          },
          {
            "label": "Successful",
            "code": "{\n  \"responseCode\": \"0000\",\n  \"responseMessage\": \"Successful\",\n  \"accessToken\": \"Xy8duZzAvv9bwDXxRxcb89tsuvk4MF4kx4lGfE4aCRVxR7XdERhbe1\",\n  \"tokenType\": \"Bearer\",\n  \"expiresIn\": \"900\"\n}"
          }
        ],
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "customType": "Success",
            "schema": [
              {
                "name": "responseCode",
                "kind": "optional",
                "type": "string",
                "description": "Response Code",
                "example": "2007300"
              },
              {
                "name": "responseMessage",
                "kind": "optional",
                "type": "string",
                "description": "Response Message",
                "example": "Successful"
              },
              {
                "name": "accessToken",
                "kind": "optional",
                "type": "string",
                "description": "A string representing an authorization issued to the client that used to access protected resources",
                "example": "Xy8duZzAvv9bwDXxRxcb89tsuvk4MF4kx4lGfE4aCRVxR7XdERhbe1"
              },
              {
                "name": "tokenType",
                "kind": "optional",
                "type": "string",
                "description": "The access token type",
                "example": "Bearer"
              },
              {
                "name": "expiresIn",
                "kind": "optional",
                "type": "string",
                "description": "Session expiry in seconds -> 900 (15 minutes)",
                "example": "900"
              }
            ],
            "modelRef": "#/components/schemas/Success",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "202",
        "description": "Request In Progress",
        "jsonExample": "",
        "isExpanded": true,
        "subExamples": [
          {
            "label": "GENERATED",
            "code": "// Request In Progress\n{\n  \"responseCode\": \"202XX00\",\n  \"responseMessage\": \"Request In Progress\"\n}"
          },
          {
            "label": "Request In Progress",
            "code": "{\n  \"responseCode\": \"202XX00\",\n  \"responseMessage\": \"Request In Progress\"\n}"
          }
        ],
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "customType": "RequestInProgress",
            "schema": [
              {
                "name": "responseCode",
                "kind": "optional",
                "type": "string",
                "description": "Response Code",
                "example": "202XX00"
              },
              {
                "name": "responseMessage",
                "kind": "optional",
                "type": "string",
                "description": "Response Message",
                "example": "Request In Progress"
              }
            ],
            "modelRef": "#/components/schemas/RequestInProgress",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "401",
        "description": "Unauthorized [reason]",
        "jsonExample": "",
        "isExpanded": true,
        "subExamples": [
          {
            "label": "GENERATED",
            "code": "// Unauthorized [reason]\n{\n  \"responseCode\": \"401XX00\",\n  \"responseMessage\": \"Unauthorized [reason]\"\n}"
          },
          {
            "label": "Unauthorized [reason]",
            "code": "{\n  \"responseCode\": \"401XX00\",\n  \"responseMessage\": \"Unauthorized [reason]\"\n}"
          },
          {
            "label": "Access Token Invalid",
            "code": "{\n  \"responseCode\": \"401XX01\",\n  \"responseMessage\": \"Access Token Invalid\"\n}"
          }
        ],
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "customType": "UnauthorizedReason",
            "schema": [
              {
                "name": "responseCode",
                "kind": "optional",
                "type": "string",
                "description": "Response Code",
                "example": "401XX00"
              },
              {
                "name": "responseMessage",
                "kind": "optional",
                "type": "string",
                "description": "Response Message",
                "example": "Unauthorized [reason]"
              }
            ],
            "modelRef": "#/components/schemas/UnauthorizedReason",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "409",
        "description": "Duplicate partnerReferenceNo",
        "jsonExample": "",
        "isExpanded": true,
        "subExamples": [
          {
            "label": "GENERATED",
            "code": "// Duplicate partnerReferenceNo\n{\n  \"responseCode\": \"409XX01\",\n  \"responseMessage\": \"Duplicate partnerReferenceNo\"\n}"
          },
          {
            "label": "Duplicate partnerReferenceNo",
            "code": "{\n  \"responseCode\": \"409XX01\",\n  \"responseMessage\": \"Duplicate partnerReferenceNo\"\n}"
          }
        ],
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "customType": "DuplicatePartnerReferenceNo",
            "schema": [
              {
                "name": "responseCode",
                "kind": "optional",
                "type": "string",
                "description": "Response Code",
                "example": "409XX01"
              },
              {
                "name": "responseMessage",
                "kind": "optional",
                "type": "string",
                "description": "Response Message",
                "example": "Duplicate partnerReferenceNo"
              }
            ],
            "modelRef": "#/components/schemas/DuplicatePartnerReferenceNo",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "500",
        "description": "General Error",
        "jsonExample": "",
        "isExpanded": true,
        "subExamples": [
          {
            "label": "GENERATED",
            "code": "// General Error\n{\n  \"responseCode\": \"500XX00\",\n  \"responseMessage\": \"General Error\"\n}"
          },
          {
            "label": "General Error",
            "code": "{\n  \"responseCode\": \"500XX00\",\n  \"responseMessage\": \"General Error\"\n}"
          }
        ],
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "customType": "GeneralError",
            "schema": [
              {
                "name": "responseCode",
                "kind": "optional",
                "type": "string",
                "description": "Response Code",
                "example": "500XX00"
              },
              {
                "name": "responseMessage",
                "kind": "optional",
                "type": "string",
                "description": "Response Message",
                "example": "General Error"
              }
            ],
            "modelRef": "#/components/schemas/GeneralError",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "504",
        "description": "Request Timeout",
        "jsonExample": "",
        "isExpanded": true,
        "subExamples": [
          {
            "label": "GENERATED",
            "code": "// Request Timeout\n{\n  \"responseCode\": \"504XX00\",\n  \"responseMessage\": \"Request Timeout\"\n}"
          },
          {
            "label": "Request Timeout",
            "code": "{\n  \"responseCode\": \"504XX00\",\n  \"responseMessage\": \"Request Timeout\"\n}"
          }
        ],
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "customType": "RequestTimeout",
            "schema": [
              {
                "name": "responseCode",
                "kind": "optional",
                "type": "string",
                "description": "Response Code",
                "example": "504XX00"
              },
              {
                "name": "responseMessage",
                "kind": "optional",
                "type": "string",
                "description": "Response Message",
                "example": "Request Timeout"
              }
            ],
            "modelRef": "#/components/schemas/RequestTimeout",
            "isExpanded": true
          }
        ]
      }
    ],
    "examples": {
      "languages": [
        {
          "id": "z8eb7hrH9HMKHNnofyNfG",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url https://dev.nicepay.co.id/nicepay/v1.0/access-token/b2b \\\n     --header 'accept: application/json' \\\n     --header 'content-type: application/json' \\\n     --header 'x-signature: icZEJ7mPLLNNs+DdQo94BnOl9ywU3LY1iU/OxMlB+sIwJr1OVGBWhhc1H8r033l3DZPuyWmhsm8TL4GbBlXsIAj92NYiNlG6mktfoDpYrdqzXgDMYLWKtrYiaai2wpelY+8KLP86iA6+LIE5gEpwSm7j8iFK6RTJKV12VEMszds=' \\\n     --header 'x-client-key: IONPAYTEST' \\\n     --header 'x-timestamp: 2022-08-04T23:59:59+07:00' \\\n     --data '{\n     \"grantType\": \"client_credentials\"\n     }'"
        },
        {
          "id": "9jnplL4JDu9sj2hiLbvrO",
          "language": "javascript",
          "label": "javascript",
          "code": "var myHeaders = new Headers();\nmyHeaders.append(\"accept\", \"application/json\");\nmyHeaders.append(\"content-type\", \"application/json\");\nmyHeaders.append(\"x-signature\", \"icZEJ7mPLLNNs+DdQo94BnOl9ywU3LY1iU/OxMlB+sIwJr1OVGBWhhc1H8r033l3DZPuyWmhsm8TL4GbBlXsIAj92NYiNlG6mktfoDpYrdqzXgDMYLWKtrYiaai2wpelY+8KLP86iA6+LIE5gEpwSm7j8iFK6RTJKV12VEMszds=\");\nmyHeaders.append(\"x-client-key\", \"IONPAYTEST\");\nmyHeaders.append(\"x-timestamp\", \"2022-08-04T23:59:59+07:00\");\n\nvar raw = JSON.stringify({\n   \"grantType\": \"client_credentials\"\n});\n\nvar requestOptions = {\n   method: 'POST',\n   headers: myHeaders,\n   body: raw,\n   redirect: 'follow'\n};\n\nfetch(\"https://dev.nicepay.co.id/nicepay/v1.0/access-token/b2b\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "58HNgK-jPbi9R8JP6PPgB",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://dev.nicepay.co.id/nicepay/v1.0/access-token/b2b\")\n\nhttps = Net::HTTP.new(url.host, url.port)\nhttps.use_ssl = true\n\nrequest = Net::HTTP::Post.new(url)\nrequest[\"accept\"] = \"application/json\"\nrequest[\"content-type\"] = \"application/json\"\nrequest[\"x-signature\"] = \"icZEJ7mPLLNNs+DdQo94BnOl9ywU3LY1iU/OxMlB+sIwJr1OVGBWhhc1H8r033l3DZPuyWmhsm8TL4GbBlXsIAj92NYiNlG6mktfoDpYrdqzXgDMYLWKtrYiaai2wpelY+8KLP86iA6+LIE5gEpwSm7j8iFK6RTJKV12VEMszds=\"\nrequest[\"x-client-key\"] = \"IONPAYTEST\"\nrequest[\"x-timestamp\"] = \"2022-08-04T23:59:59+07:00\"\nrequest.body = JSON.dump({\n   \"grantType\": \"client_credentials\"\n})\n\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "hL-1iRCI8FShYzZdJasMX",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://dev.nicepay.co.id/nicepay/v1.0/access-token/b2b\"\n\npayload = json.dumps({\n   \"grantType\": \"client_credentials\"\n})\nheaders = {\n   'accept': 'application/json',\n   'content-type': 'application/json',\n   'x-signature': 'icZEJ7mPLLNNs+DdQo94BnOl9ywU3LY1iU/OxMlB+sIwJr1OVGBWhhc1H8r033l3DZPuyWmhsm8TL4GbBlXsIAj92NYiNlG6mktfoDpYrdqzXgDMYLWKtrYiaai2wpelY+8KLP86iA6+LIE5gEpwSm7j8iFK6RTJKV12VEMszds=',\n   'x-client-key': 'IONPAYTEST',\n   'x-timestamp': '2022-08-04T23:59:59+07:00'\n}\n\nresponse = requests.request(\"POST\", url, headers=headers, data=payload)\n\nprint(response.text)\n"
        }
      ],
      "selectedLanguageId": "z8eb7hrH9HMKHNnofyNfG"
    },
    "results": {
      "languages": [
        {
          "id": "0XJUBbvaymuBBPzmD5Nyx",
          "language": "200",
          "code": "// Success\n{\n  \"responseCode\": \"2007300\",\n  \"responseMessage\": \"Successful\",\n  \"accessToken\": \"Xy8duZzAvv9bwDXxRxcb89tsuvk4MF4kx4lGfE4aCRVxR7XdERhbe1\",\n  \"tokenType\": \"Bearer\",\n  \"expiresIn\": \"900\"\n}",
          "subExamples": [
            {
              "label": "GENERATED",
              "code": "// Success\n{\n  \"responseCode\": \"2007300\",\n  \"responseMessage\": \"Successful\",\n  \"accessToken\": \"Xy8duZzAvv9bwDXxRxcb89tsuvk4MF4kx4lGfE4aCRVxR7XdERhbe1\",\n  \"tokenType\": \"Bearer\",\n  \"expiresIn\": \"900\"\n}"
            },
            {
              "label": "Successful",
              "code": "{\n  \"responseCode\": \"0000\",\n  \"responseMessage\": \"Successful\",\n  \"accessToken\": \"Xy8duZzAvv9bwDXxRxcb89tsuvk4MF4kx4lGfE4aCRVxR7XdERhbe1\",\n  \"tokenType\": \"Bearer\",\n  \"expiresIn\": \"900\"\n}"
            }
          ]
        },
        {
          "id": "EeGGjttS2DwTDKbuLKv7h",
          "language": "202",
          "code": "// Request In Progress\n{\n  \"responseCode\": \"202XX00\",\n  \"responseMessage\": \"Request In Progress\"\n}",
          "subExamples": [
            {
              "label": "GENERATED",
              "code": "// Request In Progress\n{\n  \"responseCode\": \"202XX00\",\n  \"responseMessage\": \"Request In Progress\"\n}"
            },
            {
              "label": "Request In Progress",
              "code": "{\n  \"responseCode\": \"202XX00\",\n  \"responseMessage\": \"Request In Progress\"\n}"
            }
          ]
        },
        {
          "id": "ioNPF7oQDuOyTPYJjg5Dm",
          "language": "401",
          "code": "// Unauthorized [reason]\n{\n  \"responseCode\": \"401XX00\",\n  \"responseMessage\": \"Unauthorized [reason]\"\n}",
          "subExamples": [
            {
              "label": "GENERATED",
              "code": "// Unauthorized [reason]\n{\n  \"responseCode\": \"401XX00\",\n  \"responseMessage\": \"Unauthorized [reason]\"\n}"
            },
            {
              "label": "Unauthorized [reason]",
              "code": "{\n  \"responseCode\": \"401XX00\",\n  \"responseMessage\": \"Unauthorized [reason]\"\n}"
            },
            {
              "label": "Access Token Invalid",
              "code": "{\n  \"responseCode\": \"401XX01\",\n  \"responseMessage\": \"Access Token Invalid\"\n}"
            }
          ]
        },
        {
          "id": "ZTeuHRsJW4B3id6ZnqWJV",
          "language": "409",
          "code": "// Duplicate partnerReferenceNo\n{\n  \"responseCode\": \"409XX01\",\n  \"responseMessage\": \"Duplicate partnerReferenceNo\"\n}",
          "subExamples": [
            {
              "label": "GENERATED",
              "code": "// Duplicate partnerReferenceNo\n{\n  \"responseCode\": \"409XX01\",\n  \"responseMessage\": \"Duplicate partnerReferenceNo\"\n}"
            },
            {
              "label": "Duplicate partnerReferenceNo",
              "code": "{\n  \"responseCode\": \"409XX01\",\n  \"responseMessage\": \"Duplicate partnerReferenceNo\"\n}"
            }
          ]
        },
        {
          "id": "Tf_jEWcvbwvqCPOgmmvMf",
          "language": "500",
          "code": "// General Error\n{\n  \"responseCode\": \"500XX00\",\n  \"responseMessage\": \"General Error\"\n}",
          "subExamples": [
            {
              "label": "GENERATED",
              "code": "// General Error\n{\n  \"responseCode\": \"500XX00\",\n  \"responseMessage\": \"General Error\"\n}"
            },
            {
              "label": "General Error",
              "code": "{\n  \"responseCode\": \"500XX00\",\n  \"responseMessage\": \"General Error\"\n}"
            }
          ]
        },
        {
          "id": "pWZ8ARepzLIOdDcfCxJYo",
          "language": "504",
          "code": "// Request Timeout\n{\n  \"responseCode\": \"504XX00\",\n  \"responseMessage\": \"Request Timeout\"\n}",
          "subExamples": [
            {
              "label": "GENERATED",
              "code": "// Request Timeout\n{\n  \"responseCode\": \"504XX00\",\n  \"responseMessage\": \"Request Timeout\"\n}"
            },
            {
              "label": "Request Timeout",
              "code": "{\n  \"responseCode\": \"504XX00\",\n  \"responseMessage\": \"Request Timeout\"\n}"
            }
          ]
        }
      ],
      "selectedLanguageId": "0XJUBbvaymuBBPzmD5Nyx"
    }
  },
  "children": [
    {
      "text": ""
    }
  ]
}