Skip to content

Send SMS

Our Messaging API designed to fullfill most of your use cases and can be easily integrate to any of the system. We can implement single SMS, Personlized batch SMS's, Unicode (language types), Scheduling SMS, etc using this API.

Endpoint

POST
/messages/v1/send


POSTMAN

Authentication

AUTHORIZATION: Bearer Token

Body

Object

{
  "messages": [
    {
      "originator": "SignOTP",
      "recipients": ["{{recipient1}}","{{recipient2}}"],
      "content": "Greetings from D7 API",
      "msg_type": "text",
      "data_coding": "text"
      "report_url": "https://the_url_to_recieve_delivery_report.com"
    }
  ],
}
{
  "messages": [
    {
      "originator": "SignOTP",
      "recipients": ["{{recipient1}}","{{recipient2}}"],
      "content": "Greetings from D7 API",
      "msg_type": "text",
      "data_coding": "text"
      "report_url": "https://the_url_to_recieve_delivery_report.com"
    },
    {
      "originator": "SignOTP",
      "recipients": ["{{recipient1}}","{{recipient2}}"],
      "content": "This is a test message",
      "msg_type": "text",
      "data_coding": "text"
      "report_url": "https://the_url_to_recieve_delivery_report.com"
    }
  ]
}
{
  "messages": [
    {
      "recipients": ["{{recipient1}}","{{recipient2}}"],
      "content": "Greetings from D7 API",
      "msg_type": "text",
      "data_coding": "text"
    }
  ],
  "message_globals": {  // Global message parameters for all message objects
    "originator": "SignOTP",
    "schedule_time": "2021-08-05T12:52+05:30",
    "report_url": "https://the_url_to_recieve_delivery_report.com"
  }
}

Body Parameters

Parameter Type Value
originator String Brand name or number that shows up on the receiving phone, indicating who sent the text message.
recipients Array Array of Mobile Numbers to send SMS , include country code
content String The message content is being sent.
channel String To select the messaging channel that you want to use. (e.g., SMS, WhatsApp, Viber, Telegram, etc.)
num_lookup Boolean Lookup recipient number and send SMS only when number is active (Default: False).
report_url String Webhook URL to receive delivery report (DLR) for your message
data_coding String 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.
msg_type String text, audio sms, multimedia, image
schedule_time String Schedule request to send at specific time .format: YYYY-MM-DDTHH:MM+HH:MM, must be specified inside message_globals object

Response

When the request is validated, request_id, status and created time will be returned. Users can use this request_id to query status using the Get status endpoint.

200 - Success
{
    "request_id": "d9835609-a4e0-10ea-a26a-eeafbe700fef",
    "status": "accepted",
    "created_at": "2001-08-05T12:52:38.393Z"
}
401 - Unauthorized
{ 
    "detail": { 
    "code": "ACCESS_TOKEN_SIGNATURE_VERIFICATION_FAILED",
    "message": "It looks like your requests were failed due to a missing or invalid 'Access Token'. Sign up at https://app.d7networks.com and create an authentication token in the developer section."
    } 
} 
402 - Payment Required
    {
    "detail": [
        {
            "code": "INSUFFICIENT_CREDIT",
            "message": "It looks like your requests failed due to insufficient credit on our account. Sign in at https://app.d7networks.com and make a payment to resume the messaging service on your account or contact [email protected] to get more test credits."
        }
    ]
}
422 - Validation Error
{
    "detail": [
        {
            "loc": [
            "string"
            ],
        "msg": "string",
        "type": "string"
        }
    ]
} 

Response Parameters

Parameter Type Value
request_id String Unique id for each SMS request. This request_id is required to check delivery status of your SMS.
status String The status of SMS request. Possible request status are accepted and rejected
created_at String Date and time of the SMS request.

Programming Examples

1. Same content to Multiple recipients

