Check your inbox with our API
This guide shows how to retrieve your inbound messages using the REST API.
Receive SMS code - retrieving the first page of your inbox

var loginCredentials = new EsendexCredentials("YourUsername", "YourApiPassword");
var inboxService = new InboxService(credentials);
var inboxMessages = inboxService.GetMessages();
foreach(var inboxMessage in inboxMessages.Messages)
{
Console.WriteLine("Message: account {0} from: {1} to: {2} at: {3}", inboxMessage.AccountReference, inboxMessage.Originator.PhoneNumber, inboxMessage.Recipient.PhoneNumber, inboxMessage.ReceivedAt);
}
$authentication = new \Esendex\Authentication\LoginAuthentication(
"EX000000", // Your Esendex Account Reference
"user@example.com", // Your login email address
"api-password" // Your API password
);
$service = new \Esendex\InboxService($authentication);
$result = $service->latest();
print "Total Inbox Messages: {$result->totalCount()}";
print "Fetched: {$result->count()}";
foreach ($result as $message) {
print "Message from: {$message->originator()}, {$message->summary()}";
}
int pageNumber = 1;
int pageSize = 20;
UserPassword userPassword = new UserPassword("YourUsername","YourApiPassword");
BasicServiceFactory serviceFactory = ServiceFactory.createBasicAuthenticatingFactory(userPassword);
InboxService inboxService = serviceFactory.getInboxService();
InboxMessageCollectionResponse inboxMessages;
try{
inboxMessages = inboxService.getMessages(pageNumber, pageSize);
}catch(Exception e){
e.getStackTrace();
}
var config = require('./config'),
Esendex = require('../');
var esendex = new Esendex(config);
var options = {
startIndex: 0,
count: 3
};
esendex.inbox.get(options, function (err, messages) {
if (err) return console.log(err);
messages.messageheader.map(function (msg) {
console.log(msg);
});
});
client := New("user@example.com", "api-password")
now := time.Now()
response, err := client.Received(Between(now.AddDate(0, -6, 0), now))
if err != nil {
log.Fatal(err)
}
for _, message := range response.Messages {
fmt.Printf("%v %s: %s\n", message.ReceivedAt, message.From, message.Summary)
}
Those Examples require the SDKs
You will need:
- Your Esendex account reference (EX0xxxxxx), username, API password and virtual mobile number.
- Don't have an account yet? You'll need to create an account.
- Haven't got a virtual mobile number? If you already have an account but don’t have a virtual mobile number then please call our sales team on 0345 356 5758.
- Need an API password? You can generate one on your user profile.
- A mobile phone to send
SMS
into your account.
What you might want to do with the response
- Store the Inbound Messages in your database
What you might want to do next
- Acknowledge the message by sending a response.
- Mark the message as read in your inbox.
- Delete the message from your inbox.
- Read other pages of messages in your inbox.
A note on API access
In order to allow customers to manage what their users can do on their account, access to the API is restricted to users with Admin and Standard roles on an account (in most cases this shouldn't be an issue as Admin is the default role of new users). To manage the roles of users on an account, once you've signed up:
- Log in to Echo
- Go to Settings -> User Management