---
title: Validate OTP
slug: kron-pam-api-collection-381-patch3/validate-otp
docTags: 
createdAt: 2026-10-21T06:07:16.182Z
---

{
  "id": "_qG9zBENwUUO7d7QNXt0W",
  "type": "api-oas-v2",
  "data": {
    "method": "POST",
    "url": "{{url}}/aioc-rest-web/rest/tfa/otpValid",
    "name": "",
    "description": "<h3>Request Overview</h3>\n<p>The <strong>Validate OTP</strong> method is used to verify the One Time Password (OTP) provided by a user.</p>\n<h4>Usage:</h4>\n<ul>\n<li>\n<p>Enter the <code>username</code> and <code>token</code> (OTP) in the request body.</p>\n</li>\n<li>\n<p>Ensure the request body is URL Encoded.</p>\n</li>\n</ul>\n<p>This method confirms the validity of the OTP for the specified user, ensuring secure access.</p>",
    "contentType": "application/json",
    "request": {
      "headerParameters": [
        {
          "name": "Content-Type",
          "description": "",
          "default": "application/x-www-form-urlencoded",
          "value": "application/x-www-form-urlencoded",
          "type": "string"
        },
        {
          "name": "X-XSRF-TOKEN",
          "description": "",
          "default": "{{csrftoken}}",
          "value": "{{csrftoken}}",
          "type": "string"
        }
      ],
      "queryParameters": [],
      "pathParameters": [
        {
          "name": "url",
          "description": "",
          "default": "url",
          "value": "url",
          "type": "string"
        }
      ],
      "bodyDataParameters": [],
      "formDataParameters": [
        {
          "name": "username",
          "description": "",
          "default": "{{TestUserName}}",
          "value": "{{TestUserName}}",
          "type": "string"
        },
        {
          "name": "token",
          "description": "",
          "default": "183942",
          "value": "183942",
          "type": "string"
        },
        {
          "name": "ignoreUsedBefore",
          "description": "this field allows a token to be used multiple times in validity time period. The field takes \"true\" or \"false\" values",
          "default": "true",
          "value": "true",
          "type": "string"
        }
      ],
      "oAuthParameters": []
    },
    "responses": [
      {
        "statusCode": "200",
        "description": "Validate OTP",
        "jsonExample": ""
      }
    ],
    "examples": {
      "languages": [
        {
          "id": "6ST5WyhU1mTI_sjEuDGH2",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url {{url}}/aioc-rest-web/rest/tfa/otpValid \\\n     --header 'accept: application/json' \\\n     --header 'content-type: application/x-www-form-urlencoded' \\\n     --header 'x-xsrf-token: {{csrftoken}}' \\\n     --form 'username=\"{{TestUserName}}\"' \\\n     --form 'token=\"183942\"' \\\n     --form 'ignoreUsedBefore=\"true\"'"
        },
        {
          "id": "XGhpiYvCnV-nPoYQZ0GOF",
          "language": "javascript",
          "label": "javascript",
          "code": "var myHeaders = new Headers();\nmyHeaders.append(\"accept\", \"application/json\");\nmyHeaders.append(\"content-type\", \"application/x-www-form-urlencoded\");\nmyHeaders.append(\"x-xsrf-token\", \"{{csrftoken}}\");\n\nvar formdata = new FormData();\nformdata.append(\"username\", \"{{TestUserName}}\");\nformdata.append(\"token\", \"183942\");\nformdata.append(\"ignoreUsedBefore\", \"true\");\n\nvar requestOptions = {\n   method: 'POST',\n   headers: myHeaders,\n   body: formdata,\n   redirect: 'follow'\n};\n\nfetch(\"{{url}}/aioc-rest-web/rest/tfa/otpValid\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "5li837H-GLwQwGsi-oH5w",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"net/http\"\n\nurl = URI(\"{{url}}/aioc-rest-web/rest/tfa/otpValid\")\n\nhttp = Net::HTTP.new(url.host, url.port);\nrequest = Net::HTTP::Post.new(url)\nrequest[\"accept\"] = \"application/json\"\nrequest[\"content-type\"] = \"application/x-www-form-urlencoded\"\nrequest[\"x-xsrf-token\"] = \"{{csrftoken}}\"\nform_data = [['username', File.open('undefined')],['token', File.open('undefined')],['ignoreUsedBefore', File.open('undefined')]]\nrequest.set_form form_data, 'multipart/form-data'\nresponse = http.request(request)\nputs response.read_body\n"
        },
        {
          "id": "Lq_oQ6V6OpQ5I8w8MDMmK",
          "language": "python",
          "label": "Python",
          "code": "import requests\n\nurl = \"{{url}}/aioc-rest-web/rest/tfa/otpValid\"\n\npayload = {}\nfiles=[\n\n]\nheaders = {\n   'accept': 'application/json',\n   'content-type': 'application/x-www-form-urlencoded',\n   'x-xsrf-token': '{{csrftoken}}'\n}\n\nresponse = requests.request(\"POST\", url, headers=headers, data=payload, files=files)\n\nprint(response.text)\n"
        }
      ],
      "selectedLanguageId": "6ST5WyhU1mTI_sjEuDGH2"
    },
    "results": {
      "languages": [
        {
          "id": "4wkdKBr_DOQTO3GWxjQaz",
          "language": "200",
          "code": "// Validate OTP\n"
        }
      ],
      "selectedLanguageId": "4wkdKBr_DOQTO3GWxjQaz"
    }
  },
  "children": [
    {
      "text": ""
    }
  ]
}