curl --location --request POST 'https://api.d7networks.com/messages/v1/send' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {{api_access_token}}' \
--data-raw '{
"messages": [
    {
        "channel": "sms",
        "recipients": ["{{recipient1}}","{{recipient2}}"],
        "content": "Greetings from D7 API",
        "msg_type": "text",
        "data_coding": "text"
    }
],
"message_globals": {
    "originator": "SignOTP",
    "report_url": "https://the_url_to_recieve_delivery_report.com"
}
}'
npm i direct7
const Client = require('direct7')

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

const response = await client.sms.sendMessage(
        'SignOtp',
        'https://the_url_to_recieve_delivery_report.com',
        schedule_time,
        {
            recipients: ["+recipient1", "recipient2"],
            content: "Greetings from D7 API",
            unicode: false
        }
    );
console.log(response);
pip install direct7
1
2
3
4
5
6
7
8
9
from direct7 import Client

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

client.sms.send_messages(
    {"recipients": ["+9199xXXXXXXX"],"content": "Greetings from D7 API", "unicode": False},
    originator="Sender",
    report_url="https://the_url_to_receive_delivery_report.com",
    )
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") ;
$schedule_time = null ;

$response = $direct7->sms->sendMessage(
    'Sender',
    'https://example.com/callback',
    $schedule_time,
    [
        'recipients' => ["+91999999XXXX"],
        'content' => 'Greetings from D7 API',
        'unicode' => false,
    ]
);

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)
sms := direct7.NewSMS(client)
params := direct7.Message{
    Recipients:  []string{"{{recipient1}}"},
    Content:     "Greetings from D7 API",
    Unicode:     "false",
}
response, err := sms.SendMessages([]direct7.Message{params}, "Sender", "https://the_url_to_receive_delivery_report.com", "")
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n  \"messages\": [\n    {\n        \"channel\": \"sms\",\n        \"recipients\": [\"{{recipient1}}\",\"{{recipient2}}\"],\n        \"content\": \"Greetings from D7 API\",\n        \"msg_type\": \"text\",\n        \"data_coding\": \"text\"\n    }\n  ],\n  \"message_globals\": {\n    \"originator\": \"SignOTP\",\n    \"report_url\": \"https://the_url_to_recieve_delivery_report.com\"\n  }\n}");
Request request = new Request.Builder()
.url("https://api.d7networks.com/messages/v1/send")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.addHeader("Accept", "application/json")
.addHeader("Authorization", "Bearer {{api_access_token}}")
.build();
Response response = client.newCall(request).execute();
var headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {{api_access_token}}'
};
var request = http.Request('POST', Uri.parse('https://api.d7networks.com/messages/v1/send'));
request.body = json.encode({
"messages": [
    {
    "channel": "sms",
    "recipients": [
        "{{recipient1}}",
        "{{recipient2}}"
    ],
    "content": "Greetings from D7 API",
    "msg_type": "text",
    "data_coding": "text"
    }
],
"message_globals": {
    "originator": "SignOTP",
    "report_url": "https://the_url_to_recieve_delivery_report.com"
}
});
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
9
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Content-Type", "application/json")
$headers.Add("Accept", "application/json")
$headers.Add("Authorization", "Bearer {{api_access_token}}")

$body = "{`n  `"messages`": [`n    {`n        `"channel`": `"sms`",`n        `"recipients`": [`"{{recipient1}}`",`"{{recipient2}}`"],`n        `"content`": `"Greetings from D7 API`",`n        `"msg_type`": `"text`",`n        `"data_coding`": `"text`"`n    }`n  ],`n  `"message_globals`": {`n    `"originator`": `"SignOTP`",`n    `"report_url`": `"https://the_url_to_recieve_delivery_report.com`"`n  }`n}"

$response = Invoke-RestMethod 'https://api.d7networks.com/messages/v1/send' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json
gem install direct7
require 'direct7'

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

