Sidebar Menu

GetMessageStatusByReferenceID

This method returns all messages that match a given ReferenceID. You can assign this ID to messages when using the AdvancedSMSSend method.

Endpoint

GET:
https://messaging.esendex.us/messaging.svc/GetMessageStatusByReferenceID?ReferenceID={REFERENCEID}&LicenseKey={LICENSEKEY}

Syntax

GetMessageStatusByReferenceID(ReferenceID, LicenseKey)

Request Parameters

Parameter Name Description Data Type Required Sample Value
ReferenceID

Unique ID that can be set with the AdvancedSMSSend method.

String True Esendex Test
LicenseKey

Your license key.

String True 00000000-0000-0000-0000-000000000000

Response

Returns: SMSResponse object

Code Samples

You can use any programming language you want with our API, as long as it can make a REST or SOAP call. Here are examples for some of the most common platforms.

// https://messaging.esendex.us/Messaging.svc?wsdl was added as a Service Reference and given the name WSDL

using WSDL;

var client = new MessagingClient(MessagingClient.EndpointConfiguration.mms2wsHttpBindingSecure);
var referenceId = "123";

// Let's send a message.
await client.AdvancedSMSsendAsync(new SMSAdvancedRequest
{
    LicenseKey = YOUR_LICENSE_KEY,
    SMSRequests = new SMSRequest[] {
        new SMSRequest {
            AssignedDID = YOUR_FROM_NUMBER,
            Message = "This is a test message.",
            PhoneNumbers = new string[] { YOUR_TO_NUMBER },
            ReferenceID = referenceId
        }
    }
});

// We can fetch the message's status at any time. Let's do it now.
var messages = await client.GetMessageStatusByReferenceIDAsync(referenceId, YOUR_LICENSE_KEY);

foreach (var message in messages)
{
    Console.WriteLine(
        "Message ID: " + message.MessageID + Environment.NewLine +
        "Error: " + message.SMSError + Environment.NewLine);
}
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Properties;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;

