> ## Documentation Index
> Fetch the complete documentation index at: https://docs-staging.termii.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Verify Token

> Verify token API, checks tokens sent to customers and returns a response confirming the status of the token. A token can either be confirmed as verified or expired based on the timer set for the token.

**Endpoint:** `https://BASE_URL/api/sms/otp/verify`

**Request Type:** `POST`

**Sample Response:**

| Options  | Required | Description                                                                                          |
| -------- | -------- | ---------------------------------------------------------------------------------------------------- |
| api\*key | yes      | \_string\* <br /> Your API key (It can be found on your [Termii dashboard](https://api.termii.com)). |
| pin\*id  | yes      | \_string\* <br /> ID of the PIN sent (Example: `"c8dcd048-5e7f-4347-8c89-4470c3af0b"`)               |
| pin      | yes      | *string* <br /> The PIN code (Example: `"195558"`)                                                   |

This API requires a numeric or alphanumeric token to have been sent out to a customer. It collects this token when inputed by the user and confirms its status.

<CodeGroup>
  ```json JSON theme={null}
  {
  "api_key": "Your API key",
  "pin_id": "c8dcd048-5e7f-4347-8c89-4470c3af0b",
  "pin": "195558"
  }
  ```

  ```json JavaScript theme={null}
  var data = {
           "api_key": "Your API key",
           "pin_id": "c8dcd048-5e7f-4347-8c89-4470c3af0b",
           "pin": "195558"
       };

  var data = JSON.stringify(data);

  var xhr = new XMLHttpRequest();
  xhr.withCredentials = true;

  xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
  console.log(this.responseText);
  }
  });

  xhr.open("POST", "https://BASE_URL/api/sms/otp/verify");
  xhr.setRequestHeader("Content-Type", "application/json");
  xhr.setRequestHeader("Content-Type", "application/json");

  xhr.send(data);
  ```

  ```json NodeJs theme={null}

  var request = require('request');
  var data = {
  "api_key": "Your API key",
  "pin_id": "c8dcd048-5e7f-4347-8c89-4470c3af0b",
  "pin": "195558"
  };
  var options = {
  'method': 'POST',
  'url': 'https://BASE_URL/api/sms/otp/verify',
  'headers': {
  'Content-Type': ['application/json', 'application/json']
  },
  body: JSON.stringify(data)

  };
  request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
  });
  ```

  ```json Python theme={null}

  import requests
  url = "https://BASE_URL/api/sms/otp/verify"
  payload = {
        "api_key": "Your API Key",
        "pin_id": "NUMERIC",
        "pin": "2348109477743",
     }
  headers = {
  'Content-Type': 'application/json',
  }
  response = requests.request("POST", url, headers=headers, json=payload)
  print(response.text)
  ```

  ```json C# theme={null}
  RestClient restClient = new RestClient("https://BASE_URL/api/sms/otp/verify");

  //Creating Json object
  JObject objectBody = new JObject();
  objectBody.Add("api_key","Your API Key");
  objectBody.Add("pin_id","c8dcd048-5e7f-4347-8c89-4470c3af0b");
  objectBody.Add("pin","195558");

  RestRequest restRequest = new RestRequest(Method.POST);

  restRequest.AddHeader("Content-Type", "application/json");
  restRequest.AddParameter("application/json", objectBody, ParameterType.RequestBody);
  IRestResponse restResponse = restClient.Execute(restRequest);
  Console.WriteLine(restResponse.Content);  
  ```

  ```json Java theme={null}

  Unirest.setTimeouts(0, 0);
  HttpResponse<String> response = Unirest.post("https://BASE_URL/api/sms/otp/verify")
  .header("Content-Type", "application/json")
  .body("{\r\n \"api_key\": \"Your API key\",\r\n \"pin_id\": \"c8dcd048-5e7f-4347-8c89-4470c3af0b\",\r\n \"pin\": \"195558\"\r\n\t}")
  .asString();
  ```

  ```json Php theme={null}

  $curl = curl_init();
  $data = array ( "api_key" => "Your API key",
  "pin_id" => "NUMERIC",
  "pin" => "eg. 2348109077743",
  );

  $post_data = json_encode($data);

  curl_setopt_array($curl, array(
  CURLOPT_URL => "https://BASE_URL/api/sms/otp/verify",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => $post_data,
  CURLOPT_HTTPHEADER => array(
  "Content-Type: application/json"
  ),
  ));

  $response = curl_exec($curl);

  curl_close($curl);
  echo $response;
  ```
</CodeGroup>

**Sample Response:**

```
   {
     "pinId": "c8dcd048-5e7f-4347-8c89-4470c3af0b",
     "verified": "True",
     "msisdn": "2348109077743"
   }
```