client.sms.send_message(
    originator='SignOTP',
    report_url='https://the_url_to_recieve_delivery_report.com',
    schedule_time=nil,
    { recipients: ['+991999999XXXX'], content: 'Greetings from D7 API', unicode: false }
)
1
2
3
4
5
6
7
8
9
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.d7networks.com/messages/v1/send");
request.Headers.Add("Accept", "application/json");
request.Headers.Add("Authorization", "Bearer {{api_access_token}}");
var content = new StringContent("{\n  \"messages\": [\n    {\n        \"channel\": \"sms\",\n        \"recipients\": [\"{{recipient1}}\",\"{{recipient2}}\"],\n        \"content\": \"Greetings from D7 API\",\n        \"msg_type\": \"text\",    \n        \"data_coding\": \"text\"  \n    }\n  ],\n  \"message_globals\": {\n    \"originator\": \"SignOTP\",\n    \"report_url\": \"https://the_url_to_recieve_delivery_report.com\" \n  }\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());

2. Different content and Multiple destinations

curl --location --request POST 'https://api.d7networks.com/messages/v1/send' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {{api_access_token}}' \
--data-raw '{
    "messages": [
        {
        "recipients": ["{{recipient1}}","{{recipient2}}"],
        "content": "Greetings from D7 API - First message",
        "msg_type": "text",
        "data_coding": "text"
        },
        {
        "recipients": ["{{recipient3}}","{{recipient4}}"],
        "content": "Greetings from D7 API - Second Message",
        "msg_type": "text",
        "data_coding": "text"
        }
    ],
    "message_globals": {
        "channel": "sms",
        "originator": "SignOTP",
        "report_url": "https://the_url_to_recieve_delivery_report.com"
        }
}'
const Client = require('direct7')
const client = new Client(apiToken="Your API token")
const schedule_time = null ;

const response = await client.sms.sendMessage(
            'SignOtp',
            'https://the_url_to_recieve_delivery_report.com',
            schedule_time,
            {recipients: ["+recipient1", "recipient2"], content: 'لوحة المفاتيح العربية!', unicode: true},
            {recipients: ["+recipient1", "recipient2"], content: "Greetings from D7 API", unicode: false},
        );
console.log(response);
pip install direct7
from direct7 import Client

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

client.sms.send_messages(
    {"recipients": ["+9199xXXXXXXX"],"content": "Greetings from D7 API", "unicode": False},
    {"recipients": ["+9199xXXXXXXX"],"content": "D7 API", "unicode": False},
    originator="Sender",
    report_url="https://the_url_to_receive_delivery_report.com",
    )
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") ;
$schedule_time = null ;

$response = $direct7->sms->sendMessage(
    'Sender',
    'https://example.com/callback',
    $schedule_time,
    [
        'recipients' => ["+91999999XXXX"],
        'content' => 'Greetings from D7 API',
        'unicode' => false,
    ],
    [
        'recipients' => ["+91999999XXXX"],
        'content' => 'D7 API',
        'unicode' => false,
    ]
);

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)
sms := direct7.NewSMS(client)
params_1 := direct7.Message{
    Recipients:  []string{"{{recipient1}}"},
    Content:     "Greetings from D7 API",
    Unicode:     "false",
}
params_2 := direct7.Message{
    Recipients: []string{"{{recipient2}}"},
    Content:    "Greetings from D7",
    Unicode:    "false",
}
response, err := sms.SendMessages([]direct7.Message{params_1, params_2}, "Sender", "https://the_url_to_receive_delivery_report.com", "")
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n    \"messages\": [\n        {\n        \"recipients\": [\"{{recipient1}}\",\"{{recipient2}}\"],\n        \"content\": \"Greetings from D7 API - First message\",\n        \"msg_type\": \"text\",\n        \"data_coding\": \"text\"\n        },\n        {\n        \"recipients\": [\"{{recipient3}}\",\"{{recipient4}}\"],\n        \"content\": \"Greetings from D7 API - Second Message\",\n        \"msg_type\": \"text\",\n        \"data_coding\": \"text\"\n        }\n    ],\n    \"message_globals\": {\n        \"channel\": \"sms\",\n        \"originator\": \"SignOTP\",\n        \"report_url\": \"https://the_url_to_recieve_delivery_report.com\"\n        }\n}");
Request request = new Request.Builder()
.url("https://api.d7networks.com/messages/v1/send")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.addHeader("Accept", "application/json")
.addHeader("Authorization", "Bearer {{api_access_token}}")
.build();
Response response = client.newCall(request).execute();    
var headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {{api_access_token}}'
};
var request = http.Request('POST', Uri.parse('https://api.d7networks.com/messages/v1/send'));
request.body = json.encode({
"messages": [
    {
    "recipients": [
        "{{recipient1}}",
        "{{recipient2}}"
    ],
    "content": "Greetings from D7 API - First message",
    "msg_type": "text",
    "data_coding": "text"
    },
    {
    "recipients": [
        "{{recipient3}}",
        "{{recipient4}}"
    ],
    "content": "Greetings from D7 API - Second Message",
    "msg_type": "text",
    "data_coding": "text"
    }
],
"message_globals": {
    "channel": "sms",
    "originator": "SignOTP",
    "report_url": "https://the_url_to_recieve_delivery_report.com"
}
});
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
9
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Content-Type", "application/json")
$headers.Add("Accept", "application/json")
$headers.Add("Authorization", "Bearer {{api_access_token}}")

