Latest Legacy

List all messages

This API retrieves a list of Message Detail Records (MDR) based on a filter criteria over the last 90 days.

Note: The default rate limit for this API is 20 requests per minute. If the rate limit is exceeded, the following error would be thrown: "too many requests"

API Endpoint

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

Arguments

subaccount string

Filters for

  • Outbound messages sent using a specific subaccount’s Auth Token.
  • Inbound messages received on a phone number associated with a specific subaccount.
Note: The subaccount filter is implicitly applied when a subaccount’s API credentials are used to fire this API. This argument should be used only when the parent account’s API credentials are used to fire this API.
message_direction string

Filters the results by message direction. Allowed values: inbound, outbound

message_time

Filters outbound and inbound messages based on the time the message was initiated or received.

Timestamps are expected to be in YYYY-MM-DD HH:MM[:ss[.uuuuuu]] format, and are considered to be in UTC time zone.

If you do not specify this attribute, the MDR for the last 24 hours will be retrived by default.

The filter can be used in five forms:

  • message_time: Use this argument to filter for messages by exact timestamp. The format expected is YYYY-MM-DD HH:MM:ss:uuuuuu. To get all messages that were sent or received at 2021-03-21 11:47:30.982811, use message_time=2021-03-21 11:47:30.982811

  • message_time__gt: gt stands for greater than. Use this argument to filter for messages sent or received after a given time. To get all messages that were sent or received after 2021-03-21 11:47, use message_time__gt=2021-03-21 11:47

  • message_time__gte: gte stands for greater than or equal to. To get all messages that were sent or received after or exactly at 2021-03-21 11:47[:30], use message_time__gte=2021-03-21 11:47[:30]

  • message_time__lt: lt stands for less than. Use this argument to filter for messages sent or received before a given time. To get all messages that were sent or received before 2021-03-21 11:47, use message_time__lt=2021-03-21 11:47

  • message_time__lte: lte stands for less than or equal to. To get all messages that were sent or received before or exactly at 2012-03-21 11:47[:30], use message_time__lte=2012-03-21 11:47[:30]

Note: You can combine the above filters to get messages that were sent or received in a particular time range.
message_state string

Filter results by the current status of a message.

Allowed values: queued, sent, failed, delivered, undelivered, received, rejected

message_type string

Filter results by the type of message.

Allowed values: sms, mms, whatsapp

error_code string

Filter results by a standard Plivo error code.

powerpack_id string

Filter results based on messages sent using a specific Power pack.

from_number string

Filters results by the number or sender ID from which the messages were sent using Plivo APIs. You can filter the details by using the exact number in E.164 format — for example, +12025551212 — or the exact sender ID.

to_number string

Filters results by the number to which messages were sent using Plivo APIs. You can filter the details by using the exact number in E.164 format — for example, +12025553434.

limit integer

Denotes the number of results per page. The maximum number of results that can be fetched is 20.

Defaults to 20.

offset integer

Denotes the number of value items by which the results should be offset. Defaults to 0. Read more about offset-based pagination.

destination_country_iso2 string

Filters results by the ISO2 code of the country associated with the destination number.

tendlc_registration_status string

Filters results by the 10DLC registration status of the message. Only relevant for long code messaging in the US.

tendlc_campaign_id string

Filters results by the 10DLC campaign ID associated with the message. Only relevant for long code messaging in the US.
conversation_id string Filters results by the WhatsApp conversation ID. 
conversation_origin string

Filters results by the WhatsApp Conversation Origin (Conversation type). 

Possible values: utility, authentication, marketing, service

Returns

This API returns a list of Message Detail Records matching the filters specified in the request.

The API response also contains a meta field with the fields:

  • limit: the size of the page returned in the response
  • offset: the offset for the page returned in the response
  • next: the URL that points to the next page of results
  • previous: the URL that points to the previous page of results

Response

HTTP Status Code: 200

