---
title: OTP Status and Validation
slug: singleconnect-2-16/otp-status-and-validation
description: Learn about the otpStatus and otpValid methods in this document, which explain how to check the activation status and validity of a one-time password (OTP). Discover how the otpStatus method generates a valid OTP value if it is active, while the otpValid 
docTags: 
createdAt: 2022-01-05T08:33:35.000Z
---

- In order to send otpValid request, otpStatus must be called first.&#x20;
- otpStatus method returns true, otpValid should be sent.&#x20;
  otpStatus asks whether otp is active or inactive for the user, if otp is active this method generate valid OTP value then returned true response

:::ApiMethodV2
```json
{
  "tab": "examples",
  "url": "https://{{hostname}}/twofactorauth-ui/rest/tfa/otpStatus",
  "name": "otpStatus",
  "method": "POST",
  "request": {
    "pathParameters": [],
    "queryParameters": [],
    "headerParameters": [],
    "bodyDataParameters": [],
    "formDataParameters": []
  },
  "results": {
    "languages": [
      {
        "id": "Wp-ZHKlY-l-snkilBnSQu",
        "code": "true --> Comment: user otp status is opened\r\nfalse --> Comment: user otp status is closed",
        "language": "200"
      }
    ],
    "selectedLanguageId": "Wp-ZHKlY-l-snkilBnSQu"
  },
  "examples": {
    "languages": [
      {
        "id": "7rWED8LYMVfY4hXyKHqBO",
        "code": "var client = new RestClient(\"https://{{hostname}}/twofactorauth-ui/rest/tfa/otpStatus\");\r\nclient.Timeout = -1;\r\nvar request = new RestRequest(Method.POST);\r\nrequest.AddHeader(\"Content-Type\", \"application/x-www-form-urlencoded\");\r\nrequest.AddHeader(\"Cookie\", \"NETRIGHT_SESSIONID=8f118fa5-1d0a-433e-97b3-56dfec482b22; XSRF-TOKEN=314cf821ce6395572ecd5ce8858bad3a\");\r\nrequest.AddParameter(\"username\", \"batuhan.tests\");\r\nrequest.AddParameter(\"endUserIp\", \"1.2.3.4\");\r\nrequest.AddParameter(\"applicationName\", \"BatuhanBilginDeneme\");\r\nIRestResponse response = client.Execute(request);\r\nConsole.WriteLine(response.Content);",
        "language": "csharp"
      },
      {
        "id": "QafKPJc0Ua3PdvMi6hxuU",
        "code": "curl --location --request POST 'https://{{hostname}}/twofactorauth-ui/rest/tfa/otpStatus' \\\n--header 'Content-Type: application/x-www-form-urlencoded' \\\n--header 'Cookie: NETRIGHT_SESSIONID=8f118fa5-1d0a-433e-97b3-56dfec482b22; XSRF-TOKEN=314cf821ce6395572ecd5ce8858bad3a' \\\n--data-urlencode 'username=batuhan.test' \\\n--data-urlencode 'endUserIp=1.2.3.4' \\\n--data-urlencode 'applicationName=BatuhanBilginDeneme'",
        "language": "curl",
        "customLabel": ""
      },
      {
        "id": "Ylmfiuhrufpp0O_0qqQy0",
        "code": "var settings = {\r\n  \"url\": \"https://{{hostname}}/twofactorauth-ui/rest/tfa/otpStatus\",\r\n  \"method\": \"POST\",\r\n  \"timeout\": 0,\r\n  \"headers\": {\r\n    \"Content-Type\": \"application/x-www-form-urlencoded\",\r\n    \"Cookie\": \"NETRIGHT_SESSIONID=8f118fa5-1d0a-433e-97b3-56dfec482b22; XSRF-TOKEN=314cf821ce6395572ecd5ce8858bad3a\"\r\n  },\r\n  \"data\": {\r\n    \"username\": \"batuhan.tests\",\r\n    \"endUserIp\": \"1.2.3.4\",\r\n    \"applicationName\": \"BatuhanBilginDeneme\"\r\n  }\r\n};\r\n\r\n$.ajax(settings).done(function (response) {\r\n  console.log(response);\r\n});",
        "language": "javascript"
      }
    ],
    "selectedLanguageId": "7rWED8LYMVfY4hXyKHqBO"
  },
  "description": "otpStatus",
  "currentNewParameter": {
    "label": "Body Parameter",
    "value": "bodyDataParameters"
  }
}
```
:::




