База знаний

Revision 1.2.240312

This document contains information about the JSONv2 protocol, which allows messages to be transmitted to the platform over the HTTP(S) protocol.

This document contains information that is current at the time of its preparation. The manufacturer does not guarantee the absence of errors in this document. The manufacturer reserves the right to make changes to the document without prior notice

No part of this document may be reproduced or transmitted in any form or by any means without written notice to the Manufacturer

The manufacturer does not guarantee that the software specified in this document is error-free, will work in arbitrarily selected conditions and meet all the requirements that may be imposed on it.

The manufacturer does not guarantee the operability of illegally obtained software. Illegal use of software and documentation for it is prosecuted by law

1 Description of the JSONv2 protocol for sending messages to the platform

The JSONv2 protocol allows you to send messages to the platform over the HTTP(S) protocol.

  • Differences from the SMPP protocol:
  • You can use several communication channels with your audience at the same time: Push, messenger applications and SMS (only SMS is supported in this installation). If the message is successfully delivered via any channel, further sending of the message via other channels is stopped.
  • Bulk messaging is supported.

The platform acts as a server. Clients sending messages for delivery act as HTTP clients.

Start URL for working with the JSONv2 protocol in this installation: https://mn-smsrlbsvc.vimpelcom.ru:4433/msghub/api

1.1 Basic scenarios for using the protocol

The protocol provides the ability to transmit a single message to the platform for delivery to the subscriber, as well as the ability to launch mass mailings of two types of messages.

Single message delivery scenario:

Script for launching a regular type of mass mailing (batch or broadcast):

Script for launching a sync type of mass mailing (batch or broadcast):

1.2 Sending a separate messages:
Parameter Value
URLof the API [JSONv2_URL]/{client_id}/json2/simple
Method POST
HTTPAuthentication Basic
Mandatory header Content-Type: application/json

Request parameters are divided into two types: mandatory and optional. If at least one mandatory parameter is missing, the request is not accepted by the platform. Each message transmission channel has its own unique parameters. Description of all request parameters see below

Request
{
"phone_number": 79651111111,
"extra_id": "AD-6640-7006",
"callback_url": "https://send-dr-here.com",
"start_time": "2020-12-12 10:10:10+03:00",
"tag": "Campaign name",
"channels": [
"sms"
],
"channel_options": {
"sms": {
"text": "Text for SMS",
"alpha_name": "Test",
"ttl": 300
}
}
}

HTTP status 200 OK means that your request was successfully processed by the server.

Response

If the request is correct, you will receive the following response:

{"message_id":"9f60ac8f-e721-5027-b838-e6fcb95fcd7a"}

If the request contains an error or does not match the connection settings, you will receive the following response:

{"error_code":36024,"error_text":"Phone number incorrect"}

For a description of the response parameters, see below.

1.3 Bulk messaging

The JSONv2 protocol provides the ability to launch a mass messaging service with a single request. The maximum number of recipients in a single request is 50,000.

A batch messaging requestcontains a perspersonalized message text across all communication channels for each user.

Broadcast requestcontains general text and variables that contain personalized values ​​and can be used for all request parameters

Parameter Value
Batch-URL of the API [JSONv2_URL]/{client_id}/json2/batch or
[JSONv2_URL]/{client_id}/json2/batch/sync
Broadcast-URL of the API [JSONv2_URL]/{client_id}/json2/broadcast or
[JSONv2_URL]/{client_id}/json2/broadcast/sync
Method POST
HTTPAuthentication Basic
Mandatory header Content-Type: application/json

The platform returns a response to the request (see Response to a request to send bulk messages).

1.3.1 Sending a request for batch SMS messaging

Example of a request for batch SMS messaging:

{
"messages": [
{
"phone_number": 79651111111,
"extra_id": "AD-6640-7006",
"text": "Text for all channels, recipient #79651111111"
},
{
"phone_number": 79652222222,
"extra_id": "AD-6640-7007",
"text": "Text for all channels, recipient #79652222222"
}
],
"start_time": "2020-12-12 10:10:10+03:00",
"tag": "Campaign name",
"channels": [
"sms"
],
"channel_options": {
"sms": {
"alpha_name": "Test",
"ttl": 300
}
}
}

HTTP status 200 OK means that your request was successfully processed by the server.

1.3.2 Sending a request for broadcast SMS messages

Example of a request for broadcast SMS messages:

{
"recipients": [
{
"phone_number": 79651111111, 
"extra_id": "AD-6640-7006",
 "name": "Michael",
 "greeting": "Mr."
 },
 {
 "phone_number": 79652222222,
 "extra_id": "AD-6640-7007",
 "name": "Zoya",
 "greeting": "Ms."
 }
 ],
 "start_time": "2020-12-12 10:10:10+03:00",
 "tag": "Campaign name",
 "channels": [
 "sms"
 ],
 "channel_options": {
 "sms": {
 "text": "Dear %greeting% %name%! Here is an SMS",
"alpha_name": "Test",
"ttl": 300
}
}
}

