# Verify API

#### **Two factor authentication (2FA) via SMS**

Verify API DecisionTelecom позволяет подтвердить номер мобильного телефона с помощью двухфакторной аутентификации. Создайте новый объект Verify через API, чтобы начать процесс проверки получателя. DecisionTelecom позаботится о создании токена и обеспечении доставки сообщения получателю.

Verify API использует HTTPS с ключом доступа, который используется в качестве авторизации API. Полезные данные запросов и ответов форматируются как JSON с использованием кодировки UTF-8 и значений в кодировке URL.

**API Авторизация** - Базовый ключ доступа Base64.

Чтобы получить ключ API, пожалуйста, свяжитесь с вашим менеджером по работе с клиентами.

## Отправить верификацию&#x20;

{% tabs %}
{% tab title="POST REQUEST json string" %}

```
string https://web.it-decision.com/v1/api/two-factor-auth
```

{% endtab %}
{% endtabs %}

```json
{
    "phone":380776557788,
    "pin_length":4,
    "template_id":0,
    "country_iso":"en"
}
```

#### **Response:**

```json
{
    "id": 34234234,
    "phone": 380776557788,
    "href": "https://web.it-decision.com/api/get-pin?id=34234234",
    "status": "ACCEPTD"
}
```

#### Параметры:

**Id** <mark style="color:red;">int</mark> - уникальный случайный идентификатор, который создается на платформе DecisionTelecom. – Обязательный.

**phone** <mark style="color:red;">int</mark> - номер телефона, по которому вы хотите сделать запрос. – Обязательный.

**pin\_lenght** <mark style="color:red;">int</mark> - длина пин-кода, от 4 до 10 цифр. – Опционально, по умолчанию 4.

**templete\_id** <mark style="color:red;">int</mark> - по умолчанию 0 (текст сообщения шаблона: ваш проверочный код: \d{4,10}) — Обязательный.

**country\_iso** <mark style="color:red;">string</mark> - Опционально, по умолчанию «en».

## Проверка PIN-кода

{% tabs %}
{% tab title="GET REQUEST" %}

```
 https://web.it-decision.com/v1/api/get-pin?id=34234234
```

{% endtab %}
{% endtabs %}

#### Response:

```json
{
    "id": 34234234,
    "phone": 380776557788,
    "pin": 4323
}
```

Вам остается лишь сверить значения пин-кода, которое пользователь введет у вас при верификации и которое мы возвращаем вам в ответе. Если они совпадают значит верификация пройдена успешно.

## Примеры Verify

{% tabs %}
{% tab title="cUrl" %}

```
curl --location --request POST 'https://web.it-decision.com/v1/api/two-factor-auth' \
--header 'Authorization: Basic api key' \
--header 'Content-Type: application/json' \
--data-raw '{"phone":380631211121,"pin_length":10,"template_id":0,"country_iso":"en"}'

```

{% endtab %}

{% tab title="Golang" %}

```
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://web.it-decision.com/v1/api/two-factor-auth"
  method := "POST"

  payload := strings.NewReader(`{"phone":380631211121,"pin_length":10,"template_id":0,"country_iso":"en"}`)

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("Authorization", "Basic api key")
  req.Header.Add("Content-Type", "application/json")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := ioutil.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}

```

{% endtab %}

{% tab title="Java" %}

```
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"phone\":380631211121,\"pin_length\":10,\"template_id\":0,\"country_iso\":\"en\"}");
Request request = new Request.Builder()
  .url("https://web.it-decision.com/v1/api/two-factor-auth")
  .method("POST", body)
  .addHeader("Authorization", "Basic api key")
  .addHeader("Content-Type", "application/json")
  .build();
Response response = client.newCall(request).execute();

```

{% endtab %}

{% tab title="JavaScript" %}

```
var myHeaders = new Headers();
myHeaders.append("Authorization", "Basic api key");
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({
  "phone": 380631211121,
  "pin_length": 10,
  "template_id": 0,
  "country_iso": "en"
});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://web.it-decision.com/v1/api/two-factor-auth", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

```

{% endtab %}

{% tab title="C#" %}

```
var client = new RestClient("https://web.it-decision.com/v1/api/two-factor-auth");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Basic api key");
request.AddHeader("Content-Type", "application/json");
var body = @"{""phone"":380631211121,""pin_length"":10,""template_id"":0,""country_iso"":""en""}";
request.AddParameter("application/json", body,  ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);

```

{% endtab %}

{% tab title="C – libcUrl" %}

```
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
  curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
  curl_easy_setopt(curl, CURLOPT_URL, "https://web.it-decision.com/v1/api/two-factor-auth");
  curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
  curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https");
  struct curl_slist *headers = NULL;
  headers = curl_slist_append(headers, "Authorization: Basic api key");
  headers = curl_slist_append(headers, "Content-Type: application/json");
  curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
  const char *data = "{\"phone\":380631211121,\"pin_length\":10,\"template_id\":0,\"country_iso\":\"en\"}";
  curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
  res = curl_easy_perform(curl);
}
curl_easy_cleanup(curl);


```

{% endtab %}

{% tab title="NodJs" %}

```
var https = require('follow-redirects').https;
var fs = require('fs');

var options = {
  'method': 'POST',
  'hostname': 'web.it-decision.com',
  'path': '/v1/api/two-factor-auth',
  'headers': {
    'Authorization': 'Basic api key',
    'Content-Type': 'application/json'
  },
  'maxRedirects': 20
};

var req = https.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function (chunk) {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });

  res.on("error", function (error) {
    console.error(error);
  });
});

var postData = JSON.stringify({
  "phone": 380631211121,
  "pin_length": 10,
  "template_id": 0,
  "country_iso": "en"
});

req.write(postData);

req.end();

```

{% endtab %}

{% tab title="PHP" %}

```
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://web.it-decision.com/v1/api/two-factor-auth',
  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 =>'{"phone":380631211121,"pin_length":10,"template_id":0,"country_iso":"en"}',
  CURLOPT_HTTPHEADER => array(
    'Authorization: Basic api key',
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;


```

{% endtab %}

{% tab title="Python" %}

```
import http.client
import json

conn = http.client.HTTPSConnection("web.it-decision.com")
payload = json.dumps({
  "phone": 380631211121,
  "pin_length": 10,
  "template_id": 0,
  "country_iso": "en"
})
headers = {
  'Authorization': 'Basic api key',
  'Content-Type': 'application/json'
}
conn.request("POST", "/v1/api/two-factor-auth", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

```

{% endtab %}

{% tab title="Ruby" %}

```
require "uri"
require "json"
require "net/http"

url = URI("https://web.it-decision.com/v1/api/two-factor-auth")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = "Basic api key"
request["Content-Type"] = "application/json"
request.body = JSON.dump({
  "phone": 380631211121,
  "pin_length": 10,
  "template_id": 0,
  "country_iso": "en"
})

response = https.request(request)
puts response.read_body

```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ru-api.decisiontele.com/verify-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
