---
title: Generate access token
slug: payment/generate-access-token
description: Learn how to obtain an access token for managing payment initiation resources using the `/auth` endpoint. This document provides step-by-step instructions, a curl command example, and details on request method, headers, path parameters, and body parameter
docTags: 
createdAt: 2023-07-17T08:06:51.113Z
---

:::ApiMethodV2
```json
{
  "name": "auth",
  "method": "POST",
  "url": "https://api-sandbox.klavi.ai/payment/management/v1/auth",
  "description": "Use /auth endpoint by credentials to return a token and continue your process to manage payment initiation resources.\n",
  "tab": "examples",
  "examples": {
    "languages": [
      {
        "id": "YRd3_gYluSvxhgXABwO_e",
        "language": "curl",
        "code": "curl --location 'https://api-sandbox.klavi.ai/payment/management/v1/auth' \\\n--header 'Accept: application/json' \\\n--header 'Content-Type: application/json' \\\n--data '{\n  \"accessKey\": \"String\",\n  \"secretKey\": \"String\"\n}'",
        "customLabel": ""
      },
      {
        "id": "PFbb9H9RpTgIRX9duWQyh",
        "language": "nodejs",
        "code": "var request = require('request');\nvar options = {\n   'method': 'POST',\n   'url': 'https://api-sandbox.klavi.ai/payment/management/v1/auth',\n   'headers': {\n      'Accept': 'application/json',\n      'Content-Type': 'application/json'\n   },\n   body: JSON.stringify({\n      \"accessKey\": \"String\",\n      \"secretKey\": \"String\"\n   })\n\n};\nrequest(options, function (error, response) {\n   if (error) throw new Error(error);\n   console.log(response.body);\n});\n",
        "customLabel": ""
      },
      {
        "id": "S9zdjsIQgd3gqgEJfJoiA",
        "language": "javascript",
        "code": "var myHeaders = new Headers();\nmyHeaders.append(\"Accept\", \"application/json\");\nmyHeaders.append(\"Content-Type\", \"application/json\");\n\nvar raw = JSON.stringify({\n   \"accessKey\": \"String\",\n   \"secretKey\": \"String\"\n});\n\nvar requestOptions = {\n   method: 'POST',\n   headers: myHeaders,\n   body: raw,\n   redirect: 'follow'\n};\n\nfetch(\"https://api-sandbox.klavi.ai/payment/management/v1/auth\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));",
        "customLabel": ""
      },
      {
        "id": "znYDRAS1M7sC_7e7qwWUP",
        "language": "python",
        "code": "import requests\nimport json\n\nurl = \"https://api-sandbox.klavi.ai/payment/management/v1/auth\"\n\npayload = json.dumps({\n   \"accessKey\": \"String\",\n   \"secretKey\": \"String\"\n})\nheaders = {\n   'Accept': 'application/json',\n   'Content-Type': 'application/json'\n}\n\nresponse = requests.request(\"POST\", url, headers=headers, data=payload)\n\nprint(response.text)\n",
        "customLabel": ""
      },
      {
        "id": "GH0uYNRN9pnExFFvq9SXB",
        "language": "ruby",
        "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://api-sandbox.klavi.ai/payment/management/v1/auth\")\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.body = JSON.dump({\n   \"accessKey\": \"String\",\n   \"secretKey\": \"String\"\n})\n\nresponse = https.request(request)\nputs response.read_body\n",
        "customLabel": ""
      }
    ],
    "selectedLanguageId": "GH0uYNRN9pnExFFvq9SXB"
  },
  "results": {
    "languages": [
      {
        "id": "DRztsjwAFiFe-XBvzVBQ3",
        "language": "200",
        "customLabel": "",
        "code": "{\n    \"accessToken\": \"eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJwYXlsbLWdhdGV3YXkifQ.2dvWMBcU87IeX4J7S1_bx1uKHsXAvSDaK0RdV9xq3-OSrLA\",\n    \"expireAt\": 1752053847\n}"
      }
    ],
    "selectedLanguageId": "DRztsjwAFiFe-XBvzVBQ3"
  },
  "request": {
    "pathParameters": [],
    "queryParameters": [],
    "headerParameters": [],
    "bodyDataParameters": [
      {
        "name": "accessKey",
        "kind": "required",
        "type": "string",
        "description": "Access key",
        "": "Access key"
      },
      {
        "name": "secretKey",
        "kind": "required",
        "type": "string",
        "description": "Secret key",
        "": "Secret key"
      }
    ],
    "formDataParameters": []
  },
  "currentNewParameter": {
    "label": "Body Parameter",
    "value": "bodyDataParameters"
  },
  "response": [
    {
      "name": "accessToken",
      "kind": "optional",
      "type": "string",
      "description": "Access token"
    },
    {
      "name": "expireAt",
      "kind": "optional",
      "type": "string",
      "description": "Expire time stamp of the accessToken(UTC)",
      "children": []
    }
  ],
  "hasTryItOut": false,
  "autoGeneratedAnchorSlug": "auth",
  "legacyHash": "LqFp9V6ujlLX6EfmP5m_c"
}
```
:::



