Get Details of all Messages

Once the Message API request is successful, your SMS will be put into a queue to be sent to its destination.

To get the details of all Messages, make an HTTP GET request to the Message API.

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


Note: Long SMS messages are automatically split and concatenated into a seamless user experience. 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.
Advanced Hack: See the Message API page for full details of the API.

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.

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.

Code

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

client = plivo.RestClient("AUTH_ID","AUTH_TOKEN")
response = client.messages.list(
    limit=10,
    offset=0,
    subaccount='SUBACCOUNT_AUTH_ID',
    message_direction='outbound',
    message_state='delivered',
    message_time='2019-07-05 11:47:30',
    message_time__gt='2019-07-05 11:47:30',
    message_time__gte='2019-07-05 11:47:30',
    message_time__lt='2019-07-05 11:47:30',
    message_time__lte='2019-07-05 11:47:30',
    error_code=10,
    )
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
26
27
require "rubygems"
require "plivo"

include Plivo
include Plivo::Exceptions

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

begin
  response = api.messages.list(
    limit: 10,
    offset: 0,
    subaccount: "SUBACCOUNT_AUTH_ID",
    message_direction: "outbound",
    message_state: "undelivered",
    error_code: "00",
    message_time: "2019-07-05 11:47:30",
    message_time__gt: "2019-07-05 11:47:30",
    message_time__gte: "2019-07-05 11:47:30",
    message_time__lt: "2019-07-05 11:47:30",
    message_time__lte: "2019-07-05 11:47:30",
    error_code: "10",
  )
  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');
var p = plivo.RestAPI({
    authId: 'Your AUTH_ID',
    authToken: 'Your AUTH_TOKEN'
});

var params = {};
p.get_messages(params, function (status, response) {
    console.log('Status: ', status);
    console.log('API Response:\n', response);
});

// Filtering the records
var params1 = {
    'limit': '2', // The number of results per page
    'offset': '0', // The number of items by which the results should be offset
    'message_state': "delivered", // The state of the message to be filtered
    'message_direction': "inbound" // The direction of the message to be fltered
};
p.get_messages(params1, function (status, response) {
    console.log('Status: ', status);
    console.log('API Response:\n', 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
26
27
28
29
30
<?php
/**
 * Example for Message list
 */
require 'vendor/autoload.php';
use Plivo\RestClient;

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

try {
    $response = $client->messages->list(
        [
        	'limit' => 5,
            'offset' => 0,
            'subaccount' =>'SUBACCOUNT_AUTH_ID',
            'message_state'=>'received',
            'message_direction' => 'inbound',
            'error_code'=>'10'
            'message_time' =>'2019-07-05 11:47:30',
            'message_time__gt'=>'2019-07-05 11:47:30',
            'message_time__gte'=>'2019-07-05 11:47:30',
            'message_time__lt'=>'2019-07-05 11:47:30',
            'message_time__lte'=>'2019-07-05 11:47:30'
        ]
    );
    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
35
import java.io.IOException;
import java.util.Date;

import com.plivo.api.Plivo;
import com.plivo.api.exceptions.PlivoRestException;
import com.plivo.api.models.message.Message;
import com.plivo.api.models.base.ListResponse;
import com.plivo.api.models.message.MessageDirection;
import com.plivo.api.models.message.MessageState;
import com.plivo.api.models.message.MessageLister;


class GetAllMessageList
{
    public static void main(String [] args)
    {
        Plivo.init("AUTH_ID","AUTH_TOKEN");
        try
        {
            ListResponse<Message> response = Message.lister()
                    .errorCode(10L)
                    .subaccount("SUBACCOUNT_AUTH_ID")
                    .messageDirection(MessageDirection.INBOUND)
                    .messageState(MessageState.DELIVERED)
                    .limit(5)
                    .offset(0)
                    .list();
            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
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.List(
		plivo.MessageListParams{
			Limit:  5,
			Offset: 0,
		},
	)
	if err != nil {
		panic(err)
	}
	fmt.Printf("Response: %#v\n", 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
26
27
28
29
30
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.List(
                    limit:5,
                    offset:0,
                    message_state:"undelivered",
                    message_direction:"inbound",
                    error_code:10
                );
                Console.WriteLine(response);
            }
            catch (PlivoRestException e)
            {
                Console.WriteLine("Exception: " + e.Message);
            }
        }
    }
}
1
2
curl -i --user AUTH_ID:AUTH_TOKEN \
    https://api.plivo.com/v1/Account/{auth_id}/Message/

Next Step

Learn how to get details of a single SMS message.

  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