SMS API

ReadMessageStatus

This method reads the status of an incoming or outgoing message.

Endpoint

GET:
https://messaging.esendex.us/Messaging.svc/ReadMessageStatus?LicenseKey={LICENSEKEY}&MessageId={MESSAGEID}

Syntax

ReadMessageStatus(LicenseKey, MessageID)

Request Parameters

Parameter NameDescriptionData TypeRequiredSample Value
LicenseKeyYour license key.GUIDTrue00000000-0000-0000-0000-000000000000
MessageIDUnique ID for message.GUIDTrued73cd74b-8687-4701-8f03-f75b4d4d860d

Response

Returns: OutgoingMessageResponse 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.

C#

// 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);

// Let's send a message.
var messages = await client.SendMessageAsync(new OutgoingMessageRequest
{
    Body = "Hi, this is a test.",
    From = YOUR_FROM_NUMBER,
    LicenseKey = YOUR_LICENSE_KEY,
    To = new[] { YOUR_TO_NUMBER }
});

// We can use this ID to fetch the message's status later on.
var messageId = messages[0].MessageID;

if (messageId == Guid.Empty)
{
    Console.WriteLine("The message could not be sent.");
    return;
}

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

Console.WriteLine(
    "Message ID: " + message.MessageID + Environment.NewLine +
    "Message Status: " + message.MessageStatus + Environment.NewLine +
    "To: " + message.To + Environment.NewLine +
    "From: " + message.From + Environment.NewLine +
    "UTC Time Sent: " + message.SentTime + Environment.NewLine +
    "Attachments: " + message.Attachments
);

Java

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 ReadMessageStatus {
    public static void main(String[] args) {
        try {
            URL url = new URL("https://messaging.esendex.us/Messaging.svc/ReadMessageStatus?"
                    + "LicenseKey=00000000-0000-0000-0000-000000000000"
                    + "&MessageId=f01d89fd-5155-5455-0000-000011af9652");
            try {
                InputStream in = url.openStream();
                StreamSource source = new StreamSource(in);
                printResult(source);
            } catch (java.io.IOException e) {
            }
        } catch (MalformedURLException e) {
        }
    }

    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) {
        }
    }
}

JavaScript

const headers = {
    'Accept': 'application/json',
    'Content-Type': 'application/json'
};

// Let's send a message.
const url = 'https://messaging.esendex.us/Messaging.svc/SendMessage';
const response = await fetch(url, {
    headers,
    body: JSON.stringify({
        'Body': 'Hi, this message was sent using JavaScript.',
        'LicenseKey': '00000000-0000-0000-0000-000000000000',
        'To': ['7575559999'],
        'UseMMS': false,
        "ScheduledDateTime": "/Date(9999999999999)/"
    }),
    method: 'POST'
});

// We can use this ID to fetch the message's status later on.
const messages = await response.json();
const messageId = messages[0]['MessageID'];

// We can fetch the message's status at any time. Let's do it now.
const params = new URLSearchParams({
    'LicenseKey': '00000000-0000-0000-0000-000000000000',
    'MessageID': messageId
});
const url2 = 'https://messaging.esendex.us/Messaging.svc/ReadMessageStatus?' + params.toString();
const response2 = await fetch(url2, {
    headers
});
const message = await response2.json();

console.log(message);

PHP with cURL

<?php

$url = 'https://messaging.esendex.us/Messaging.svc/ReadMessageStatus?LicenseKey=00000000-0000-0000-0000-000000000000&MessageId=f01d89fd-5155-5455-0000-000011af9652';
$ch = curl_init();

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

$response = curl_exec($ch);
curl_close($ch);

print_r($response);

?>

Python

import httpx

headers = {"Accept": "application/json"}

with httpx.Client(headers=headers) as client:
    # Let's send a message.
    response = client.post(
        url="https://messaging.esendex.us/Messaging.svc/SendMessage",
        json={
            "Body": "Hi, this message was sent using Python.",
            "LicenseKey": "00000000-0000-0000-0000-000000000000",
            "To": ["7575559999"],
            "UseMMS": False,
        },
    )
    response.raise_for_status()

    # We can use this ID to fetch the message's status later on.
    message_id = response.json()[0]["MessageID"]

    if message_id == "00000000-0000-0000-0000-000000000000":
        raise RuntimeError("The message could not be sent.")

    # We can fetch the message's status at any time. Let's do it now.
    response = client.get(
        url="https://messaging.esendex.us/Messaging.svc/ReadMessageStatus",
        params={
            "LicenseKey": "00000000-0000-0000-0000-000000000000",
            "MessageId": message_id,
        },
    )
    response.raise_for_status()

    print(response.json())

Ruby

require 'json'
require 'net/http'

headers = { Accept: 'application/json', 'Content-Type': 'application/json' }

# Let's send a message.
uri = URI('https://messaging.esendex.us/Messaging.svc/SendMessage')
data = {
  'Body': 'Hi, this message was sent using Ruby.',
  'LicenseKey': '00000000-0000-0000-0000-000000000000',
  'To': ['7575559999'],
  'UseMMS': false
}.to_json
response = Net::HTTP.post(uri, data, headers)
raise response.message if response.is_a?(Net::HTTPClientError) || response.is_a?(Net::HTTPServerError)

# We can use this ID to fetch the message's status later on.
message_id = JSON.parse(response.body)[0]['MessageID']
raise 'The message could not be sent.' if message_id == '00000000-0000-0000-0000-000000000000'

# We can fetch the message's status at any time. Let's do it now.
uri = URI('https://messaging.esendex.us/Messaging.svc/ReadMessageStatus')
params = {
  'LicenseKey': '00000000-0000-0000-0000-000000000000',
  'MessageId': message_id
}
uri.query = URI.encode_www_form(params)
response = Net::HTTP.get(uri, headers)
raise response.message if response.is_a?(Net::HTTPClientError) || response.is_a?(Net::HTTPServerError)

puts JSON.parse(response.body)

XML POST Request

xmlpost

XML Response

xmlresponse

Let’s start sending, together.