Skip to content

Generate OTP

Generate the One Time Password or Verification 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 Number 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 Regenerate OTP delay 60
*retry_count Regenerate 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"
}'
npm i direct7
const Client = require('direct7')

const client = new Client(apiToken="Your API token")

const response = await client.verify.sendOTP({
            originator: "SignOTP", recipient: "+9199999XXXXX",
            content: "Greetings from D7 API, your mobile  verification code is: {}",
            expiry: 600,
            data_coding: "text"
        })

console.log(response);
pip install direct7
from direct7 import Client

client = Client(api_token="Your API token")

client.verify.send_otp(
    originator="SignOTP", 
    recipient="+97150900XXXX", 
    content = "Greetings from D7 API, your mobile verification code is: {}", 
    expiry = 600, 
    data_coding = "text")

composer require direct7/direct7-php
require_once 'vendor/autoload.php';
require_once __DIR__ . '/vendor/autoload.php';

use direct7\Direct7\Client;

$client = new Client(api_token="Your API token")

$response = $direct7->verify->sendOtp(
    originator:'SignOTP', 
    recipient:'+91999999XXXX', 
    content:'Greetings from D7 API, your mobile verification code is: {}', 
    data_coding:'text', 
    expiry:600);

var_dump($response);
go get -u github.com/d7networks/direct7-go-sdk
import (
"github.com/d7networks/direct7-go-sdk/direct7"
    )   
apiToken := "Your Api Token"
client := direct7.NewClient(apiToken)
verify := direct7.NewVerify(client)
originator := "SignOTP"
recipient := "{{recipient}}"
content := "Greetings from D7 API, your mobile verification code is: {}"
dataCoding := "text"
expiry := 600
response, err := verify.SendOTP(originator, recipient, content, dataCoding, expiry)
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
gem install direct7
require 'direct7'

client = Direct7::Client.new('Your API token')

client.verify.send_otp(
    originator="SignOTP", 
    recipient="+97150900XXXX", 
    content = "Greetings from D7 API, your mobile verification code is: {}", 
    expiry = 600, 
    data_coding = "text")
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" 
}'
npm i direct7
const Client = require('direct7')

const client = new Client(apiToken="Your API token")

const response = await client.verify.sendOTP({
            originator: "SignOTP", 
            recipient: "+9199999XXXXX",
            template_id: 25
        })

console.log(response);
pip install direct7
1
2
3
4
5
6
7
8
from direct7 import Client

client = Client(api_token="Your API token")

client.verify.send_otp(
    originator="SignOTP", 
    recipient="+97150900XXXX", 
    template_id= 25)

composer require direct7/direct7-php
require_once 'vendor/autoload.php';
require_once __DIR__ . '/vendor/autoload.php';

use direct7\Direct7\Client;

$client = new Client(api_token="Your API token")

$response = $direct7->verify->sendOtp(
    originator:'SignOTP', 
    recipient:'+91999999XXXX', 
    template_id: 25);

var_dump($response);
go get -u github.com/d7networks/direct7-go-sdk
import (
"github.com/d7networks/direct7-go-sdk/direct7"
    )   
apiToken := "Your Api Token"
client := direct7.NewClient(apiToken)
verify := direct7.NewVerify(client)
originator := "SignOTP"
recipient := "{{recipient}}"
templateID := 25
response, err := verify.SendOTP(originator, recipient, templateID)
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
gem install direct7
1
2
3
4
5
6
7
8
require 'direct7'

client = Direct7::Client.new('Your API token')

client.verify.send_otp(
    originator="SignOTP", 
    recipient="+97150900XXXX", 
    template_id=25)
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

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

Response Parameters

Parameter Value / Pattern
otp_id Unique id for each otp request. Users can use this otp_id to regenerate otp or verify otp.
status The status of sms request. Possible request status are OPEN (authentication is approved and is waiting for a response), APPROVED (authentication has been approved), EXPIRED (authentication has expired) and FAILED (There was an error while sending notification)
expiry OTP Expiry time in seconds.