You can use variables in the text. The variable name can be arbitrary and is indicated between the “%” symbols. Variables with their values ​​for substitution must be specified in the “recipients” section. The number of variables in the text is unlimited. But there is a limit on the length of the message, and it must meet the following parameters:

{
"recipients": [
{
"phone_number": 79651111111,
"extra_id": "AD-6640-7006",
"name": "Michael",
"greeting": "Mr. "
 },
 {
 "phone_number": 79652222222,
 "extra_id": "AD-6640-7007",
 "name": "Zoya",
 "greeting": "Ms."
 }
 ],
 "start_time": "2020-12-12 10:10:10+03:00",
 "tag": "Campaign name",
 "channels": [
 "sms"
 ],
 "channel_options": {
 "sms": {
 "text": "Dear %greeting% %name%! Here is an SMS",
"alpha_name": "Test",
"ttl": 300
}
},
"sms_cyrillic": {
"min": 0,
"max": 1340
},
"sms_latin": {
"min": 0,
"max": 3060
}
}

HTTP status 200 OK means that your request was successfully processed by the server.

1.3.3 Response to a request for mass messaging

If the request is sent to URL[JSONv2_URL]/{client_id}/json2/broadcastor [JSONv2_URL] /{client_id}/json in response you will receive the campaign identifier (ID) in the following format:

{"job_id": "66591729-cb47-5ef9-964b-949dc6aff84f"}

Using this job_id you can request a report on the status of the campaign (mailing list).

If the request is sent to the URL [JSONv2_URL]/{client_id}/json2/broadcast/sync or [JSONv2_URL] /{client_id} you will receive details for each message, with their “message_id”:

{
"messages": [
{
"processed": true,
"phone_number": "79651111111",
"message_id": "9f60ac8f-e721-5027-b838-e6fcb95fcd7a",
 "extra_id": "AD-6640-7006",
 "accepted": true
 },
 {
 "processed": true,
 "phone_number": "79652222222",
"message_id": "e5ea7286-6849-52d7-9e1b-8719b736283e",
"extra_id": "AD-6640-7007",
"accepted": true
}
]
}

See below for a description of the response parameters.

1.3.4 Request for a campaign status report

A campaign status request allows you to get information about the status of your campaign (mailing list)

Parameter Value
Get Job status URL [JSONv2_URL]/{client_id}/json2/job/{job_id}
Method GET
HTTP Authentication Basic

Campaign status example:


{
 "messages": [
 {
 "time": 1477417299000,
 "phone_number": "79652222222",
 "message_id": "e5ea7286-6849-52d7-9e1b-8719b736283e",
 "extra_id": "AD-6640-7007",
 "processed": false,
 "accepted": true,
 "total_sms_parts": 1,
 "error_text": "SMS expired",
 "error_code": 35015
 },
 {
 "time": 1477417294667,
 "phone_number": "79651111111",
 "message_id": "9f60ac8f-e721-5027-b838-e6fcb95fcd7a",
 "extra_id": "AD-6640-7006",
 "processed": false,
 "accepted": true,
 "total_sms_parts": 1,
"delivered_sms_parts": 1,
"status_text": "SMS delivered",
"status": 2,
"substatus": 23,
"msghub_status": 23011
}
]
}

HTTP status 200 OK means that your request was successfully processed by the server

See below for a description of the report parameters

1.4 Message delivery report

1.4.1 Receiving a delivery report for a single message

As soon as the status is updated in the system, the report is sent to your URL in the format JSON. The report contains the final status of the message.

Example report:

{
"number": 79651111111,
"time": 1477417294667,
"status": 2,
"substatus": 23,
"msghub_status": 23011,
"message_id": "9f60ac8f-e721-5027-b838-e6fcb95fcd7a",
"extra_id": "AD-6640-7006",
"sent_via": "sms"
}

See below for description of report parameters

1.4.2 Receiving a batch mailing report

As soon as the status is updated in the system, the message delivery reports are saved in a batch. The package is sent to your URL in JSON format (HTTP, HTTPS). The number of reports in the package and the frequency of their sending are configured on the platform side

Example report:


