Sending an SMS

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:


Request Body

    "from": "+19191234567",
    "to": [
    "text": "Hey {{name}}! This is just a friendly hello :D",
    "personalization": [
        "phone_number": "+19191234567",
        "data": {
          "name": "Dummy"
        "phone_number": "+19199876543",
        "data": {
          "name": "Not Dummy"
use MailerSend\MailerSend;
use MailerSend\Helpers\Builder\SmsParams;

$mailersend = new MailerSend(['api_key' => 'key']);

$smsParams = (new SmsParams())
$sms = $mailersend->sms->send($smsParams);

More examplesopen in new window

"use strict";

const MailerSend = require("../../src/MailerSend");
const SmsParams = require("../../src/SmsParams");

const mailersend = new MailerSend({
  api_key: process.env.API_KEY,

const recipients = [

const smsParams = new SmsParams()
  .setText("This is the text content");


More examplesopen in new window

from mailersend import sms_sending

api_key = "API key here"

mailer = sms_sending.NewSmsSending(api_key)

# Number belonging to your account in E164 format
number_from = "+11234567890"

# You can add up to 50 recipient numbers
numbers_to = [
text = "This is the text content"

print(mailer.send_sms(number_from, numbers_to, text))

More examplesopen in new window

package main

import (


var APIKey = "Api Key Here"

func main() {
	// Create an instance of the mailersend client
	ms := mailersend.NewMailersend(APIKey)

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	message := ms.Sms.NewMessage()
	message.SetText("This is the message content {{ var }}")

	personalization := []mailersend.SmsPersonalization{
			PhoneNumber: "client-number",
			Data: map[string]interface{}{
				"var": "foo",


	res, _ := ms.Sms.Send(context.TODO(), message)

More examplesopen in new window

import com.mailersend.sdk.MailerSend;
import com.mailersend.sdk.exceptions.MailerSendException;

public void sendSms() {
    MailerSend ms = new MailerSend();
    ms.setToken("mailersend token");
    try {
        String messageId = ms.sms().builder().from("from phone number")
        .addRecipient("to phone number")
        .text("test sms {{name}}")
        .addPersonalization("to phone number", "name", "name personalization")
    } catch (MailerSendException e) {

More examplesopen in new window

require "mailersend-ruby"

# Intialize the SMS class
ms_sms =

# Add parameters
ms_sms.add_text('This is the message content')
personalization = {
  phone_number: 'client-number',
  data: {
    test: 'Test Value'

# Send the SMS

More examplesopen in new window

Request parameters

JSON parameters are provided in dot notation

JSON parameterTypeRequiredLimitationsDetails
fromstringyesNumber belonging to your account in E164 format
to.*stringyesUS, CAThe phone number(s) the message should be sent to in E164 format
textstringyesMax lenght:2048The contents of the text message. Must be 2048 characters or less.
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 Headeropen in new window). 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 hereopen in new window.
personalizationobject[]noAllows using personalization in {{ var }} syntax. Can be used in the text fields. Read more about advanced personalization.
personalization.*.phone_numberstringyesPhone number that personalization will be applied to.
personalization.*.dataobject[]yesObject with key: value pairs. Values will be added to your template using {{ key }} syntax.


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

Last Updated: