Send a Multipart SMS (over the character limit)

A standard SMS contains at most 160 characters (Note: The limit is 70 characters when sending Unicode messages). Even though text messages are limited in length, most mobile handsets can display messages longer than the text limit. To the sender and receiver, it is a seamless user experience and feels like you are sending and receiving entire messages at once regardless of the length. In order to ensure that long messages are delivered in its entirety, the SMS service provider needs to support the automatic splitting and concatenation of long SMS messages.

Plivo API’s support sending SMS in all text based languages (e.g., English, French, Chinese, Arabic, etc.). All of Plivo server-side SDKs automatically encode messages into Unicode UTF-8 as needed.

Note:Plivo's Message API breaks long SMS text messages into multiple SMS and adds a concatenation header to each message so that it can be stitched together (i.e., concatenated) at receiver's mobile device. Though, some carriers and handsets do not support long SMS concatenation.

SMS Message Length Limits

Depending on the language you are sending in, SMS text messages are limited to either 70 or 160 characters in length. This is because a standard SMS message can contain a maximum of 1120 bits. Latin-based languages such as English, French, and Spanish use GSM encoding, which equates to 7 bits per character; limiting 1 SMS to at most 160 characters. Languages that use Unicode Transformation Format (UTF) encoding such as Chinese, Arabic, or Japanese uses 16 bits per character; limiting 1 SMS to a maximum of 70 characters. Messages containing more than the allowed characters are automatically split and concatenated on the receivers end.

Long Message Delivery Reports

When checking Message Logs and Delivery Reports for long SMS messages that are split, look for the ParentMessageUUID, which is the same in all split messages and identical to the UUID of the first message in the split sequence of messages. Check out our guide on Handling SMS Delivery Reports for details on how to receive delivery reports.

To send an SMS, make an HTTP POST request to the Message API.

POST https://api.plivo.com/v1/Account/{auth_id}/Message/


Advanced Hack: Check out our Message API docs to see how you can get the details of a single message or all your messages in a single `GET` request.

Getting Started

  1. Sign up for a free Plivo trial account.
  2. Check out our server-side SDKs page and install the right helper based on the programming language you want to use.
  3. Buy a Plivo phone number (optional).
    Note: A phone number is required only for sending SMS to US and Canadian phone numbers. However, country-specific carrier conditions may still apply. You can buy a US or Canadian phone number through the Buy Numbers tab on your Plivo account UI.
  4. Use a web hosting service to host your web application. There are many inexpensive cloud hosting providers that you can use for just a few dollars a month. Follow the instructions of your hosting provider to host your web application.
    Note: If you are using a Plivo Trial account for this example, you can only send sms to phone numbers that have been verified with Plivo. Phone numbers can be verified at the Sandbox Numbers page.

Implementation

  1. Copy the relevant code below into a text file and save it.
  2. Replace 'Your AUTH_ID' and 'Your AUTH_TOKEN' with the AUTH ID and AUTH TOKEN found on your Plivo dashboard.
  3. Add your 'src' (source) phone number. This will show up as your Sender ID. Be sure that all phone numbers include country code, area code, and phone number without spaces or dashes (e.g., 14153336666).
    Note: You can send SMS text messages to any country using the Message API and set any 'src' number except for US and Canadian numbers. In order to send text messages to phones in the US or Canada, you will need to purchase a US or Canadian phone number from Plivo and use it as the 'src' number. You can buy a Plivo number from the Buy Numbers tab on your Plivo account dashboard.
  4. Add your 'dst' (destination) phone numbers. These are the phone numbers you wish to send SMS text messages to. You may send SMS text messages to multiple destinations by using the “<” character (e.g., 2222222222<3333333333).
    Note: If you are using a trial account, your destination number needs to be verified with Plivo. Phone numbers can be verified at the Sandbox Numbers page.
  5. Edit the 'text' field with your SMS text message.
    Note: Text messages that are longer than 160 characters are concatenated and billed separately as individual text messages.
  6. Make the 'HTTP POST' request to Plivo. If successful, Plivo will queue your SMS deliver it to your recipients at a base rate of 1 message per second.
    Check out our full Message API docs to see all the parameters and functionalities you can use.

Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import plivo

client = plivo.RestClient("auth_id", "auth_token")
response = client.messages.create(
    powerpack_uuid='your_powerpack_uuid',
    dst='+14152223333',
    text='This randomly generated text can be used' +
    'in your layout(webdesign, websites, books, posters ...) for free.' +
    'This text is entirely free of law. Feel free to link to this site by using the'
    + 'image below or by making a simple text link',
    url='http://foo.com/sms status/',
)
print(response)
# prints only the message_uuid
print(response.message_uuid)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
require "plivo"
include Plivo