[
{
"number": "79651111111",
"time": 1477417294667,
"status": 2,
"substatus": 23,
"msghub_status": 23011,
"message_id": "9f60ac8f-e721-5027-b838-e6fcb95fcd7a",
"extra_id": "AD-6640-7006",
"sent_via": "sms"
},
{
"number": "79652222222",
"time": 1477417299000,
 "status": 3,
 "substatus": 35,
 "msghub_status": 35015,
 "message_id": "e5ea7286-6849-52d7-9e1b-8719b736283e",
 "extra_id": "AD-6640-7007",
 "sent_via": "sms"
 },
 {
 "number": "79653333333",
 "time": 1477417299050,
 "status": 2,
 "substatus": 23,
 "msghub_status": 23033,
 "message_id": "8a3ff6c5-a1fb-4849-a54b-3c488753cb8b",
"extra_id": "AD-6640-7008",
"sent_via": "sms"
}
]

See below for a description of the report parameters

1.5 Request a delivery report for a single message

The delivery report includes the final status of the message.

Parameter Value
Get Detailed DR URLs [JSONv2_URL]/{client_id}/dr/{message_id}/advanced or [JSONv2_URL]/{client_id}/dr/external/{extra_id}/advanced
Get Simple DR URLs [JSONv2_URL]/{client_id}/dr/{message_id}/simple or [JSONv2_URL]/{client_id}/dr/external/{extra_id}/simple
Method GET
HTTP Authentication Basic
1.5.1 Requesting a simple delivery report

A simple message delivery report can be requested by message ID (the platform-generated “message_id” parameter) or by an additional ID (the client-defined “extra_id” parameter).

To get a report by message ID, use the following URL:

[JSONv2_URL]/{client_id}/dr/{message_id}/simple

To get a report using an additional ID, use the followingfollowing URL:

[JSONv2_URL]/{client_id}/dr/external/{extra_id}/simple

Simple delivery report example:

{
"phone_number": "79651111111",
"last_partner": "sms",
"message_id": "9f60ac8f-e721-5027-b838-e6fcb95fcd7a",
"extra_id": "AD-6640-7006",
"time": 1477417294667,
"status": 2,
"substatus": 23,
"msghub_status": 23011,
"total_sms_parts": 1,
"delivered_sms_parts": 1
}

HTTP status 200 OK means that your request was successfully processed by the server.

See below for a description of the report parameters

1.5.2 Requesting a detailed delivery report

A detailed message delivery report can be requested by message ID (the “message_id” parameter generated by the platform) or by an additional identifier (the “extra_id” parameter specified by the client application).

To get a report by message ID, use the following URL:

[JSONv2_URL]/{client_id}/dr/{message_id}/advanced

To get a report using an additional identifier, use the following URL:

[JSONv2_URL]/{client_id}/dr/external/{extra_id}/advanced

Example of a detailed delivery report:

{
"reports": [
{
"phone_number": "79651111111",
"message_id": "9f60ac8f-e721-5027-b838-e6fcb95fcd7a",
"extra_id": "AD-6640-7006",
"time": 1477417294667,
 "last_partner": "sms",
 "status": 3,
 "substatus": 35,
 "msghub_status": 35015
 },
 {
 "phone_number": "79651111111",
 "message_id": "9f60ac8f-e721-5027-b838-e6fcb95fcd7a",
 "extra_id": "AD-6640-7006",
 "time": 1477417294667,
 "last_partner": "sms",
 "status": 2,
 "substatus": 23,
 "msghub_status": 23011,
 "total_sms_parts": 1,
 "delivered_sms_parts": 1
 }
],
"started": true,
"processing": false,
"delivered_via": "sms",
"channels": [
{
"channel": "sms",
"ttl": 300
}
]
}

If the message has not been sent to any of the communication channels or does not yet have the final delivery status, the message status is -1.

HTTP status 200 OK means that your request was successfully processed by the server

See below for a description of the report parameters

1.6 SMS encoding
Scheme encoding Short SMS text length in message segment Long SMS text length in message segment Supported
GSM7-bitdefault alphabet(GSM03.38)* 160 characters 153 characters Yes
UCS2(ISO/IEC-10646) 16-bit 70 characters 67 characters Yes

* message segment lengths are specified based on the use of symbols from the default 7-bit GSM alphabet table. In this case, it should be noted that when using the symbols of the extended table of the default GSM 7-bit alphabet, the length of the message segments will decrease, since each symbol of the extended table is transmitted as two octets and is counted as two symbols

Extended table of the default GSM 7-bit alphabet symbols:

Hex Dec Symbol name Symbol
0x1B0A 27 10 FORM FEED (PAGE BREAK)  
0x1B14 27 20 CIRCUMFLEX ACCENT ^
0x1B28 27 40 LEFT CURLY BRACKET {
0x1B29 27 41 RIGHT CURLY BRACKET }
0x1B2F 27 47 REVERSE SOLIDUS (BACKSLASH) \
0x1B3C 27 60 LEFT SQUARE BRACKET [
0x1B3D 27 61 TILDE ~
0x1B3E 27 62 RIGHT SQUARE BRACKET ]
0x1B40 27 64 VERTICAL BAR |
0x1B65 27 101 EURO SIGN
0x1B1B 27 27 RESERVED  
1.7 Description of request and response parameters

