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
Header
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"
},
{
"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
401 - Unauthorized
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."
}
]
}
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
2. Different content and Multiple destinations
3. Send Unicode messages
4. Send mixed content (text and unicode) messages
: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();