$body = "{`n    `"messages`": [`n        {`n        `"recipients`": [`"{{recipient1}}`",`"{{recipient2}}`"],`n        `"content`": `"Greetings from D7 API - First message`",`n        `"msg_type`": `"text`",`n        `"data_coding`": `"text`"`n        },`n        {`n        `"recipients`": [`"{{recipient3}}`",`"{{recipient4}}`"],`n        `"content`": `"Greetings from D7 API - Second Message`",`n        `"msg_type`": `"text`",`n        `"data_coding`": `"text`"`n        }`n    ],`n    `"message_globals`": {`n        `"channel`": `"sms`",`n        `"originator`": `"SignOTP`",`n        `"report_url`": `"https://the_url_to_recieve_delivery_report.com`"`n        }`n}"

$response = Invoke-RestMethod 'https://api.d7networks.com/messages/v1/send' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json
gem install direct7
require 'direct7'

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

client.sms.send_message(
    originator='SignOTP',
    report_url='https://the_url_to_recieve_delivery_report.com',
    schedule_time=nil,
    { recipients: ['+991999999XXXX'], content: 'Greetings from D7 API', unicode: false },
    { recipients: ['+991999999XXXX'], content: 'D7 API', unicode: false }
)
1
2
3
4
5
6
7
8
9
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.d7networks.com/messages/v1/send");
request.Headers.Add("Accept", "application/json");
request.Headers.Add("Authorization", "Bearer {{api_access_token}}");
var content = new StringContent("{\n    \"messages\": [\n        {\n        \"recipients\": [\"{{recipient1}}\",\"{{recipient2}}\"],\n        \"content\": \"Greetings from D7 API - First message\",\n        \"msg_type\": \"text\",  \n        \"data_coding\": \"text\" \n        },\n        {\n        \"recipients\": [\"{{recipient3}}\",\"{{recipient4}}\"],\n        \"content\": \"Greetings from D7 API - Second Message\",\n        \"msg_type\": \"text\", \n        \"data_coding\": \"text\" \n        }\n    ],\n    \"message_globals\": {\n        \"channel\": \"sms\",\n        \"originator\": \"SignOTP\",\n        \"report_url\": \"https://the_url_to_recieve_delivery_report.com\" \n        }\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());

3. Send Unicode messages

curl --location --request POST 'https://api.d7networks.com/messages/v1/send' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {{api_access_token}}' \
--data-raw '{
"messages": [
    {
        "channel": "sms",
        "recipients": ["{{recipient1}}","{{recipient2}}"],
        "content": "Привет от D7 API, Спасибо за тестирование наших служб обмена сообщениями",
        "msg_type": "text",
        "data_coding": "unicode"
    }
],
"message_globals": {
    "originator": "SignOTP",
    "report_url": "https://the_url_to_recieve_delivery_report.com"
}
}'
npm i direct7
const Client = require('direct7')
const client = new Client(apiToken="Your API token")
const schedule_time = null ;

const response = await client.sms.sendMessage(
    'SignOtp',
    'https://the_url_to_recieve_delivery_report.com',
    schedule_time,
    { 
        recipients: ["+91999XXXXXXX"],
        content: 'لوحة المفاتيح العربية!',
        unicode: true 
    }
    );
console.log(response);
pip install direct7
1
2
3
4
5
6
7
8
9
from direct7 import Client

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

client.sms.send_messages(
    {"recipients": ["+9199XXXXXXXXXX"],"content": "مرحبا بالعالم!", "unicode": True},
    originator="Sender",
    report_url="https://the_url_to_receive_delivery_report.com",
    )

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") ;
$schedule_time = null ;

$response = $direct7->sms->sendMessage(
    'Sender',
    'https://example.com/callback',
    $schedule_time,
    [
        'recipients' => ["+919999XXXXXX"],
        'content' => 'لوحة المفاتيح العربية!',
        'unicode' => true,
    ]
);

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)
sms := direct7.NewSMS(client)
params := Message{
    Recipients:  []string{"{{recipient}}"},
    Content:     "مرحبا بالعالم!",
    Unicode:     "true",
}
response, err := sms.SendMessages([]Message{params}, "Sender", "https://the_url_to_receive_delivery_report.com", "")
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n  \"messages\": [\n    {\n        \"channel\": \"sms\",\n        \"recipients\": [\"{{recipient1}}\",\"{{recipient2}}\"],\n        \"content\": \"Привет от D7 API, Спасибо за тестирование наших служб обмена сообщениями\",\n        \"msg_type\": \"text\",\n        \"data_coding\": \"unicode\"\n    }\n  ],\n  \"message_globals\": {\n    \"originator\": \"SignOTP\",\n    \"report_url\": \"https://the_url_to_recieve_delivery_report.com\"\n  }\n}");
Request request = new Request.Builder()
.url("https://api.d7networks.com/messages/v1/send")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.addHeader("Accept", "application/json")
.addHeader("Authorization", "Bearer {{api_access_token}}")
.build();
Response response = client.newCall(request).execute();
var headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {{api_access_token}}'
};
var request = http.Request('POST', Uri.parse('https://api.d7networks.com/messages/v1/send'));
request.body = json.encode({
"messages": [
    {
    "channel": "sms",
    "recipients": [
        "{{recipient1}}",
        "{{recipient2}}"
    ],
    "content": "Привет от D7 API, Спасибо за тестирование наших служб обмена сообщениями",
    "msg_type": "text",
    "data_coding": "unicode"
    }
],
"message_globals": {
    "originator": "SignOTP",
    "report_url": "https://the_url_to_recieve_delivery_report.com"
}
});
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
9
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Content-Type", "application/json")
$headers.Add("Accept", "application/json")
$headers.Add("Authorization", "Bearer {{api_access_token}}")

$body = "{`n  `"messages`": [`n    {`n        `"channel`": `"sms`",`n        `"recipients`": [`"{{recipient1}}`",`"{{recipient2}}`"],`n        `"content`": `"Привет от D7 API, Спасибо за тестирование наших служб обмена сообщениями`",`n        `"msg_type`": `"text`",`n        `"data_coding`": `"unicode`"`n    }`n  ],`n  `"message_globals`": {`n    `"originator`": `"SignOTP`",`n    `"report_url`": `"https://the_url_to_recieve_delivery_report.com`"`n  }`n}"

$response = Invoke-RestMethod 'https://api.d7networks.com/messages/v1/send' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json
gem install direct7
require 'direct7'

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

client.sms.send_message(
    originator='SignOTP',
    report_url='https://the_url_to_recieve_delivery_report.com',
    schedule_time=nil,
    { recipients: ['+919999XXXXXX'], content: "مرحبا بالعالم!", unicode: true }
    )
1
2
3
4
5
6
7
8
9
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.d7networks.com/messages/v1/send");
request.Headers.Add("Accept", "application/json");
request.Headers.Add("Authorization", "Bearer {{api_access_token}}");
var content = new StringContent("{\n  \"messages\": [\n    {\n        \"channel\": \"sms\",\n        \"recipients\": [\"{{recipient1}}\",\"{{recipient2}}\"],\n        \"content\": \"Привет от D7 API, Спасибо за тестирование наших служб обмена сообщениями\",\n        \"msg_type\": \"text\", \n        \"data_coding\": \"unicode\" \n    }\n  ],\n  \"message_globals\": {\n    \"originator\": \"SignOTP\"\n        \n  }\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());

4. Send mixed content (text and unicode) messages

curl --location --request POST 'https://api.d7networks.com/messages/v1/send' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {{api_access_token}}' \
--data-raw '{
"messages": [
    {
        "channel": "sms",
        "recipients": ["{{recipient1}}","{{recipient2}}"],
        "content": "Привет от D7 API, Спасибо за тестирование наших служб обмена сообщениями",
        "msg_type": "text",
        "data_coding": "auto"
    }
],
"message_globals": {
    "originator": "SignOTP",
    "report_url": "https://the_url_to_recieve_delivery_report.com"
}
}'
const Client = require('direct7')
const client = new Client(apiToken="Your API token")
const schedule_time = null;

const response = await client.sms.sendMessage(
            'SignOtp',
            'https://the_url_to_recieve_delivery_report.com',
            schedule_time,
            {
                recipients: ["+recipient1", "recipient2"],
                content: "Привет от D7 API, Спасибо за тестирование наших служб обмена сообщениями",
                unicode: true
            }
        );
console.log(response);
pip install direct7
1
2
3
4
5
6
7
8
9
from direct7 import Client

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

client.sms.send_messages(
    {"recipients": ["+9199xXXXXXXX"],"content": "Привет от D7 API, Спасибо за тестирование наших служб обмена сообщениями", "unicode": True},
    originator="Sender",
    report_url="https://the_url_to_receive_delivery_report.com",
    )
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") ;
$schedule_time = null ;

$response = $direct7->sms->sendMessage(
    'Sender',
    'https://example.com/callback',
    $schedule_time,
    [
        'recipients' => ["+91999999XXXX"],
        'content' => 'Привет от D7 API, Спасибо за тестирование наших служб обмена сообщениями',
        'unicode' => true,
    ]
);

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)
sms := direct7.NewSMS(client)
params := Message{
    Recipients:  []string{"{{recipient1}}"},
    Content:     "Привет от D7 API, Спасибо за тестирование наших служб обмена сообщениями",
    Unicode:     "true",
}
response, err := sms.SendMessages([]Message{params}, "Sender", "https://the_url_to_receive_delivery_report.com", "")

