# Sending SMS, Viber, Flash SMS, WAP-Push

## Sending SMS, Viber, Flash SMS, WAP-Push

<mark style="color:green;">`POST`</mark> `http://lk.mysmpp.ru/json`

#### Headers

| Name                                           | Type   | Description                     |
| ---------------------------------------------- | ------ | ------------------------------- |
| Content-type<mark style="color:red;">\*</mark> | String | **`text/json; charset=utf-8;`** |

#### Request Body

| Name                                                    | Type   | Description                                                                                                                                                                                                                                                                                                                                                |
| ------------------------------------------------------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| login<mark style="color:red;">\*</mark>                 | String | Your login in the system                                                                                                                                                                                                                                                                                                                                   |
| password<mark style="color:red;">\*</mark>              | String | Your password in the system                                                                                                                                                                                                                                                                                                                                |
| token<mark style="color:red;">\*</mark>                 | String | You can use a secret key instead of login and password. To obtain it, please contact your manager.                                                                                                                                                                                                                                                         |
| message.type\_send\_1<mark style="color:red;">\*</mark> | String | Type of message to be sent **`viber`** or **`sms`**                                                                                                                                                                                                                                                                                                        |
| message.sender<mark style="color:red;">\*</mark>        | String | <p>SMS sender.  <br><mark style="color:orange;">This is the value that will be displayed on the subscriber's phone in the SMS from whom field</mark></p>                                                                                                                                                                                                   |
| message.phones.phone<mark style="color:red;">\*</mark>  | Int    | Number of the subscriber to whom the SMS is addressed                                                                                                                                                                                                                                                                                                      |
| message.phones.client\_id\_sms                          | Int    | <p>Number assigned by the client </p><p><mark style="color:orange;">Allows to avoid repeated sending. If an SMS with the same number has already been sent from this account, it will not be sent again, but the number of the previously sent SMS will be returned.</mark></p>                                                                            |
| message.text<mark style="color:red;">\*</mark>          | String | Regular SMS text or WAP link description                                                                                                                                                                                                                                                                                                                   |
| message.phones.validity\_period                         | Date   | <p>The date and time after which no attempts will be made to deliver SMS in the format:</p><p><em>YYYY-MM-DD HH:MM:SS</em></p><p>where,<br>    YYYY - year,<br>    MM - month,<br>    DD - day,<br>    HH - hours, </p><p>    MM - minutes</p><p>    SS - seconds</p><p><mark style="color:orange;">If not set, the SMS has a maximum lifetime.</mark></p> |

{% tabs %}
{% tab title="200: OK In case the correct JSON document is received" %}

```json
{
    "information":
        [
            {
                "state": "Status", 
                "id_sms": "SMS ID in the system to check the status",
                "error": "Error message."
            },
            {
                "state": "Status", 
                "id_sms": "SMS ID in the system to check the status",
                "error": "Error message."
            }
        ]
}
```

{% endtab %}

{% tab title="400: Bad Request If an error occurs in the sent JSON document" %}

```json
{
    "error": "Error message."
}
```

{% endtab %}
{% endtabs %}

### Deciphering parameters in query responses

<table><thead><tr><th width="138.33333333333331">Parameter</th><th width="133">Data type</th><th>Description</th></tr></thead><tbody><tr><td>state</td><td>String</td><td>Message status ("send"), if SMS has been sent</td></tr><tr><td>id_sms</td><td>Int</td><td><p>SMS message number. It is used to check the status of SMS. </p><p><mark style="color:orange;">If an error occurred while sending SMS, id_sms is not transmitted</mark></p></td></tr><tr><td>error</td><td>String</td><td><p>Error text for response status <mark style="color:green;"><strong>200</strong></mark>: </p><ul><li>Incorrect JSON document format </li><li>Your account is locked Incorrect login or password </li><li>POST data is missing</li></ul><p>Error text at response status <mark style="color:red;"><strong>400</strong></mark>: </p><ul><li>We have run out of SMS. Contact your manager to resolve the problem </li><li>Out of SMS </li><li>Account blocked </li><li>Specify phone number </li><li>Phone number is on the stop list </li><li>This destination is closed for you </li><li>This destination is closed </li><li>SMS text rejected by moderator </li><li>No sender </li><li>The sender must not exceed 15 characters for numeric numbers and 11 characters for alphanumeric numbers </li><li>Phone number must be less than 15 characters </li><li>No message text </li><li>No link </li><li>Provide the name of the contact and at least one parameter for a business card </li><li>There is no such sender </li><li>The sender has not been moderated</li></ul></td></tr></tbody></table>

### Example of a sending request&#x20;

{% code lineNumbers="true" fullWidth="false" %}

```json
{
    "login": "login",
    "password": "password",
    "token": "token",
    "message": [
        {
            "type_send_1":"sms",
            "sender":"sender 1",
            "text":"message text 1",
            "phones":[
                {
                    "phone":"79612242243",
                    "client_id_sms":"101",
                    "validity_period":"2001-12-31 15:34:54"
                },
                {
                    "phone":"79612242244",
                    "client_id_sms":"102",
                    "validity_period":"2001-12-31 15:34:54"
                }
            ]
        },
        {
            "type_send_1":"sms",
            "sender":" sender 2",
            "text":"message text 2",
            "phones":[
                {
                "phone":"79612242245",
                    "client_id_sms":"103",
                    "validity_period":"2001-12-31 15:34:54"
                }
            ]
        }
    ]
}
```

{% endcode %}
