# SMS API

import { Badge } from '@astrojs/starlight/components';

<Aside type="caution" title="/createSMSMessage is deprecated">
New integrations should use [Messaging API v2](/developer/api-reference/messaging-api-v2/) — pass `platforms: ["SMS"]` to `Notify`. See the [migration guide](/developer/api-reference/messaging-api-v2/migration-from-v1/#from-createsmsmessage).
</Aside>

<Aside type="note">
Before sending SMS messages, connect your SMS provider in the Control Panel. [Learn more](/developer/first-steps/connect-messaging-services/sms-configuration/)
</Aside>

## createSMSMessage <Badge text="Deprecated" variant="caution" size="small" />

Used to send SMS notifications to users

POST `https://api.pushwoosh.com/json/1.3/createSMSMessage`

### Request body

| Name                           | Required | Type    | Description                                                                                                  |
|--------------------------------|----------|---------|--------------------------------------------------------------------------------------------------------------|
| **auth***                      | Yes      | string  | [API access token](/developer/api-reference/api-identifiers/#api-access-token) from Pushwoosh Control Panel.                                                               |
| **application***               | Yes      | string  | [Pushwoosh application code](/developer/api-reference/api-identifiers/#application-code)                                                                                 |
| **notifications***             | Yes      | array   | Content settings. JSON array of message parameters. See details below.                                       |

**Notification parameters**

| Name                             | Required | Type    | Description                                                                                                                                                                                   |
|----------------------------------|----------|---------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **send_date***                   | Yes      | string  | Date and time to send the notification. Use format `YYYY-MM-DD HH:mm` or `now` to send immediately.                                                                                           |
| **content***                     | Yes      | string  | Text content of the SMS message.                                                                                                                                                              |
| **devices***                     | Yes      | array   | Customer phone number (must be associated with a UserId using `/registerDevice` and specified in the `hwid` parameter or use `use_auto_registration`). Only one number can be specified here. |
| **use_auto_registration**        | No       | boolean | If set to `true` the phone number specified in the `devices` parameter will be automatically registered.                                                                                      |
| **dynamic_content_placeholders** | No       | object  | Dynamic content placeholders to customize the message content. Each placeholder will be replaced with corresponding dynamic values.                                                           |
| **preset**                       | No       | string  | SMS [Preset Code](/developer/api-reference/api-identifiers/#preset-code) from your Control Panel.                                                                                                                                                      |

### Request example

```json
{
  "request": {
    "application": "12345-67891",    // required. Pushwoosh application code.
    "auth": "yxoPUlwqm…………pIyEX4H",  // required. API access token from Pushwoosh Control Panel.
    "notifications": [{
      "send_date": "now",            // required. YYYY-MM-DD HH:mm OR "now".
      "content": "Hello!",           // required. SMS text (string).
      "devices": ["+1234567890"],    // required. Customer phone number (must be associated with
                                     //           a UserId using. /registerDevice and specified in
                                     //           the "hwid" parameter or use "use_auto_registration").
                                     //           Only one number can be specified here.
      "preset": "XXXXX-XXXXX",       // optional. SMS Preset Code from your Control Panel.
      "use_auto_registration": true  // optional. Automatically register phone number specified
                                     //           in "devices" parameter.
    }]
  }
}
```

### Response example

```json
{
  "status_code": 200,
  "status_message": "OK",
  "response": {
    "Messages": [
      "9648-0B10ECB6-0D9F214D"
    ]
  }
}
```

### Error response
```json
{
  "status_code": 210,
  "status_message": "Invalid devices list. \"devices\" must be an array.",
  "response": {
    "Messages": []
  }
}
```

<Aside type="note">
 Currently, each SMS must be sent in a separate request for each customer.
</Aside>

To get SMS statistics, use the [totalsByIntervals](/developer/api-reference/statistics-api/message-statistics-api/#totalsbyintervals) method.

You can also view statistics for each message in the [Message History](/product/statistics-and-analytics/message-history/) section.

<Aside type="caution">
Please note that some mobile operators do not transmit delivery status data, so the statistics may need to be more accurate. You can check the details with the mobile operators that provide numbers to your customers.
</Aside>