:simple-spring: Java linenums="1" OkHttpClient client = new OkHttpClient().newBuilder() .build(); MediaType mediaType = MediaType.parse("application/json"); RequestBody body = RequestBody.create(mediaType, "{\n \"messages\": [\n {\n \"channel\": \"sms\",\n \"recipients\": [\"{{recipient1}}\",\"{{recipient2}}\"],\n \"content\": \"Привет от D7 API, Спасибо за тестирование наших служб обмена сообщениями\",\n \"msg_type\": \"text\",\n \"data_coding\": \"auto\"\n }\n ],\n \"message_globals\": {\n \"originator\": \"SignOTP\",\n \"report_url\": \"https://the_url_to_recieve_delivery_report.com\"\n }\n}"); Request request = new Request.Builder() .url("https://api.d7networks.com/messages/v1/send") .method("POST", body) .addHeader("Content-Type", "application/json") .addHeader("Accept", "application/json") .addHeader("Authorization", "Bearer {{api_access_token}}") .build(); Response response = client.newCall(request).execute();

var headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {{api_access_token}}'
};
var request = http.Request('POST', Uri.parse('https://api.d7networks.com/messages/v1/send'));
request.body = json.encode({
"messages": [
    {
    "channel": "sms",
    "recipients": [
        "{{recipient1}}",
        "{{recipient2}}"
    ],
    "content": "Привет от D7 API, Спасибо за тестирование наших служб обмена сообщениями",
    "msg_type": "text",
    "data_coding": "auto"
    }
],
"message_globals": {
    "originator": "SignOTP",
    "report_url": "https://the_url_to_recieve_delivery_report.com"
}
});
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
9
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Content-Type", "application/json")
$headers.Add("Accept", "application/json")
$headers.Add("Authorization", "Bearer {{api_access_token}}")