api = RestClient.new("auth_id", "auth_token")
response = api.messages.create(
  nil, #from
  ["+14151112222"], #to
  "This randomly generated text can be used in your layout (webdesign , websites, books, posters ... )
    for free. This text is entirely free of law. Feel free to link to this site by using
    the image below or by making a simple text link", #text
  { url: "http://foo.com/sms status/" },
  "your_powerpack_uuid",
)
puts response
#Prints only the message_uuid
puts response.message_uuid
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
var plivo = require('plivo');

(function main() {
    'use strict';
    var client = new plivo.Client("auth_id", "auth_token");
    client.messages.create(
        null, //from
        "+14151112222", // to
        "This randomly generated text can" +
        "be used in your layout (webdesign , websites, books, poclesters ... )for free." +
        "This text is entirely free of law.Feel free to link to this site by using" +
        "the image below or by making a simple text link", // text
        {
            method: "GET",
            url: "http://foo.com/sms status/"
        },
        "your_powerpack_uuid"
    ).then(function (response) {
        console.log(response);
        //Prints only the message_uuid
        console.log(response.messageUuid);
    }, );
})();
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php
require 'vendor/autoload.php';
use Plivo\RestClient;

$client = new RestClient("auth_id", "auth_token");
$response = $client->messages->create(
  null, //from
  ['+14152223333'], //to
  'This randomly generated text can be used in your layout (webdesign , websites, books, posters ... )
  for free. This text is entirely free of law. Feel free to link to this site by using the image below
  or by making a simple text link', //text
  ["url"=>"http://foo.com/sms status/"],
  'your_powerpack_uuid'
);
print_r($response);
// Prints only the message_uuid
print_r($response->getmessageUuid(0));
?>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import java.io.IOException;
import java.net.URL;
import java.util.Collections;

import com.plivo.api.Plivo;
import com.plivo.api.exceptions.PlivoRestException;
import com.plivo.api.models.message.Message;
import com.plivo.api.models.message.MessageCreateResponse;

class MultiPart {
    public static void main(String[] args) {
        Plivo.init("auth_id", "auth_token");
        try {
            MessageCreateResponse response = Message.creator(Collections.singletonList("+14151112222"),
                    "This randomly generated text can be used in your layout (webdesign , websites, books, posters ... )"
                            + "for free. This text is entirely free of law."
                            + "Feel free to link to this site by using the image below or by making a simple text link",
                    "your_powerpack_uuid").url(new URL("http://foo.com/sms_status/")).create();

            System.out.println(response);
            // Prints only the message_uuid
            System.out.println(response.getMessageUuid());
        } catch (PlivoRestException | IOException e) {
            e.printStackTrace();
        }
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package main

import "fmt"
import "github.com/plivo/plivo-go"

func main() {
	client, err := plivo.NewClient("auth_id", "auth_token", &plivo.ClientOptions{})
	if err != nil {
		panic(err)
	}
	response, err := client.Messages.Create(
		plivo.MessageCreateParams{
			PowerpackUUID: "your_powerpack_uuid",
			Dst:           "+14151112222",
			Text: "This randomly generated text can be used in your layout" +
				"(webdesign , websites, books, posters ... )for free. This text is entirely free of law." +
				"Feel free to link to this site by using the image below or by making" +
				"a simple text link",
			URL: "http://foo.com/sms_status/",
		},
	)
	if err != nil {
		panic(err)
	}
	fmt.Printf("Response: %#v\n", response)
	// Prints only the message_uuid
	fmt.Printf("Response: %#v\n", response.MessageUUID)
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
using System;
using System.Collections.Generic;
using Plivo;
using Plivo.Exception;

namespace PlivoExamples
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            var api = new PlivoApi("auth_id", "auth_token");

            var response = api.Message.Create(
                powerpack_uuid: "your_powerpack_uuid",
                dst: new List<String> { "+14152223333" },
                text: "This randomly generated text can be used in your layout (webdesign , websites, books, posters ... )" +
                +"for free. This text is entirely free of law. Feel free to link to this site by using the image below or by making a simple text link," +
                +"Long text in English",
                url: "http://foo.com/sms_status/"
            );
            Console.WriteLine(response);
            // Prints the message_uuid
            Console.WriteLine(response.MessageUuid[0]);

        }
    }
}
1
2
3
4
curl -i --user auth_id:auth_token \
-H "Content-Type: application/json" \
-d '{"powerpack_uuid": "your_powerpack_uuid","dst": "+14152223333", "text": "This randomly generated text can be used to test the splitting of Long SMS. SMS splitting information will be present in the url and also in the message logs.","url":"http://foo.com/sms_status/"}' \
https://api.plivo.com/v1/Account/{auth_id}/Message/

Next Step

Learn how to send multiple (bulk) SMS with a single API request.

  1. Send a Single SMS
  2. Send a Long SMS
  3. Send Multiple (Bulk) SMS
  4. Send an SMS with Alphanumeric Sender ID
  5. Receive an SMS
  6. Reply to an Incoming SMS
  7. Forward an Incoming SMS
  8. Get Details of all Messages
  9. Get Details of a Single Message
  10. Handling SMS Delivery Reports
  11. Forward SMS to Email