Bulk Messaging

It is possible to send one message to multiple destination numbers via a single API request using Plivo’s Bulk Messaging feature.

Simply provide a list of destination numbers separated with the delimiter <. (e.g. 14156667777<14157778888<14158889999).

Each destination number is sanitized and validated. Valid destination numbers are accepted, and the list of invalid destination numbers is shared in the message response.

This send message API supports up to 1000 unique destination numbers.

Note that messages to all recipients may not be delivered instantly. This is because the messages would be dequeued for delivery based on rate limits configured for your account.

Returns

A unique message_uuid is generated for each valid destination number, and the entire list of uuids is returned in the message_uuid parameter in the response body.

The list of invalid destination numbers is returned in the invalid_number parameter in the response body.

Response

HTTP Status Code: 202

{
  "api_id": "984bc856-9231-11e7-b886-067c5485c240",
  "invalid_number": [
    "jsgf3dsjh28372"
  ],
  "message": "message(s) queued",
  "message_uuid": [
    "6da4afba-2bcf-4a87-9eff-d2f88577b0f1",
    "6da384ba-19js-aand-2h3g-r2f8ja0700f1"
  ]
}

Example Request

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(
    src='13644444296',
    dst='17652348329<17652348362',
    text='Hello, this is a sample text',
    url='http://foo.com/sms_status/',
    method='POST',
    log=False,
    type_='sms',
    trackable=True,
    # powerpack_uuid='2dca8f70-1387-4cbd-b97f-796717a5784b'
)
print(response)
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
require "rubygems"
require "plivo"

include Plivo
include Plivo::Exceptions

api = RestClient.new("AUTH_ID", "AUTH_TOKEN")

begin
  response = api.messages.create(
    "13644444296", #src
    ["17652348329", "17652348362"], #dst
    "Hello, this is a sample text", #text
    { url: "http://foo.com/sms_status/",
      method: "POST",
      log: false,
      trackable: true,
      type: "sms" },
    # '2dca8f70-1387-4cbd-b97f-796717a5784b', #powerpack_uuid
  )

  puts response
rescue PlivoRESTError => e
  puts "Exception: " + e.message
end
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(
        "13644444296", //src
        "17652348362<17652348329", //dst
        "Hello, this is a sample text from Plivo", // text
        {
            method: "GET",
            url: "http://foo.com/sms_status/",
            log: "true",
            type: "sms"
        },
        // "2dca8f70-1387-4cbd-b97f-796717a5784b" powerpack_uuid

    ).then(function (response) {
        console.log(response);
    }, function (err) {
        console.error(err);
    });
})();
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php
require 'vendor/autoload.php';
use Plivo\RestClient;

$client = new RestClient("AUTH_ID", "AUTH_TOKEN");

try {
    $response = $client->messages->create(
        '13644444296', #src
        ['17652348329<17652348362'], #dst
        'Hello, this is a sample text', #text
        ["url"=>"http://foo.com/sms_status/", "method"=>"POST", "type"=>"sms","log"=> "true","log"=> "true"]
        #'2dca8f70-1387-4cbd-b97f-796717a5784b' #powerpack_uuid
    );
    print_r($response);
}
catch (PlivoRestException $ex) {
    print_r(ex);
}
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
29
30
31
32
33
34
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;
import com.plivo.api.models.message.MessageType;

class BulkSMS
{
    public static void main(String [] args)
    {
        Plivo.init("AUTH_ID", "AUTH_TOKEN");
        try
        {
            MessageCreateResponse response = Message.creator("13644444296",Collections.singletonList("17652348362<17652348329"),
                    "Hello, this is a sample text"/*,"powerpack_uuid"*/)
                    .url(new URL("http://foo.com/sms_status/") )
                    .method("GET")
                    .type(MessageType.SMS)
                    .log(true)
                    .trackable(false)
                    .create();
            System.out.println(response);
        }

        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
29
30
31
32
33
34
35
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");
            try
            {
                var response = api.Message.Create(
                    src:"13644444296",
                    dst:new List<String>{"17652348373<17652348329"},
                    text:"Hello, this is sample text",
                    url:"http://foo.com/sms_status/",
                    method:"GET",
                    log:false,
                    trackable:true
                    type:"sms"
                    // powerpack_uuid:"2dca8f70-1387-4cbd-b97f-796717a5784b"

                );
                Console.WriteLine(response);
            }
            catch (PlivoRestException e)
            {
                Console.WriteLine("Exception: " + e.Message);
            }
        }
    }
}
1
2
3
4
curl -i --user AUTH_ID:AUTH_TOKEN \
    -H "Content-Type: application/json" \
    -d '{"src": "1111111111","dst": "14156667777<14157778888<jsgf3dsjh28372", "text": "Hi, text from Plivo"}' \
    https://api.plivo.com/v1/Account/{auth_id}/Message/
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{
			Src:       "13644444296",
			Dst:       "17652348329<17652348362",
			Text:      "Hello, this is a sample text",
			Type:      "sms",
			URL:       "http://foo.com/sms_status/",
			Method:    "POST",
			Trackable: true,
			Log:       "false",
			//PowerpackUUID: "2dca8f70-1387-4cbd-b97f-796717a5784b",
		},
	)
	if err != nil {
		panic(err)
	}
	fmt.Printf("Response: %#v\n", response)
}