Get Details of a Single Message

Once the Message API request is successful, your SMS will be put into a queue to be sent to its destination. Plivo has a throughput of 1 SMS per second. That is, Plivo will send 1 SMS every second for each 'src' (source) number in the API request.

To get the details of a Single Messages, make an HTTP GET request to the Message API by passing the Message UUID.

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

Prerequisites

  1. Sign up for a free Plivo trial account.
  2. Check out our Helper Libraries page and install the right helper based on the programming language you want to use.
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.

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 the unique message_uuid found in the response of the message you sent. See a Sample Response.

Code

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

auth_id = "Your AUTH_ID"
auth_token = "Your Auth_TOKEN"
p = plivo.RestAPI(auth_id, auth_token)

# Message UUID for which the details will be retrieved
params = {'message_uuid': '0936ec98-7c4c-11e4-9bd8-22000afa12b9'}
# Fetch the details
response = p.get_message(params)

# Prints all the details of a message
print str(response)

# Prints the number of SMS units
# print "Your SMS was split into %s units" % response[1]['units']

# Prints the status of the message
# print response[1]['message_state']
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
require 'rubygems'
require 'plivo'
include Plivo

AUTH_ID = "Your AUTH_ID"
AUTH_TOKEN = "Your AUTH_TOKEN"
p = RestAPI.new(AUTH_ID, AUTH_TOKEN)

# Message UUID for which the details will be retrieved
params = {'record_id' => '0936ec98-7c4c-11e4-9bd8-22000afa12b9'}
# Fetch the details
response = p.get_message(params)

# Prints all the details of a message
puts response

# Prints the number of SMS units
# puts "Your SMS was split into %s units" % response[1]['units']

# Prints the status of the message
# puts response[1]['message_state']
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
var plivo = require('plivo');
var p = plivo.RestAPI({
    authId: 'Your AUTH_ID',
    authToken: 'Your AUTH_TOKEN'
});

// Message UUID for which the details will be retrieved
var params = {'record_id': '005bcdf3-b1b9-4487-b8d3-59efb41431ca'};

// Fetch the details
p.get_message(params, function (status, response) {
    console.log('Status: ', status);
    console.log('API Response:\n', response);
    console.log('Units:', response['units']);
    console.log('Status:', response['message_state']);
});
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
<?php
    require 'vendor/autoload.php';
    use Plivo\RestAPI;
    $auth_id = "Your AUTH_ID";
    $auth_token = "Your AUTH_TOKEN";
    $p = new RestAPI($auth_id, $auth_token);

    // Message UUID for which the details will be retrieved
    $params = array('record_id' => '0936ec98-7c4c-11e4-9bd8-22000afa12b9');
    // Fetch the details
    $response = $p->get_message($params);

    // Print the response
    print_r ($response['response']);

    // Print the number of SMS units
    print "Units : {$response['response']['units']}";

    // Print the status of the message
    print "Message State : {$response['response']['message_state']}";
?>
 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
package com.plivo.test;

import java.util.LinkedHashMap;
import com.plivo.helper.api.client.*;
import com.plivo.helper.api.response.message.MessageResponse;
import com.plivo.helper.exception.PlivoException;

public class GetDetails {
    public static void main(String[] args) {
        String authId = "Your AUTH_ID";
        String authToken = "Your AUTH_TOKEN";
        RestAPI api = new RestAPI(authId, authToken, "v1");

        LinkedHashMap<String, String> parameters = new LinkedHashMap<String, String>();
        // Message UUID for which the details will be retrieved
        parameters.put("record_id", "0936ec98-7c4c-11e4-9bd8-22000afa12b9");
        try {
            Message msg = api.getMessage(parameters);
            // Prints all the details of a message
            System.out.println(msg);

            // Prints the number of SMS units
            // System.out.println("Units : " + msg.units);

            // Prints the state of the message
            // System.out.println("Message State : " + msg.messageState);
        } catch (PlivoException e) {
            System.out.println(e.getLocalizedMessage());
        }
    }
}
 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
using System;
using System.Collections.Generic;
using System.Reflection;
using RestSharp;
using Plivo.API;

namespace Get_Details
{
    class Program
    {
        static void Main(string[] args)
        {
            RestAPI plivo = new RestAPI("Your AUTH_ID", "Your AUTH_TOKEN");
            IRestResponse<Message> resp = plivo.get_message(new Dictionary<string, string>()
            {
                // Message UUID for which the details will be retrieved
                { "record_id", "1aead330-8ff9-11e4-9bd8-22000afa12b9" }
            });

            // Prints all the details of a message
            Console.Write(resp.Content);

            // Print the status of the message
            // Console.Write("Message State : {0}", resp.Data.message_state);

            Console.ReadLine();
        }
    }
}
1
2
curl -i --user AUTH_ID:AUTH_TOKEN \
    https://api.plivo.com/v1/Account/{auth_id}/Message/{message_uuid}/

Sample Response

(200, 
    {
       u'message_state': u'delivered',
       u'total_amount': u'0.02600',
       u'to_number': u'3333333333',
       u'total_rate': u'0.00650',
       u'api_id': u'ebe64d72-8a75-11e4-ac1f-22000ac51de6',
       u'message_direction': u'outbound',
       u'from_number': u'1111111111',
       u'message_uuid': u'0936ec98-7c4c-11e4-9bd8-22000afa12b9',
       u'message_time': u'2014-12-05 12:27:54+05:30',
       u'units': 4,
       u'message_type': u'sms',
       u'resource_uri': u'/v1/Account/XXXXXXXXXXXX/Message/0936ec98-7c4c-11e4-9bd8-22000afa12b9/'
   }
)

Next Step

Learn how to handle SMS delivery reports.

  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. Handling SMS Delivery Reports
  10. Forward SMS to Email