Descriptionrequest parameters:

Title Required Description
Basic
phone_number Yes User's phone number. Provided in international format without the “+” sign
channels Yes List of message delivery channels.
channel_options Yes Must be specified for each communication channel
messages Yes List of recipients’ phone numbers and message texts that will be used for all communication channels. For batch mailing request
recipients Yes List of parameters for a personalized campaign. For broadcast request
extra_id No External message identifier (set by the client application). Maximum length: 64 characters
callback_url No Message reports will be sent to this URL. Maximum length: 256 characters
start_time No The planned start date of the campaign. Should be specified in the following format: “YYYY-MM-DD hh:mm:ss±hh:mm”. If the difference with Greenwich Mean Time (in the format +03:00) is not specified, then the difference is calculated based on the local provider's time
tag No Campaign name. Maximum length: 64 characters
is_promotional No Boolean value (true/false). Advertising message flag. The value is true, the message is advertising. The value is false, the message is not advertising.
ctr No Boolean value (true/false). If the flag is enabled, links are substituted to count the number of clicks on links in the message. If true, links are replaced. If false, links are not replaced.
Channel parameters
SMS
Title Required Description
text Yes Text of the SMS message. Requirements for the text - Cyrillic characters (up to 1005 characters), Latin characters (up to 2295 characters)
ttl Yes Message lifetime in seconds: SMS: 300..259200
alpha_name Yes Alphanumeric name. Maximum length - 11 characters, may begin with a number. Alphanumeric name can only consist of 7-bit characters of the default GSM alphabet table

Description of response parameters:

Name Description
message_id Message identifier. Specified in UUID format
phone_number User's phone number. Specified in international format without the “+” sign
extra_id External message identifier (parameter specified by the client application)
job_id Campaign identifier. Set in UUID format
error_code Error code. The values ​​are configured in the platform web interface in the section "Administration" → "Module settings" → "Error codes" on the "Incoming" tab (the full_status column)
error_text Brief description of the error code
processed Boolean value (true/false). True only if the message is being processed. False if message processing has not started
accepted Boolean value (true/false). True only if the message is accepted by the platform. False if the message is rejected by the platform

Description of message delivery report parameters:

Title Description
phone_number User's phone number. Specified in international format without the “+” sign
message_id Message identifier
extra_id External message identifier (parameter specified by the client application)
status ProMessage status. See the list of statuses below.
substatus Extended message status. See the list of statuses below.
msghub_status Detailed message status. The values ​​are configured in the platform web interface in the section "Administration" → "Module settings" → "Error codes" on the "Incoming" tab (the full_status column).
sent_via Last message delivery channel. If the message is blocked by the platform, the field value is “msghub”
total_sms_parts Total number of SMS message parts
delivered_sms_parts Number of delivered SMS message parts. If no messages were sent to the SMS channel, this parameter is missing
status_text Brief description of the message status
error_text Brief description of the error
error_code Error code. The values ​​are configured in the platform web interface in the section “Administration” → “Module settings” → “Error codes” on the “Incoming” tab (the full_status column).
processed Boolean value (true/false). The value is true if the message is being processed. The value is false if the message processing has not started
accepted Boolean value (true/false). The value is true only if the message is accepted by the platform. The value is false if the message is rejected by the platform
last_partner The last channel for delivering the message. If the message is blocked by the platform, the value of the field is “msghub”. For a detailed (extended) report, this parameter is set for each communication channel
delivered_via The last channel for delivering the message. If the message was received but did not receive the final status or was blocked by the platform, the value of the “msghub” field
started Boolean value (true/false). The value is false if the message processing has not started or started with a delay
processing Boolean value (true/false). The value is true if the message is being processed. Value false if message processing has not started or has already completed
channel Message sending channel
ttl Message lifetime in seconds for each channel
1.8 Message statuses

This section provides a basic list of statuses that can be changed by the system owner.

Simplified meaning of “status” - status:

Extended meaning of “substatus” - substatuses:

Code Status
1 Message is being delivered- Message is being delivered
2 Message delivered- Message delivered
3 Message processing or delivering error- Message processing or delivery error
Code Status
10 Message is not accepted for processing- Message is not accepted for processing
12 Message is accepted for processing- Message is accepted for processing
23 Message delivered- Message delivered
24 Message has not been delivered within TTL- Message has not been delivered within TTL
28 Message has not been delivered within TTL- Message has not been delivered within TTL
35 Message has not been delivered within TTL- Message has not been delivered within TTL
36 Message delivery error- Message delivery error