$body = "{`n  `"messages`": [`n    {`n        `"channel`": `"sms`",`n        `"recipients`": [`"{{recipient1}}`",`"{{recipient2}}`"],`n        `"content`": `"Привет от D7 API, Спасибо за тестирование наших служб обмена сообщениями`",`n        `"msg_type`": `"text`",`n        `"data_coding`": `"auto`"`n    }`n  ],`n  `"message_globals`": {`n    `"originator`": `"SignOTP`",`n    `"report_url`": `"https://the_url_to_recieve_delivery_report.com`"`n  }`n}"

$response = Invoke-RestMethod 'https://api.d7networks.com/messages/v1/send' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json
gem install direct7
require 'direct7'

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

client.sms.send_message(
    originator='SignOTP',
    report_url='https://the_url_to_recieve_delivery_report.com',
    schedule_time=nil,
    { recipients: ['+991999999XXXX'], content: 'Привет от D7 API, Спасибо за тестирование наших служб обмена сообщениями', unicode: true }
)
1
2
3
4
5
6
7
8
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.d7networks.com/messages/v1/send");
request.Headers.Add("Authorization", "Bearer {{api_access_token}}");
var content = new StringContent("{\n  \"messages\": [\n    {\n        \"channel\": \"sms\",\n        \"recipients\": [\"{{recipient1}}\",\"{{recipient2}}\"],\n        \"content\": \"Привет от D7 API, Спасибо за тестирование наших служб обмена сообщениями\"\n    },\n    {\n        \"channel\": \"sms\",\n        \"recipients\": [\"{{recipient3}}\",\"{{recipient4}}\"],\n        \"content\": \"Hello from D7 API, Thanks for testing our messaging services\"\n    }\n  ],\n  \"message_globals\": {\n    \"originator\": \"D7Web\", \n    \"data_coding\": \"auto\",\n    \"report_url\": \"https://the_url_to_recieve_delivery_report.com\", \n    \n  }\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());

4. Send scheduled messages

curl --location 'https://api.d7networks.com/messages/v1/send' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{api_access_token}}' \
--data '{
"messages": [
    {
        "channel": "sms",
        "recipients": ["{{recipient1}}","{{recipient2}}"],
        "content": "Привет от D7 API, Спасибо за тестирование наших служб обмена сообщениями"
    },
    {
        "channel": "sms",
        "recipients": ["{{recipient3}}","{{recipient4}}"],
        "content": "Hello from D7 API, Thanks for testing our messaging services"
    }
],
"message_globals": {
    "originator": "D7Web", 
    "data_coding": "auto",
    "report_url": "https://the_url_to_recieve_delivery_report.com", 
    "schedule_time": "2023-04-19T16:18+04:00" 
    }
}'
const Client = require('direct7')
const client = new Client(apiToken="Your API token")
const schedule_time = '2024-02-05T07:13:13+0000' ;

const response = await client.sms.sendMessage(
        'SignOtp',
        'https://the_url_to_recieve_delivery_report.com',
        schedule_time,
        {recipients: ["+recipient1", "recipient2"], content: "Greetings from D7 API", unicode: false},
    );
console.log(response);
pip install direct7
from direct7 import Client

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

client.sms.send_messages(
    {"recipients": ["+9199xXXXXXXX"],"content": "Greetings from D7 API", "unicode": False},
    originator="Sender",
    report_url="https://the_url_to_receive_delivery_report.com",
    schedule_time='2024-02-05T07:13:13+0000'
    )
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") ;
$schedule_time = '2024-02-05T10:17:10+0000' ;

