Code Samples
Send Attachment and Check Delivery Status
/messages && /messages/{messageId}
C#
using System;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
namespace ApiRequest
{
class Program
{
public static async Task Main(string[] args)
{
var httpClient = new HttpClient();
var apiKey = "YOUR_KEY_HERE";
var accountRef = "EXUKxxxxxx";
// -------------------------------------------------------------
// STEP 1: Send RCS Message with Attachment
// -------------------------------------------------------------
var sendUrl = "https://api.esendex.co.uk/v2/messages";
var sendRequest = new HttpRequestMessage(HttpMethod.Post, sendUrl);
sendRequest.Headers.Add("X-Api-Key", apiKey);
var sendBodyJson = @"{
""accountReference"": """ + accountRef + @""",
""channel"": ""RCS"",
""messageType"": ""NotificationsAndReminders"",
""body"": {
""attachment"": {
""attachmentUrl"": ""https://example.com/assets/ticket.pdf"",
""fileName"": ""EventTicket.pdf"",
""description"": ""Your VIP Event Ticket""
}
},
""recipients"": [
{
""msisdn"": ""+447123456789""
}
]
}";
sendRequest.Content = new StringContent(sendBodyJson, Encoding.UTF8, "application/json");
Console.WriteLine("Dispatching RCS rich message...");
var sendResponse = await httpClient.SendAsync(sendRequest);
if (sendResponse.IsSuccessStatusCode)
{
var sendResponseBody = await sendResponse.Content.ReadAsStringAsync();
Console.WriteLine("Send Response: " + sendResponseBody);
using var jsonDoc = JsonDocument.Parse(sendResponseBody);
if (jsonDoc.RootElement.TryGetProperty("messageIds", out var messageIds) && messageIds.GetArrayLength() > 0)
{
var targetMessageId = messageIds[0].GetString();
Console.WriteLine($"\n✅ Target Message ID: {targetMessageId}");
// -------------------------------------------------------------
// STEP 2: Query Delivery Status
// -------------------------------------------------------------
var statusUrl = $"https://api.esendex.co.uk/v2/messages/{targetMessageId}?AccountReference={accountRef}";
var statusRequest = new HttpRequestMessage(HttpMethod.Get, statusUrl);
statusRequest.Headers.Add("X-Api-Key", apiKey);
statusRequest.Headers.Add("AccountReference", accountRef);
Console.WriteLine("Checking delivery status...");
var statusResponse = await httpClient.SendAsync(statusRequest);
if (statusResponse.IsSuccessStatusCode)
{
var statusResponseBody = await statusResponse.Content.ReadAsStringAsync();
Console.WriteLine("Status Response: " + statusResponseBody);
}
else
{
Console.WriteLine($"Status Query Error: {statusResponse.StatusCode}");
var errorContent = await statusResponse.Content.ReadAsStringAsync();
Console.WriteLine("Details: " + errorContent);
}
}
}
else
{
Console.WriteLine($"Send Error: {sendResponse.StatusCode}");
var errorContent = await sendResponse.Content.ReadAsStringAsync();
Console.WriteLine("Details: " + errorContent);
}
}
}
}
Why do developers choose our multichannel API suite?
Built for outcomes
Our RCS API (REST) eliminates API complexity with its modern architecture: one format, one base URL, and one API key.
Multichannel agility
Frictionless transition from SMS to RCS with one simple parameter change.
Fast API integration
Reduce time-to-value and skip complex setup. Our modern architecture means you can set up your API in as little as 3 hours.
Enterprise security
Rest easy with fully accredited ISO 27001 certification and built-in, reliable GDPR compliance pathways. The only messaging supplier with both ISO 27001 and NEN 7510 in the world.
Let’s start sending, together.
Discover the full power of our mobile messaging platform.