:::ApiMethodV2
```json
{
  "tab": "examples",
  "url": "https://{{hostname}}/twofactorauth-ui/rest/tfa/otpValid",
  "name": "otpValid",
  "method": "POST",
  "request": {
    "pathParameters": [],
    "queryParameters": [],
    "headerParameters": [],
    "bodyDataParameters": [],
    "formDataParameters": []
  },
  "results": {
    "languages": [
      {
        "id": "3XFrftxMAvDEOY3fEG2y1",
        "code": " Comment: otp is valid",
        "language": "200"
      },
      {
        "id": "IZTEZgqR5rsZlF3B1bBZF",
        "code": "<!doctype html> --> Comment: otp is not valid \r\n<html lang=\"en\">\r\n\r\n<head>\r\n\t<title>HTTP Status 403 – Forbidden</title>\r\n\t<style type=\"text/css\">\r\n\t\tbody {\r\n\t\t\tfont-family: Tahoma, Arial, sans-serif;\r\n\t\t}\r\n\r\n\t\th1,\r\n\t\th2,\r\n\t\th3,\r\n\t\tb {\r\n\t\t\tcolor: white;\r\n\t\t\tbackground-color: #525D76;\r\n\t\t}\r\n\r\n\t\th1 {\r\n\t\t\tfont-size: 22px;\r\n\t\t}\r\n\r\n\t\th2 {\r\n\t\t\tfont-size: 16px;\r\n\t\t}\r\n\r\n\t\th3 {\r\n\t\t\tfont-size: 14px;\r\n\t\t}\r\n\r\n\t\tp {\r\n\t\t\tfont-size: 12px;\r\n\t\t}\r\n\r\n\t\ta {\r\n\t\t\tcolor: black;\r\n\t\t}\r\n\r\n\t\t.line {\r\n\t\t\theight: 1px;\r\n\t\t\tbackground-color: #525D76;\r\n\t\t\tborder: none;\r\n\t\t}\r\n\t</style>\r\n</head>\r\n\r\n<body>\r\n\t<h1>HTTP Status 403 – Forbidden</h1>\r\n</body>\r\n\r\n</html>",
        "language": "403"
      }
    ],
    "selectedLanguageId": "3XFrftxMAvDEOY3fEG2y1"
  },
  "examples": {
    "languages": [
      {
        "id": "lI3k4LMubtUt4FguzK9qf",
        "code": "var client = new RestClient(\"https://{{hostname}}/twofactorauth-ui/rest/tfa/otpValid\");\r\nclient.Timeout = -1;\r\nvar request = new RestRequest(Method.POST);\r\nrequest.AddHeader(\"Content-Type\", \"application/x-www-form-urlencoded\");\r\nrequest.AddHeader(\"Cookie\", \"NETRIGHT_SESSIONID=8f118fa5-1d0a-433e-97b3-56dfec482b22; XSRF-TOKEN=314cf821ce6395572ecd5ce8858bad3a\");\r\nrequest.AddParameter(\"username\", \"batuhan.test\");\r\nrequest.AddParameter(\"token\", \"489375\");\r\nrequest.AddParameter(\"applicationName\", \"BatuhanBilginDeneme\");\r\nIRestResponse response = client.Execute(request);\r\nConsole.WriteLine(response.Content);",
        "language": "csharp"
      },
      {
        "id": "hpOzZli7nPkOtBN1CWlZ5",
        "code": "curl --location --request POST 'https://{{hostname}}/twofactorauth-ui/rest/tfa/otpValid' \\\r\n--header 'Content-Type: application/x-www-form-urlencoded' \\\r\n--header 'Cookie: NETRIGHT_SESSIONID=8f118fa5-1d0a-433e-97b3-56dfec482b22; XSRF-TOKEN=314cf821ce6395572ecd5ce8858bad3a' \\\r\n--data-urlencode 'username=batuhan.test' \\\r\n--data-urlencode 'token=489375' \\\r\n--data-urlencode 'applicationName=BatuhanBilginDeneme'",
        "language": "curl"
      },
      {
        "id": "HMikY7FvL9PsQX25IhscC",
        "code": "var settings = {\n  \"url\": \"https://{{hostname}}/twofactorauth-ui/rest/tfa/otpValid\",\n  \"method\": \"POST\",\n  \"timeout\": 0,\n  \"headers\": {\n    \"Content-Type\": \"application/x-www-form-urlencoded\",\n    \"Cookie\": \"NETRIGHT_SESSIONID=8f118fa5-1d0a-433e-97b3-56dfec482b22; XSRF-TOKEN=314cf821ce6395572ecd5ce8858bad3a\"\n  },\n  \"data\": {\n    \"username\": \"batuhan.test\",\n    \"token\": \"296242\",\n    \"applicationName\": \"BatuhanBilginDeneme\"\n  }\n};\n\n$.ajax(settings).done(function (response) {\n  console.log(response);\n});",
        "language": "javascript"
      }
    ],
    "selectedLanguageId": "lI3k4LMubtUt4FguzK9qf"
  },
  "description": "otpValid",
  "currentNewParameter": {
    "label": "Body Parameter",
    "value": "bodyDataParameters"
  }
}
```
:::







