Skip to content

Generate OTP

Generate the One Time Password or Verifiaction Token and send to the recipient.

POST
/verify/v1/otp/send-otp

Authentication

AUTHORIZATION: Bearer Token

Request parameters

Parameter Value / Pattern Example
*originator The Sender/Header of a message. We can use your brand name with a maximum character limit of 11 or your mobile number with your country code. D7Web
*recipients Mobile Numbers to send OTP Code. The recipient's phone number should have a country code prefix. 9715097526xx
*content OTP Message Content with {} placeholder Greetings from D7 API, your mobile verification code is: {}
*expiry OTP Expiry time in seconds 300
data_coding Set as text for normal GSM 03.38 characters(English, normal characters). Set as unicode for non GSM 03.38 characters (Arabic, Chinese, Hebrew, Greek like regional languages and Unicode characters). Set as auto so we will find the data_coding based on your content. auto
*retry_delay Regeneate OTP delay 60
*retry_count Regeneate OTP limit 3
*otp_code_length Length of OTP code. Minimum 2 to maximum 10 6
*otp_type Should be an enum with values: numeric, alpha, or alphanumeric numeric
*template_id You can create a verification template in the dashboard and call it from the request 25
*success_url Verification Success callback URL https://d7networks.com/callback-receiver-success
*failure_url Verification Failure callback URL https://d7networks.com/callback-receiver-failed

Request

curl --location --request POST 'https://api.d7networks.com/verify/v1/otp/send-otp' \
--header 'Authorization: Bearer {{api_access_token}}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "originator": "SignOTP",
    "recipient": "{{recipient1}}",
    "content": "Greetings from D7 API, your mobile verification code is: {}",
    "expiry": "600",
    "data_coding": "text"
}'
var axios = require('axios');
var data = JSON.stringify({
"originator": "SignOTP",
"recipient": "{{recipient1}}",
"content": "Greetings from D7 API, your mobile verification code is: {}",
"expiry": "600",
"data_coding": "text"
});

var config = {
method: 'post',
url: 'https://api.d7networks.com/verify/v1/otp/send-otp',
headers: { 
    'Authorization': 'Bearer {{api_access_token}}', 
    'Content-Type': 'application/json'
},
data : data
};

axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
import requests
import json

url = "https://api.d7networks.com/verify/v1/otp/send-otp"

payload = json.dumps({
"originator": "SignOTP",
"recipient": "{{recipient1}}",
"content": "Greetings from D7 API, your mobile verification code is: {}",
"expiry": "600",
"data_coding": "text"
})
headers = {
'Authorization': 'Bearer {{api_access_token}}',
'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.d7networks.com/verify/v1/otp/send-otp',
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 =>'{
    "originator": "SignOTP",
    "recipient": "{{recipient1}}",
    "content": "Greetings from D7 API, your mobile verification code is: {}",
    "expiry": "600",
    "data_coding": "text"
}',
CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer {{api_access_token}}',
    'Content-Type: application/json'
),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
package main

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

func main() {

url := "https://api.d7networks.com/verify/v1/otp/send-otp"
method := "POST"

payload := strings.NewReader(`{
    "originator": "SignOTP",
    "recipient": "{{recipient1}}",
    "content": "Greetings from D7 API, your mobile verification code is: {}",
    "expiry": "600",
    "data_coding": "text"
}`)

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

if err != nil {
    fmt.Println(err)
    return
}
req.Header.Add("Authorization", "Bearer {{api_access_token}}")
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))
}
var settings = {
"url": "https://api.d7networks.com/verify/v1/otp/send-otp",
"method": "POST",
"timeout": 0,
"headers": {
    "Authorization": "Bearer {{api_access_token}}",
    "Content-Type": "application/json"
},
"data": JSON.stringify({
    "originator": "SignOTP",
    "recipient": "{{recipient1}}",
    "content": "Greetings from D7 API, your mobile verification code is: {}",
    "expiry": "600",
    "data_coding": "text"
}),
};

$.ajax(settings).done(function (response) {
console.log(response);
});
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n    \"originator\": \"SignOTP\",\n    \"recipient\": \"{{recipient1}}\",\n    \"content\": \"Greetings from D7 API, your mobile verification code is: {}\",\n    \"expiry\": \"600\",\n    \"data_coding\": \"text\"\n}");
Request request = new Request.Builder()
.url("https://api.d7networks.com/verify/v1/otp/send-otp")
.method("POST", body)
.addHeader("Authorization", "Bearer {{api_access_token}}")
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
var headers = {
'Authorization': 'Bearer {{api_access_token}}',
'Content-Type': 'application/json'
};
var request = http.Request('POST', Uri.parse('https://api.d7networks.com/verify/v1/otp/send-otp'));
request.body = json.encode({
"originator": "SignOTP",
"recipient": "{{recipient1}}",
"content": "Greetings from D7 API, your mobile verification code is: {}",
"expiry": "600",
"data_coding": "text"
});
request.headers.addAll(headers);

http.StreamedResponse response = await request.send();

if (response.statusCode == 200) {
print(await response.stream.bytesToString());
}
else {
print(response.reasonPhrase);
}
1
2
3
4
5
6
7
8
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Authorization", "Bearer {{api_access_token}}")
$headers.Add("Content-Type", "application/json")

