Skip to content

Send Message

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.

POST /messages/v1/send

AUTHORIZATIONS: Bearer Token

Request parameters

Parameter Value / Pattern
*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.
*recipients Mobile Numbers to send SMS seperated by comma in an array.
*content Message Content being sent.
*channel Messaging Channel (SMS, WhatsApp, Viber, Telegram,etc)
report_url Your call back server URL to recieve delivery status.
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.
msg_type text, audio sms, multimedia, image

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.

{
    "request_id": "d9835609-a4e0-10ea-a26a-eeafbe700fef",
    "status": "accepted",
    "created_at": "2001-08-05T12:52:38.393Z"
}
{ 
    "detail": { 
        "code": "ACCESS_TOKEN_SIGNATURE_VERIFICATION_FAILED", 
        "message": "Access token signature verification failed" 
    } 
} 
{
    "detail": [
        {
            "loc": [
            "string"
            ],
        "msg": "string",
        "type": "string"
        }
    ]
} 

Example 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"
}
}'
var axios = require('axios');
var data = JSON.stringify({
"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"
}
});

var config = {
method: 'post',
url: 'https://api.d7networks.com/messages/v1/send',
headers: { 
    'Content-Type': 'application/json', 
    'Accept': 'application/json', 
    'Authorization': 'Bearer {{api_access_token}}'
},
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/messages/v1/send"

payload = json.dumps({
"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"
}
})
headers = {
'Content-Type': 'application/json',
'Accept': '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/messages/v1/send',
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 =>'{
"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"
}
}',
CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Accept: 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/messages/v1/send"
method := "POST"

payload := strings.NewReader(`{
"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"
}
}`)

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("Accept", "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 settings = {
"url": "https://api.d7networks.com/messages/v1/send",
"method": "POST",
"timeout": 0,
"headers": {
    "Content-Type": "application/json",
    "Accept": "application/json",
    "Authorization": "Bearer {{api_access_token}}"
},
"data": JSON.stringify({
    "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"
    }
}),
};

$.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  \"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
require "uri"
require "json"
require "net/http"

url = URI("https://api.d7networks.com/messages/v1/send")

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

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Accept"] = "application/json"
request["Authorization"] = "Bearer {{api_access_token}}"
request.body = JSON.dump({
"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"
}
})

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

Example 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"
        }
}'
var axios = require('axios');
var data = JSON.stringify({
"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"
}
});

var config = {
method: 'post',
url: 'https://api.d7networks.com/messages/v1/send',
headers: { 
    'Content-Type': 'application/json', 
    'Accept': 'application/json', 
    'Authorization': 'Bearer {{api_access_token}}'
},
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/messages/v1/send"

payload = json.dumps({
"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"
}
})
headers = {
'Content-Type': 'application/json',
'Accept': '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/messages/v1/send',
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 =>'{
    "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"
        }
}',
CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Accept: 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/messages/v1/send"
method := "POST"

payload := strings.NewReader(`{
    "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"
        }
}`)

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("Accept", "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 settings = {
"url": "https://api.d7networks.com/messages/v1/send",
"method": "POST",
"timeout": 0,
"headers": {
    "Content-Type": "application/json",
    "Accept": "application/json",
    "Authorization": "Bearer {{api_access_token}}"
},
"data": JSON.stringify({
    "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"
    }
}),
};

$.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    \"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
require "uri"
require "json"
require "net/http"

url = URI("https://api.d7networks.com/messages/v1/send")

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

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Accept"] = "application/json"
request["Authorization"] = "Bearer {{api_access_token}}"
request.body = JSON.dump({
"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"
}
})

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

Example 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"
}
}'
var axios = require('axios');
var data = JSON.stringify({
"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"
}
});

var config = {
method: 'post',
url: 'https://api.d7networks.com/messages/v1/send',
headers: { 
    'Content-Type': 'application/json', 
    'Accept': 'application/json', 
    'Authorization': 'Bearer {{api_access_token}}'
},
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/messages/v1/send"

payload = json.dumps({
"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"
}
})
headers = {
'Content-Type': 'application/json',
'Accept': '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/messages/v1/send',
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 =>'{
"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"
}
}',
CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Accept: 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/messages/v1/send"
method := "POST"

payload := strings.NewReader(`{
"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"
}
}`)

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("Accept", "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 settings = {
"url": "https://api.d7networks.com/messages/v1/send",
"method": "POST",
"timeout": 0,
"headers": {
    "Content-Type": "application/json",
    "Accept": "application/json",
    "Authorization": "Bearer {{api_access_token}}"
},
"data": JSON.stringify({
    "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"
    }
}),
};

$.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  \"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
require "uri"
require "json"
require "net/http"

url = URI("https://api.d7networks.com/messages/v1/send")

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

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Accept"] = "application/json"
request["Authorization"] = "Bearer {{api_access_token}}"
request.body = JSON.dump({
"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"
}
})

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

Example 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"
}
}'
var axios = require('axios');
var data = JSON.stringify({
"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"
}
});

var config = {
method: 'post',
url: 'https://api.d7networks.com/messages/v1/send',
headers: { 
    'Content-Type': 'application/json', 
    'Accept': 'application/json', 
    'Authorization': 'Bearer {{api_access_token}}'
},
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/messages/v1/send"

payload = json.dumps({
"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"
}
})
headers = {
'Content-Type': 'application/json',
'Accept': '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/messages/v1/send',
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 =>'{
"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"
}
}',
CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Accept: 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/messages/v1/send"
method := "POST"

payload := strings.NewReader(`{
"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"
}
}`)

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("Accept", "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 settings = {
"url": "https://api.d7networks.com/messages/v1/send",
"method": "POST",
"timeout": 0,
"headers": {
    "Content-Type": "application/json",
    "Accept": "application/json",
    "Authorization": "Bearer {{api_access_token}}"
},
"data": JSON.stringify({
    "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"
    }
}),
};

$.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  \"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
require "uri"
require "json"
require "net/http"

url = URI("https://api.d7networks.com/messages/v1/send")

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

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Accept"] = "application/json"
request["Authorization"] = "Bearer {{api_access_token}}"
request.body = JSON.dump({
"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"
}
})

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