SMS API
Sending an SMS
Discover how to easily send SMS using MailerSend's SMS API. Start sending SMS today and reach your customers instantly. Learn more now.
This endpoint allows you to start sending SMSs through MailerSend SMS API.
Send an SMS
This endpoint allows you to send an asynchronous SMS. It returns the status of the SMS sent with a X-SMS-Message-Id that can be used to continuously query for the status using the SMS API.
Send an SMS using this POST request:
POST https://api.mailersend.com/v1/smsRequest Body
{
"from": "+19191234567",
"to": [
"+19191234567",
"+19199876543"
],
"text": "Hey {{name}}! This is just a friendly hello :D",
"personalization": [
{
"phone_number": "+19191234567",
"data": {
"name": "Dummy"
}
},
{
"phone_number": "+19199876543",
"data": {
"name": "Not Dummy"
}
}
]
}Request parameters
JSON parameters are provided in dot notation
| JSON parameter | Type | Required | Limitations | Details |
|---|---|---|---|---|
from | string | yes | Number belonging to your account in E164 format | |
to | string[] | yes | min:1,max:50 | Must not contain duplicate numbers. |
to.* | string | yes | US, CA | The phone number(s) the message should be sent to in E164 format. If from is a trial number, each number must be a verified recipient. |
text | string | yes | Max lenght:2048 | The contents of the text message. Must be 2048 characters or less. The characters (, ), [, ], < and > are not allowed. If the body of your message is more than 160 GSM-7 characters or 70 UCS-2 characters, MailerSend will split the message into a segmented SMS and add a special header (User Data Header). Please note you are billed by segment. The User Data Header (UDH) takes up 6 bytes and instructs the receiving device how to reassemble the segments so that your whole message will be shown as one SMS on the receiving handset. The maximum number of characters per concatenated (long) message is slightly reduced due to the inclusion of concatenation headers (UDH). You can see the difference between GSM-7 and UCS-2 and how they're segmented here. |
personalization | object[] | no | Allows using personalization in {{ var }} syntax. Can be used in the text fields. Read more about advanced personalization. | |
personalization.*.phone_number | string | yes | Phone number that personalization will be applied to. Must be one of the numbers in to. | |
personalization.*.data | object | yes | Object with key: value pairs. Values will be added to your template using {{ key }} syntax. Keys cannot contain dots (.). |
Responses
Sending queued
Response Code: 202 Accepted
Response Headers:
Content-Type: text/plain; charset=utf-8
X-SMS-Message-Id: 5e42957d51f1d94a1070a733
Response Body: [EMPTY]Sending paused
Response Code: 202 Accepted
Response Headers:
Content-Type: text/plain; charset=utf-8
X-SMS-Message-Id: 5e42957d51f1d94a1070a733
X-SMS-Send-Paused: true
Response Body: [EMPTY]Validation error
Response Code: 422 Unprocessable Entity
Response Headers:
content-type: application/json{
"message": "The given data was invalid.",
"errors": {
"from": [
"The from field contains an invalid number."
]
}
}See - Validations errors