> ## 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.

# Voice Token

> The voice token API enables you to generate and trigger one-time passwords (OTP) through the voice channel to a phone number. OTPs are generated and sent to the phone number and can only be verified using our Verify Token API.

**Endpoint:** `https://BASE_URL/api/sms/otp/send/voice`

**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)).                                                                         |
| phone\*number       | yes      | \_string\* <br /> The destination phone number. Phone number must be in the international format (Example: `23490126727`)                                                    |
| pin\*attempts       | yes      | Enum: `"NUMERIC"` `"ALPHANUMERIC"` Type of PIN code that will be generated and sent as part of the OTP message. It has a minimum of one attempt.                             |
| pin\_time\_to\_live | yes      | \_integer\* <br /> Example: `1` Represents how long the PIN is valid before expiration. The time is in minutes. The minimum time value is 0 and the maximum time value is 60 |
| pin\*length         | yes      | \_integer\* <br /> Example: `4`                                                                                                                                              |

<CodeGroup>
  ```json JSON theme={null}
  {
   "api_key" : "Your API key",
   "phone_number" : "23409800000000",
   "pin_attempts" : 10,
   "pin_time_to_live" :  5,
   "pin_length" : 6,
  }
  ```

  ```json JavaScript theme={null}
  var data = {
           "api_key" : "Your API key",
           "phone_number" : "23409800000000",
           "pin_attempts" : 10,
           "pin_time_to_live" :  5,
           "pin_length" : 6,
    };

  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/send/voice");
  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",
  "phone_number" : "23409800000000",
  "pin_attempts" : 10,
  "pin_time_to_live" : 5,
  "pin_length" : 6,
  };
  var options = {
  'method': 'POST',
  'url': 'https://BASE_URL/api/sms/otp/send/voice',
  '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/send/voice"
  payload = {
         "api_key" : "Your API key",
         "phone_number" : "23409800000000",
         "pin_attempts" : 10,
         "pin_time_to_live" :  5,
         "pin_length" : 6,
     }
  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/send/voice");

  //Creating Json object
  JObject objectBody = new JObject();
  objectBody.Add("api_key","Your API Key");
  objectBody.Add("phone_number","+2348109077743");
  objectBody.Add("pin_attempts", 3);
  objectBody.Add("pin_time_to_live", 0);
  objectBody.Add("pin_length", 6);

  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.get("https://BASE_URL/api/sms/otp/send/voice")
  .header("Content-Type", "application/json")
  .body("{\n\n \"api_key\" : \"Your API key\",\n  
  \"phone_number\" : \"23409800000000\",\n  
  \"pin_attempts\" : 10,\n \"pin_time_to_live\" : 5,\n  
  \"pin_length\" : 6\n\n}")
  .asString();
  ```

  ```json Php theme={null}

  <?php

  $curl = curl_init();

  curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://BASE_URL/api/sms/otp/send/voice',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_POSTFIELDS =>'{

   "api_key" : "Your API key",
   "phone_number" : "23409800000000",
   "pin_attempts" : 10,
   "pin_time_to_live" :  5,
   "pin_length" : 6

  }',
  CURLOPT_HTTPHEADER => array(
  'Content-Type: application/json'
  ),
  ));

  $response = curl_exec($curl);

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

**Sample Response:**

```
  {
     "code": "ok",
     "message_id": "453166532802459832",
     "pinId": "29ae67c2-c8e1-4165-8a51-8d3d7c298081",
     "message": "Successfully Sent",
     "balance": 77.5,
     "user": "Termii Test"
  }
```