public final class GetMessageStatusByReferenceID{
    public static void main(String[] args) {
        try {
            URL url = new URL("https://messaging.esendex.us/Messaging.svc/GetMessageStatus?"
                        + "ReferenceID=12346"
                        + "&LicenseKey=YOUR LICENSE KEY");

            try {
                InputStream in = url.openStream();
                StreamSource source = new StreamSource(in);
                printResult(source);
            } catch (java.io.IOException e) {
                e.printStackTrace();
            }
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
    }

    private static void printResult(Source source) {
        try {
            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            StreamResult sr = new StreamResult(bos);
            Transformer trans = TransformerFactory.newInstance().newTransformer();
            Properties oprops = new Properties();
            oprops.put(OutputKeys.OMIT_XML_DECLARATION, "yes");
            trans.setOutputProperties(oprops);
            trans.transform(source, sr);

            System.out.println("**** Response ******");
            System.out.println(bos.toString());

            bos.close();
            System.out.println();
        } catch (Exception e) {
        }
    }
}
<?php

$client = new SoapClient('https://messaging.esendex.us/Messaging.svc?wsdl');

$param = array(
    'ReferenceID' => '(your reference ID, set in AdvancedSMSSend)',
    'LicenseKey' => '(your license key)'
);

$result = $client->GetMessageStatusByReferenceID($param);

print_r($result);

?>
<?php

$url = 'https://messaging.esendex.us/Messaging.svc/GetMessageStatusByReferenceID?ReferenceID=(Reference ID)&LicenseKey=(License Key)';
$cURL = curl_init();

curl_setopt($cURL, CURLOPT_URL, $url);
curl_setopt($cURL, CURLOPT_HTTPGET, true);
curl_setopt($cURL, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Accept: application/json'));

$result = curl_exec($cURL);
curl_close($cURL);

print_r($result);

?>
[
	{
		"Cancelled": true,
		"MessageID": "1627aea5-8e0a-4371-9022-9b504344e724",
		"Queued": true,
		"ReferenceID": "String content",
		"SMSError": 0,
		"SMSIncomingMessages": [
			{
				"FromPhoneNumber": "String content",
				"IncomingMessageID": "1627aea5-8e0a-4371-9022-9b504344e724",
				"MatchedMessageID": "1627aea5-8e0a-4371-9022-9b504344e724",
				"Message": "String content",
				"ResponseReceiveDate": "\/Date(928164000000-0400)\/",
				"ToPhoneNumber": "String content"
			}
		],
		"Sent": true,
		"SentDateTime": "\/Date(928164000000-0400)\/"
	}
]
<ArrayOfSMSResponse xmlns="http://sms2.cdyne.com">
  <SMSResponse>
    <Cancelled>true</Cancelled>
    <MessageID>1627aea5-8e0a-4371-9022-9b504344e724</MessageID>
    <Queued>true</Queued>
    <ReferenceID>String content</ReferenceID>
    <SMSError>NoError</SMSError>
    <SMSIncomingMessages>
      <SMSIncomingMessage>
        <FromPhoneNumber>String content</FromPhoneNumber>
        <IncomingMessageID>1627aea5-8e0a-4371-9022-9b504344e724</IncomingMessageID>
        <MatchedMessageID>1627aea5-8e0a-4371-9022-9b504344e724</MatchedMessageID>
        <Message>String content</Message>
        <ResponseReceiveDate>1999-05-31T11:20:00</ResponseReceiveDate>
        <ToPhoneNumber>String content</ToPhoneNumber>
      </SMSIncomingMessage>
      <SMSIncomingMessage>
        <FromPhoneNumber>String content</FromPhoneNumber>
        <IncomingMessageID>1627aea5-8e0a-4371-9022-9b504344e724</IncomingMessageID>
        <MatchedMessageID>1627aea5-8e0a-4371-9022-9b504344e724</MatchedMessageID>
        <Message>String content</Message>
        <ResponseReceiveDate>1999-05-31T11:20:00</ResponseReceiveDate>
        <ToPhoneNumber>String content</ToPhoneNumber>
      </SMSIncomingMessage>
    </SMSIncomingMessages>
    <Sent>true</Sent>
    <SentDateTime>1999-05-31T11:20:00</SentDateTime>
  </SMSResponse>
  <SMSResponse>
    <Cancelled>true</Cancelled>
    <MessageID>1627aea5-8e0a-4371-9022-9b504344e724</MessageID>
    <Queued>true</Queued>
    <ReferenceID>String content</ReferenceID>
    <SMSError>NoError</SMSError>
    <SMSIncomingMessages>
      <SMSIncomingMessage>
        <FromPhoneNumber>String content</FromPhoneNumber>
        <IncomingMessageID>1627aea5-8e0a-4371-9022-9b504344e724</IncomingMessageID>
        <MatchedMessageID>1627aea5-8e0a-4371-9022-9b504344e724</MatchedMessageID>
        <Message>String content</Message>
        <ResponseReceiveDate>1999-05-31T11:20:00</ResponseReceiveDate>
        <ToPhoneNumber>String content</ToPhoneNumber>
      </SMSIncomingMessage>
      <SMSIncomingMessage>
        <FromPhoneNumber>String content</FromPhoneNumber>
        <IncomingMessageID>1627aea5-8e0a-4371-9022-9b504344e724</IncomingMessageID>
        <MatchedMessageID>1627aea5-8e0a-4371-9022-9b504344e724</MatchedMessageID>
        <Message>String content</Message>
        <ResponseReceiveDate>1999-05-31T11:20:00</ResponseReceiveDate>
        <ToPhoneNumber>String content</ToPhoneNumber>
      </SMSIncomingMessage>
    </SMSIncomingMessages>
    <Sent>true</Sent>
    <SentDateTime>1999-05-31T11:20:00</SentDateTime>
  </SMSResponse>
</ArrayOfSMSResponse>