$body = "{`n    `"originator`": `"SignOTP`",`n    `"recipient`": `"{{recipient1}}`",`n    `"content`": `"Greetings from D7 API, your mobile verification code is: {}`",`n    `"expiry`": `"600`",`n    `"data_coding`": `"text`"`n}"

$response = Invoke-RestMethod 'https://api.d7networks.com/verify/v1/otp/send-otp' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json
require "uri"
require "json"
require "net/http"

url = URI("https://api.d7networks.com/verify/v1/otp/send-otp")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer {{api_access_token}}"
request["Content-Type"] = "application/json"
request.body = JSON.dump({
"originator": "SignOTP",
"recipient": "{{recipient1}}",
"content": "Greetings from D7 API, your mobile verification code is: {}",
"expiry": "600",
"data_coding": "text"
})

response = https.request(request)
puts response.read_body
1
2
3
4
5
6
7
8
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.d7networks.com/verify/v1/otp/send-otp");
request.Headers.Add("Authorization", "Bearer {{api_access_token}}");
var content = new StringContent("{\n    \"originator\": \"SignOTP\",\n    \"recipient\": \"{{recipient1}}\",\n    \"content\": \"Greetings from D7 API, your mobile verification code is: {}\",\n    \"data_coding\": \"auto\" \n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());

Request using template id

1
2
3
4
5
6
7
8
curl --location 'https://api.d7networks.com/verify/v1/otp/send-otp' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{api_access_token}}' \
--data '{
    "originator": "SignOTP",
    "recipient": "{{recipient1}}",
    "template_id": "25" 
}'
const axios = require('axios');
let data = JSON.stringify({
"originator": "SignOTP",
"recipient": "{{recipient1}}",
"template_id": "25"
});

let config = {
method: 'post',
maxBodyLength: Infinity,
url: 'https://api.d7networks.com/verify/v1/otp/send-otp',
headers: { 
    'Content-Type': 'application/json', 
    'Authorization': 'Bearer {{api_access_token}}'
},
data : data
};

axios.request(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});
import requests
import json

url = "https://api.d7networks.com/verify/v1/otp/send-otp"

payload = json.dumps({
"originator": "SignOTP",
"recipient": "{{recipient1}}",
"template_id": "25"
})
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer {{api_access_token}}'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.d7networks.com/verify/v1/otp/send-otp',
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 =>'{
    "originator": "SignOTP",
    "recipient": "{{recipient1}}",
    "template_id": "25" 
}',
CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: Bearer {{api_access_token}}'
),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
package main

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

func main() {

url := "https://api.d7networks.com/verify/v1/otp/send-otp"
method := "POST"

payload := strings.NewReader(`{
    "originator": "SignOTP",
    "recipient": "{{recipient1}}",
    "template_id": "25" 
}`)

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

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

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))
}
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", "Bearer {{api_access_token}}");

var raw = JSON.stringify({
"originator": "SignOTP",
"recipient": "{{recipient1}}",
"template_id": "25"
});

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

fetch("https://api.d7networks.com/verify/v1/otp/send-otp", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n    \"originator\": \"SignOTP\",\n    \"recipient\": \"{{recipient1}}\",\n    \"template_id\": \"25\" \n}");
Request request = new Request.Builder()
.url("https://api.d7networks.com/verify/v1/otp/send-otp")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.addHeader("Authorization", "Bearer {{api_access_token}}")
.build();
Response response = client.newCall(request).execute();
var headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer {{api_access_token}}'
};
var request = http.Request('POST', Uri.parse('https://api.d7networks.com/verify/v1/otp/send-otp'));
request.body = json.encode({
"originator": "SignOTP",
"recipient": "{{recipient1}}",
"template_id": "25"
});
request.headers.addAll(headers);

http.StreamedResponse response = await request.send();

if (response.statusCode == 200) {
print(await response.stream.bytesToString());
}
else {
print(response.reasonPhrase);
}
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Content-Type", "application/json")
$headers.Add("Authorization", "Bearer {{api_access_token}}")

$body = @"
{
    `"originator`": `"SignOTP`",
    `"recipient`": `"{{recipient1}}`",
    `"template_id`": `"25`" 
}
"@

$response = Invoke-RestMethod 'https://api.d7networks.com/verify/v1/otp/send-otp' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json
require "uri"
require "json"
require "net/http"

url = URI("https://api.d7networks.com/verify/v1/otp/send-otp")

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

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer {{api_access_token}}"
request.body = JSON.dump({
"originator": "SignOTP",
"recipient": "{{recipient1}}",
"template_id": "25"
})

response = https.request(request)
puts response.read_body
1
2
3
4
5
6
7
8
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.d7networks.com/verify/v1/otp/send-otp");
request.Headers.Add("Authorization", "Bearer {{api_access_token}}");
var content = new StringContent("{\n    \"originator\": \"SignOTP\",\n    \"recipient\": \"{{recipient1}}\",\n    \"template_id\": \"25\" \n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());

Response

When the request is validated, otp_id, status and expiry will be returned. Users can use this otp_id to regenerate otp or verify otp

Success
{
    "otp_id": "dfd31c0e-2cd2-494e-88d2-6cac05263a7f",
    "status": "OPEN",
    "expiry": 600
} 
Validation Error
{
    "detail": [
        {
            "loc": [
                "string",
                0
            ],
            "msg": "string",
            "type": "string"
        }
    ]
}