{
   "Api_id":"f237ffbd-e1b1-4bd3-a2cb-874hebb",
   "meta":{
      "limit":1,
      "offset":0,
      "next":"/v1/Account/<AUTH_ID>/Message/?limit=1&offset=1",
      "previous":null
   },
   "objects":[
      {
         "message_uuid":"63f0462e-d744-453d-a387-d8e8e7e7ee",
         "from_number":"15732556666",
         "to_number":"12017138888",
         "message_direction":"outbound",
         "message_state":"sent",
         "message_time":"2023-10-18 17:27:36.499871+05:30",
         "message_type":"sms",
         "total_amount":"0.02600",
         "total_rate":"0.02600",
         "units":1,
         "mcc":"312",
         "mnc":"650",
         "error_code":"000",
         "resource_uri":"/v1/Account/<AUTH_ID>/Message/63f0462e-d744-453d-a387-dc4ad0aadff5/",
         "carrier_fees":"0.01000",
         "carrier_fees_rate":"0.01000",
         "powerpack_id":"31dbf456-b639-4d06-afc9-6b5hryr7r7r7",
         "tendlc_campaign_id":null,
         "tendlc_registration_status":"not_applicable",
         "destination_country_iso2":"US",
         "is_domestic":false,
         "requester_ip":"52.8.218.266",
         "replaced_sender":"15732554678",
         "conversation_id":"",
         "conversation_origin":"",
         "conversation_expiration_timestamp":"",
         "dlt_entity_id":"",
         "dlt_template_id":"",
         "dlt_template_category":"",
         "destination_network":"Level3",
         "log": "number_only"
      }
   ]
}

Example Request

1
2
3
4
5
6
7
import plivo

client = plivo.RestClient(auth_id="<auth_id>", auth_token="auth_token")

# List MDR
response = client.messages.list(limit=1,offset=0)
print(response)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
require 'rubygems'
require 'plivo'

include Plivo
include Plivo::Exceptions

# Environment
api = RestClient.new("<auth_id>", "<auth_token>")

# GET MDR
begin
response = api.messages.get("c9d8f08d-4f1f-4765-b7e4-83e0d35a36c5")
puts response
rescue PlivoRESTError => e
    puts 'Exception: ' + e.message
end
1
2
3
4
5
6
7
8
9
10
11
let plivo = require('plivo')

let client = new plivo.Client('<auth_id>','<auth_token>');

// List MDR
client.messages.list()
.then(function(response) {
    console.log(response);
}).catch(function(error) {
    console.log(error);
});
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php
require 'vendor/autoload.php';
use Plivo\RestClient;

// ENVIORNMENT
$client = new RestClient("<auth_id>", "<auth_token>");

// List all Messages
try {
    $response = $client->messages->list(['limit' => 1,'offset' => 0]);
    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
package com.plivo.examples;
import java.io.IOException;

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

public class Sample {

	public static void main(String[] args) throws PlivoValidationException {
        Plivo.init("<auth_id>", "<auth_token>");

        // List MDR
		try
	        {
	            ListResponse<Message> response = Message.lister()
	                    .limit(2)
	                    .offset(0)
	                    .list();

	            List<Message>  res = response.getObjects();
	            for (int i = 0; i < res.size(); i++) {
	                System.out.println(res.get(i));
	            }
	        }
	        catch (Exception 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
using System;
using System.Collections.Generic;
using Plivo;
using Plivo.Exception;

namespace dotnet_sdk
{
    class Sms
    {
        static void Main(string[] args)
        {
            // ENVIRONMENT
            var api = new PlivoApi("<auth_id>","<auth_token>");

            // List all Message Detail
            try
            {   
                Console.WriteLine("List all Messages");
                var response = api.Message.List(
                    limit:1,
                    offset:0
                    // subaccount:"subaccount_auth_id"
                );
                Console.WriteLine(response);
            }
            catch (PlivoRestException e)
            {
                Console.WriteLine("Exception: " + e.Message);
            }

        }
    }
}
1
2
curl -i --user auth_id_ID:auth_token \
    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
29
package main

import (
	"fmt"

	plivo "github.com/plivo/plivo-go"
)

func main() {

	// ENVIRONMENT
	client, err := plivo.NewClient("<auth_id>", "<auth_token>",
		&plivo.ClientOptions{})
	if err != nil {
		panic(err)
	}

	// List all Messages
	response, err := client.Messages.List(
		plivo.MessageListParams{
			Limit:  1,
			Offset: 0,
		})
	if err != nil {
		panic(err)
	}
	fmt.Printf("Response: %#v\n", response)

}