$response = $direct7->sms->sendMessage(
    'Sender',
    'https://example.com/callback',
    $schedule_time,
    [
        'recipients' => ["+91999999XXXX"],
        'content' => 'Greetings from D7 API',
        'unicode' => false,
    ]
);

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)
sms := direct7.NewSMS(client)
params := direct7.Message{
    Recipients:  []string{"{{recipient1}}"},
    Content:     "Greetings from D7 API",
    Unicode:     "false",
}
response, err := sms.SendMessages([]direct7.Message{params}, "Sender", "https://the_url_to_receive_delivery_report.com", "2024-02-05T09:48:42+0000")
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n  \"messages\": [\n    {\n        \"channel\": \"sms\",\n        \"recipients\": [\"{{recipient1}}\",\"{{recipient2}}\"],\n        \"content\": \"Привет от D7 API, Спасибо за тестирование наших служб обмена сообщениями\"\n    },\n    {\n        \"channel\": \"sms\",\n        \"recipients\": [\"{{recipient3}}\",\"{{recipient4}}\"],\n        \"content\": \"Hello from D7 API, Thanks for testing our messaging services\"\n    }\n  ],\n  \"message_globals\": {\n    \"originator\": \"D7Web\", \n    \"data_coding\": \"auto\",\n    \"report_url\": \"https://the_url_to_recieve_delivery_report.com\", \n    \"schedule_time\": \"2023-04-19T16:18+04:00\" \n  }\n}");
Request request = new Request.Builder()
.url("https://api.d7networks.com/messages/v1/send")
.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/messages/v1/send'));
request.body = json.encode({
"messages": [
    {
    "channel": "sms",
    "recipients": [
        "{{recipient1}}",
        "{{recipient2}}"
    ],
    "content": "Привет от D7 API, Спасибо за тестирование наших служб обмена сообщениями"
    },
    {
    "channel": "sms",
    "recipients": [
        "{{recipient3}}",
        "{{recipient4}}"
    ],
    "content": "Hello from D7 API, Thanks for testing our messaging services"
    }
],
"message_globals": {
    "originator": "D7Web",
    "data_coding": "auto",
    "report_url": "https://the_url_to_recieve_delivery_report.com",
    "schedule_time": "2023-04-19T16:18+04:00"
}
});
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 = @"
{
`"messages`": [
    {
        `"channel`": `"sms`",
        `"recipients`": [`"{{recipient1}}`",`"{{recipient2}}`"],
        `"content`": `"Привет от D7 API, Спасибо за тестирование наших служб обмена сообщениями`"
    },
    {
        `"channel`": `"sms`",
        `"recipients`": [`"{{recipient3}}`",`"{{recipient4}}`"],
        `"content`": `"Hello from D7 API, Thanks for testing our messaging services`"
    }
],
`"message_globals`": {
    `"originator`": `"D7Web`", 
    `"data_coding`": `"auto`",
    `"report_url`": `"https://the_url_to_recieve_delivery_report.com`", 
    `"schedule_time`": `"2023-04-19T16:18+04:00`" 
}
}
"@

$response = Invoke-RestMethod 'https://api.d7networks.com/messages/v1/send' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json
gem install direct7
require 'direct7'

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

client.sms.send_message(
    originator='SignOTP',
    report_url='https://the_url_to_recieve_delivery_report.com',
    schedule_time='2023-04-19T16:18+04:00',
    { recipients: ['+991999999XXXX'], content: 'Greetings from D7 API', unicode: false }
)
1
2
3
4
5
6
7
8
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.d7networks.com/messages/v1/send");
request.Headers.Add("Authorization", "Bearer {{api_access_token}}");
var content = new StringContent("{\n  \"messages\": [\n    {\n        \"channel\": \"sms\",\n        \"recipients\": [\"{{recipient1}}\",\"{{recipient2}}\"],\n        \"content\": \"Привет от D7 API, Спасибо за тестирование наших служб обмена сообщениями\"\n    },\n    {\n        \"channel\": \"sms\",\n        \"recipients\": [\"{{recipient3}}\",\"{{recipient4}}\"],\n        \"content\": \"Hello from D7 API, Thanks for testing our messaging services\"\n    }\n  ],\n  \"message_globals\": {\n    \"originator\": \"D7Web\", \n    \"data_coding\": \"auto\",\n    \"report_url\": \"https://the_url_to_recieve_delivery_report.com\", \n    \"schedule_time\": \"2023-04-19T16:18+04:00\" \n  }\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());