The MessageMedia Messages API provides a number of endpoints for building powerful two-way messaging applications.
Authentication is done via API keys. Sign up at https://developers.messagemedia.com/register/ to get your API keys.
Requests are authenticated using HTTP Basic Auth or HMAC. Provide your API key as the auth_user_name and API secret as the auth_password.
Our API returns standard HTTP success or error status codes. For errors, we will also include extra information about what went wrong encoded in the response as JSON. The most common status codes are listed below.
Code | Title | Description |
---|---|---|
400 | Invalid Request | The request was invalid |
401 | Unauthorized | Your API credentials are invalid |
403 | Disabled feature | Feature not enabled |
404 | Not Found | The resource does not exist |
50X | Internal Server Error | An error occurred with our API |
If you have any questions, comments, or concerns, please join our Slack channel: https://developers.messagemedia.com/collaborate/slack/
Alternatively you can email us at: [email protected]
If you discover a problem with the SDK, we would like to know about it. You can raise an issue or send an email to: [email protected]
We welcome your thoughts on how we could best provide you with SDKs that would simplify how you consume our services in your application. You can fork and create pull requests for any features you would like to see or raise an issue
Install via NuGet by:
PM> Install-Package MessageMedia.SDK.Messages -Version 1.1.2
Alternatively, right-click on your solution and click "Manage NuGet Packages...", then click browse and search for MessageMedia.
Visual Studio Mac: Project -> Add NuGet Packages -> Search for 'MessageMedia'
It's easy to get started. Simply enter the API Key and secret you obtained from the MessageMedia Developers Portal into the code snippet below and a mobile number you wish to send to. Please note this SDK is not supported for .NET Framework applications.
Destination numbers (destination_number
) should be in the E.164 format. For example, +61491570156
.
using System;
using System.Linq;
using MessageMedia.Messages;
using MessageMedia.Messages.Controllers;
using MessageMedia.Messages.Models;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace TestCSharpSDK
{
class Program
{
static void Main(string[] args)
{
// Configure your credentials (Note, these can be pulled from the environment variables as well)
String basicAuthUserName = "YOUR_API_KEY";
String basicAuthPassword = "YOUR_API_SECRET";
bool useHmacAuthentication = false; //Change this to true if you are using HMAC keys
// Instantiate the client
MessageMediaMessagesClient client = new MessageMediaMessagesClient(basicAuthUserName, basicAuthPassword, useHmacAuthentication);
IMessagesController messages = client.Messages;
var request = new SendMessagesRequest() {
Messages = new []{
new Message() {
Content = "Greetings from MessageMedia!",
DestinationNumber = "YOUR_MOBILE_NUMBER"
}
}
};
SendMessagesResponse result = messages.CreateSendMessages(request);
Message message = result.Messages.First();
Console.WriteLine("Status: {0}, Message Id: {1}", message.Status, message.MessageId);
Console.ReadKey();
}
}
}
Destination numbers (destination_number
) should be in the E.164 format. For example, +61491570156
.
using System;
using System.Linq;
using MessageMedia.Messages;
using MessageMedia.Messages.Controllers;
using MessageMedia.Messages.Models;
namespace TestCSharpSDK
{
class Program
{
static void Main(string[] args)
{
// Configure your credentials (Note, these can be pulled from the environment variables as well)
String basicAuthUserName = "YOUR_API_KEY";
String basicAuthPassword = "YOUR_API_SECRET";
bool useHmacAuthentication = false; //Change this to true if you are using HMAC keys
// Instantiate the client
MessageMediaMessagesClient client = new MessageMediaMessagesClient(basicAuthUserName, basicAuthPassword, useHmacAuthentication);
IMessagesController messages = client.Messages;
// Perform API call
var request = new SendMessagesRequest()
{
Messages = new[]
{
new Message()
{
Format = MessageFormat.MMS,
Content = "Greets from MessageMedia!",
DestinationNumber = "YOUR_MOBILE_NUMBER",
Media = new[]
{"https://upload.wikimedia.org/wikipedia/commons/6/6a/L80385-flash-superhero-logo-1544.png"}
}
}
};
SendMessagesResponse result = messages.CreateSendMessages(request);
Message message = result.Messages.First();
Console.WriteLine("Status: {0}, Message Id: {1}", message.Status, message.MessageId);
Console.ReadKey();
}
}
}
You can get a messsage ID from a sent message by looking at the message_id
from the response of the above example.
using System;
using MessageMedia.Messages;
using MessageMedia.Messages.Controllers;
using MessageMedia.Messages.Models;
namespace TestCSharpSDK
{
class Program
{
static void Main(string[] args)
{
// Configure your credentials (Note, these can be pulled from the environment variables as well)
String basicAuthUserName = "YOUR_API_KEY";
String basicAuthPassword = "YOUR_API_SECRET";
bool useHmacAuthentication = false; //Change this to true if you are using HMAC keys
// Instantiate the client
MessageMediaMessagesClient client = new MessageMediaMessagesClient(basicAuthUserName, basicAuthPassword, useHmacAuthentication);
IMessagesController messages = client.Messages;
string messageId = "YOUR_MESSAGE_ID";
dynamic result = messages.GetMessageStatus(messageId);
string msg = Newtonsoft.Json.JsonConvert.SerializeObject(result);
Console.WriteLine(msg);
}
}
}
You can check for replies that are sent to your messages
using System;
using MessageMedia.Messages;
using MessageMedia.Messages.Controllers;
using MessageMedia.Messages.Models;
namespace TestCSharpSDK
{
class Program
{
static void Main(string[] args)
{
// Configure your credentials (Note, these can be pulled from the environment variables as well)
String basicAuthUserName = "YOUR_API_KEY";
String basicAuthPassword = "YOUR_API_SECRET";
bool useHmacAuthentication = false; //Change this to true if you are using HMAC keys
// Instantiate the client
MessageMediaMessagesClient client = new MessageMediaMessagesClient(basicAuthUserName, basicAuthPassword, useHmacAuthentication);
IRepliesController replies = client.Replies;
MessageMedia.Messages.Models.CheckRepliesResponse result = replies.GetCheckReplies();
string msg = Newtonsoft.Json.JsonConvert.SerializeObject(result);
Console.WriteLine(msg);
}
}
}
This endpoint allows you to check for delivery reports to inbound and outbound messages.
using System;
using MessageMedia.Messages;
using MessageMedia.Messages.Controllers;
using MessageMedia.Messages.Models;
namespace TestCSharpSDK
{
class Program
{
static void Main(string[] args)
{
// Configure your credentials (Note, these can be pulled from the environment variables as well)
String basicAuthUserName = "YOUR_API_KEY";
String basicAuthPassword = "YOUR_API_SECRET";
bool useHmacAuthentication = false; //Change this to true if you are using HMAC keys
// Instantiate the client
MessageMediaMessagesClient client = new MessageMediaMessagesClient(basicAuthUserName, basicAuthPassword, useHmacAuthentication);
IDeliveryReportsController deliveryReports = client.DeliveryReports;
MessageMedia.Messages.Models.CheckDeliveryReportsResponse result = deliveryReports.GetCheckDeliveryReports();
string msg = Newtonsoft.Json.JsonConvert.SerializeObject(result);
Console.WriteLine(msg);
}
}
}
Check out the full API documentation for more detailed information.
Please contact developer support at [email protected] or check out the developer portal at developers.messagemedia.com
Apache License. See the LICENSE file.