The Mobile Message SMS API provides powerful and flexible tools for sending and receiving SMS messages in Australia. You can send single or bulk SMS messages, track delivery statuses in real-time with webhooks, and receive inbound messages directly into your application. The API supports custom sender IDs, message tracking with custom references, and delivery receipts, allowing you to manage your SMS campaigns efficiently.
The base URL for the API is https://api.mobilemessage.com.au/
. This documentation will help you understand how to send and receive SMS messages, set up webhooks for real-time notifications, and track message delivery statuses.
The Mobile Message API allows up to 5 simultaneous requests per account. If you exceed this limit, you'll receive an HTTP 429 error with the message: "Too many concurrent requests. Please wait."
Simply wait for an existing request to complete before trying again.
To access the API, you need to authenticate using your API username and password. Many programming languages have native functions for handling Basic Authentication, but you can also manually create the Authorization
header if needed.
If you're manually constructing the header, follow these steps:
username:password
.Authorization
header as follows: Authorization: Basic <base64_encoded_credentials>
.Many languages provide built-in functions for Basic Authentication, which automatically handle encoding and adding the correct headers. Below are examples using native functions where available, as well as how to manually create the header when necessary.
cURL has native support for Basic Authentication:
curl -u user123:mypassword -X GET https://api.mobilemessage.com.au/v1/messages
In Python, you can use the requests
library, which supports Basic Authentication natively:
import requests
from requests.auth import HTTPBasicAuth
response = requests.get('https://api.mobilemessage.com.au/v1/messages',
auth=HTTPBasicAuth('user123', 'mypassword'))
print(response.json())
With JavaScript, using the Fetch API with Basic Authentication is straightforward. Simply provide the username and password in the headers:
const apiUsername = 'user123';
const apiPassword = 'mypassword';
fetch('https://api.mobilemessage.com.au/v1/messages', {
method: 'GET',
headers: {
'Authorization': 'Basic ' + btoa(`${apiUsername}:${apiPassword}`)
}
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error(error));
In PHP, you can use curl_setopt()
to set the authentication options:
<?php
$ch = curl_init('https://api.mobilemessage.com.au/v1/messages');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, "user123:mypassword");
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
Java's HttpURLConnection
doesn't have native support for Basic Authentication, so you'll need to manually create the header:
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Base64;
public class APIRequest {
public static void main(String[] args) throws Exception {
String apiUsername = "user123";
String apiPassword = "mypassword";
String credentials = apiUsername + ":" + apiPassword;
String encodedCredentials = Base64.getEncoder().encodeToString(credentials.getBytes());
URL url = new URL("https://api.mobilemessage.com.au/v1/messages");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestProperty("Authorization", "Basic " + encodedCredentials);
connection.setRequestMethod("GET");
// Process the response...
}
}
In C#, the HttpClient
class supports Basic Authentication natively by adding the authorization header:
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
class Program {
static async Task Main() {
var client = new HttpClient();
var apiUsername = "user123";
var apiPassword = "mypassword";
var credentials = Encoding.ASCII.GetBytes($"{apiUsername}:{apiPassword}");
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic",
Convert.ToBase64String(credentials));
var response = await client.GetAsync("https://api.mobilemessage.com.au/v1/messages");
var responseString = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseString);
}
}
/v1/messages
Send one or more SMS messages using the API. You can send up to 100 SMS messages per API request.
Parameter | Type | Description |
---|---|---|
messages |
Array of Objects | A list of messages to be sent. |
Each message object should include:
Field | Type | Description |
---|---|---|
to |
String | The recipient's phone number, which can be in local Australian format or international format. |
message |
String | The message content (maximum 765 characters). You can include GSM characters, such as standard English letters, numbers, and punctuation, but emojis are not supported. |
sender |
String | The sender ID to display. This ID must be registered in your account first. |
custom_ref (optional) |
String | A custom reference to help track the message. |
Below are examples of how to send SMS messages using this endpoint in various programming languages:
Using cURL to send an SMS message:
curl -u user123:mypassword -X POST https://api.mobilemessage.com.au/v1/messages \
-H "Content-Type: application/json" \
-d '{
"messages": [
{
"to": "0412345678",
"message": "Hello, this is a test message",
"sender": "CompanyABC",
"custom_ref": "tracking001"
}
]
}'
Sending an SMS in Python using the requests
library with native Basic Authentication:
import requests
from requests.auth import HTTPBasicAuth
# Set up variables for message details
to = "0412345678"
sender = "CompanyABC"
message = "Hello, this is a test message"
custom_ref = "tracking001"
# Create the data array
data = {
"messages": [
{
"to": to,
"message": message,
"sender": sender,
"custom_ref": custom_ref
}
]
}
# Make the POST request with Basic Authentication
response = requests.post('https://api.mobilemessage.com.au/v1/messages', json=data, auth=HTTPBasicAuth('user123', 'mypassword'))
# Print the response from the API
print(response.json())
Using JavaScript (Fetch API) to send an SMS message:
// Set up variables for message details
const to = "0412345678";
const sender = "CompanyABC";
const message = "Hello, this is a test message";
const custom_ref = "tracking001";
// Create the message data object
const messageData = {
messages: [
{
to: to,
message: message,
sender: sender,
custom_ref: custom_ref
}
]
};
// Fetch API call to send the SMS
fetch('https://api.mobilemessage.com.au/v1/messages', {
method: 'POST',
headers: {
'Authorization': 'Basic ' + btoa('user123:mypassword'),
'Content-Type': 'application/json'
},
body: JSON.stringify(messageData)
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error(error));
Sending an SMS in PHP using cURL
with native Basic Authentication:
<?php
// Set up variables for message details
$to = "0412345678"; // Recipient phone number
$sender = "CompanyABC"; // Sender ID
$message = "Hello, this is a test message"; // Message content
$custom_ref = "tracking001"; // Optional custom reference
// Create the message data array
$message_data = [
"to" => $to,
"message" => $message,
"sender" => $sender,
"custom_ref" => $custom_ref
];
// Create the final data array
$data = [
"messages" => [$message_data]
];
// Initialize cURL session
$ch = curl_init('https://api.mobilemessage.com.au/v1/messages');
// Set cURL options for Basic Authentication and JSON payload
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, "user123:mypassword");
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
// Execute the request and get the response
$response = curl_exec($ch);
curl_close($ch);
// Output the response
echo $response;
?>
Sending an SMS in Java using HttpURLConnection
:
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Base64;
public class SendSMS {
public static void main(String[] args) throws Exception {
// Set up variables for message details
String to = "0412345678";
String sender = "CompanyABC";
String message = "Hello, this is a test message";
String custom_ref = "tracking001";
// Create the JSON string for the message
String jsonInputString = String.format(
"{\"messages\": [{\"to\": \"%s\", \"message\": \"%s\", \"sender\": \"%s\", \"custom_ref\": \"%s\"}]}",
to, message, sender, custom_ref);
// Basic Authentication credentials
String apiUsername = "user123";
String apiPassword = "mypassword";
String credentials = Base64.getEncoder().encodeToString((apiUsername + ":" + apiPassword).getBytes());
// Make the HTTP connection
URL url = new URL("https://api.mobilemessage.com.au/v1/messages");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestProperty("Authorization", "Basic " + credentials);
connection.setRequestProperty("Content-Type", "application/json");
connection.setRequestMethod("POST");
connection.setDoOutput(true);
// Send the JSON data
try (OutputStream os = connection.getOutputStream()) {
byte[] input = jsonInputString.getBytes("utf-8");
os.write(input, 0, input.length);
}
// Read the response
// ...
}
}
Sending an SMS in C# using HttpClient
:
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
class Program {
static async Task Main() {
// Set up variables for message details
var to = "0412345678";
var sender = "CompanyABC";
var message = "Hello, this is a test message";
var custom_ref = "tracking001";
// Create the message data object
var messageData = new {
messages = new[] {
new {
to = to,
message = message,
sender = sender,
custom_ref = custom_ref
}
}
};
// Initialize HttpClient with Basic Authentication
var client = new HttpClient();
var credentials = Convert.ToBase64String(Encoding.ASCII.GetBytes("user123:mypassword"));
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", credentials);
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
// Send the POST request
var content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(messageData), Encoding.UTF8, "application/json");
var response = await client.PostAsync("https://api.mobilemessage.com.au/v1/messages", content);
var responseString = await response.Content.ReadAsStringAsync();
// Output the response
Console.WriteLine(responseString);
}
}
Each message will return details such as status, cost, and message ID.
{
"status": "complete",
"total_cost": 1,
"results": [
{
"to": "0412345678",
"message": "Hello, this is a test message",
"sender": "CompanyABC",
"custom_ref": "tracking001",
"status": "success",
"cost": 1,
"message_id": "abcd1234-efgh-5678-ijkl-9876543210mn"
}
]
}
/v1/messages
Lookup the details of a previously sent message using the message_id
or custom_ref
.
Parameter | Type | Description |
---|---|---|
message_id (optional) |
String | The unique message ID (UUID). |
custom_ref (optional) |
String | The custom reference provided when the message was sent. |
GET /v1/messages?message_id=abcd1234-efgh-5678-ijkl-9876543210mn
Below are examples of how to look up a sent message using this endpoint in various programming languages:
Using cURL to look up a sent message by message_id
:
curl -u user123:mypassword -X GET "https://api.mobilemessage.com.au/v1/messages?message_id=abcd1234-efgh-5678-ijkl-9876543210mn"
Looking up a sent message in Python using the requests
library with native Basic Authentication:
import requests
from requests.auth import HTTPBasicAuth
# Set up variables for message lookup
message_id = "abcd1234-efgh-5678-ijkl-9876543210mn" # Use message_id or custom_ref
# Create the request URL
url = f"https://api.mobilemessage.com.au/v1/messages?message_id={message_id}"
# Make the GET request with Basic Authentication
response = requests.get(url, auth=HTTPBasicAuth('user123', 'mypassword'))
# Print the response from the API
print(response.json())
Using JavaScript (Fetch API) to look up a sent message by message_id
:
// Set up variables for message lookup
const message_id = "abcd1234-efgh-5678-ijkl-9876543210mn"; // Use message_id or custom_ref
// Fetch API call to look up the sent message
fetch(`https://api.mobilemessage.com.au/v1/messages?message_id=${message_id}`, {
method: 'GET',
headers: {
'Authorization': 'Basic ' + btoa('user123:mypassword'),
'Content-Type': 'application/json'
}
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error(error));
Looking up a sent message in PHP using cURL
:
<?php
// Set up variables for message lookup
$message_id = "abcd1234-efgh-5678-ijkl-9876543210mn"; // Use message_id or custom_ref
// Create the request URL
$url = "https://api.mobilemessage.com.au/v1/messages?message_id=" . $message_id;
// Initialize cURL session
$ch = curl_init($url);
// Set cURL options for Basic Authentication
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, "user123:mypassword");
// Execute the request and get the response
$response = curl_exec($ch);
curl_close($ch);
// Output the response (JSON response from the API)
echo $response;
?>
Looking up a sent message in Java using HttpURLConnection
:
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Base64;
public class LookupMessage {
public static void main(String[] args) throws Exception {
// Set up variables for message lookup
String message_id = "abcd1234-efgh-5678-ijkl-9876543210mn"; // Use message_id or custom_ref
String url = "https://api.mobilemessage.com.au/v1/messages?message_id=" + message_id;
// Basic Authentication credentials
String apiUsername = "user123";
String apiPassword = "mypassword";
String credentials = Base64.getEncoder().encodeToString((apiUsername + ":" + apiPassword).getBytes());
// Make the HTTP connection
URL requestUrl = new URL(url);
HttpURLConnection connection = (HttpURLConnection) requestUrl.openConnection();
connection.setRequestProperty("Authorization", "Basic " + credentials);
connection.setRequestMethod("GET");
// Read the response
// ...
}
}
Looking up a sent message in C# using HttpClient
:
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
class Program {
static async Task Main() {
// Set up variables for message lookup
var message_id = "abcd1234-efgh-5678-ijkl-9876543210mn"; // Use message_id or custom_ref
var url = $"https://api.mobilemessage.com.au/v1/messages?message_id={message_id}";
// Initialize HttpClient with Basic Authentication
var client = new HttpClient();
var credentials = Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes("user123:mypassword"));
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", credentials);
// Send the GET request
var response = await client.GetAsync(url);
var responseString = await response.Content.ReadAsStringAsync();
// Output the response
Console.WriteLine(responseString);
}
}
The response will include details such as message status, cost, and the timestamp when the message was requested.
{
"status": "complete",
"results": [
{
"to": "+61412345678",
"message": "Hello, this is message 1",
"sender": "CompanyABC",
"custom_ref": "tracking001",
"status": "success",
"cost": 1,
"message_id": "abcd1234-efgh-5678-ijkl-9876543210mn",
"requested_at": "2024-09-30 14:35:00"
}
]
}
/v1/account
Use this endpoint to retrieve your account's current credit balance.
This endpoint does not require any additional parameters. The credit balance is retrieved based on your authenticated API credentials.
Below are examples of how to retrieve your account's credit balance using this endpoint in various programming languages:
Using cURL to retrieve your account credit balance:
curl -u user123:mypassword -X GET https://api.mobilemessage.com.au/v1/account
Retrieving account credit balance in Python using the requests
library with native Basic Authentication:
import requests
from requests.auth import HTTPBasicAuth
# Create the request URL
url = "https://api.mobilemessage.com.au/v1/account"
# Make the GET request with Basic Authentication
response = requests.get(url, auth=HTTPBasicAuth('user123', 'mypassword'))
# Print the response from the API
print(response.json())
Using JavaScript (Fetch API) to retrieve your account credit balance:
// Fetch API call to retrieve account credit balance
fetch('https://api.mobilemessage.com.au/v1/account', {
method: 'GET',
headers: {
'Authorization': 'Basic ' + btoa('user123:mypassword'),
'Content-Type': 'application/json'
}
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error(error));
Retrieving account credit balance in PHP using cURL
with native Basic Authentication:
<?php
// Create the request URL
$url = "https://api.mobilemessage.com.au/v1/account";
// Initialize cURL session
$ch = curl_init($url);
// Set cURL options for Basic Authentication
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, "user123:mypassword");
// Execute the request and get the response
$response = curl_exec($ch);
curl_close($ch);
// Output the response (JSON response from the API)
echo $response;
?>
Retrieving account credit balance in Java using HttpURLConnection
:
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Base64;
public class GetBalance {
public static void main(String[] args) throws Exception {
// Create the request URL
String url = "https://api.mobilemessage.com.au/v1/account";
// Basic Authentication credentials
String apiUsername = "user123";
String apiPassword = "mypassword";
String credentials = Base64.getEncoder().encodeToString((apiUsername + ":" + apiPassword).getBytes());
// Make the HTTP connection
URL requestUrl = new URL(url);
HttpURLConnection connection = (HttpURLConnection) requestUrl.openConnection();
connection.setRequestProperty("Authorization", "Basic " + credentials);
connection.setRequestMethod("GET");
// Read the response
// ...
}
}
Retrieving account credit balance in C# using HttpClient
:
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
class Program {
static async Task Main() {
// Initialize HttpClient with Basic Authentication
var client = new HttpClient();
var credentials = Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes("user123:mypassword"));
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", credentials);
// Send the GET request
var response = await client.GetAsync("https://api.mobilemessage.com.au/v1/account");
var responseString = await response.Content.ReadAsStringAsync();
// Output the response
Console.WriteLine(responseString);
}
}
Field | Type | Description |
---|---|---|
status |
String | "complete" if the request was successful. |
credit_balance |
Integer | The current credit balance of your account. |
{
"status": "complete",
"credit_balance": 1000
}
{
"error": "Account not found or no credit balance available."
}
{
"error": "Invalid request method. Only GET is allowed."
}
Webhooks allow your application to receive real-time notifications about inbound messages and delivery receipts for SMS messages.
To enable webhooks, set your Inbound URL
and/or Status URL
in your account settings. These URLs will receive POST requests with JSON payloads when certain events occur.
Both inbound and status webhooks send a JSON payload with the following structure:
Field | Type | Description |
---|---|---|
to |
String | The recipient's phone number. |
message |
String | The content of the SMS. |
sender |
String | The phone number or ID of the sender. |
received_at |
String | The timestamp when the message or status update was received (UTC format). |
type (inbound only) |
String | The type of event: "inbound" for messages or "unsubscribe" . |
status (status webhooks only) |
String | The delivery status, which can only be "delivered" or "failed" . |
message_id (status webhooks only) |
String | The unique identifier for the message. |
{
"to": "61412345678",
"message": "Hello, this is message 1",
"sender": "61412345699",
"received_at": "2024-09-30 14:35:00",
"type": "inbound"
}
{
"to": "61412345678",
"message": "Hello, this is message 1",
"sender": "Mobile MSG",
"custom_ref": "tracking001",
"status": "delivered",
"message_id": "044b035f-0396-4a47-8428-12d5273ab04a",
"received_at": "2024-09-30 14:35:00"
}
Ensure your webhook URLs are accessible and can handle POST requests with JSON payloads. Your server must respond within 5 seconds; otherwise, the request will be considered a failure and will be retried.
If your server doesn't respond successfully (e.g., a status code other than 200), the system will retry sending the webhook up to 5 times, with a 1-minute delay between each retry.
Below are examples of how to process the incoming webhook payload in various programming languages:
Processing webhook payload in Python using Flask:
from flask import Flask, request, jsonify
app = Flask(__name__)
@app.route('/webhook', methods=['POST'])
def webhook():
# Get the JSON payload
data = request.get_json()
# Process the webhook data
to = data.get('to')
message = data.get('message')
sender = data.get('sender')
received_at = data.get('received_at')
event_type = data.get('type', 'status') # Default to 'status' if not inbound
# Output the processed data
print(f"Received {event_type} webhook:")
print(f"To: {to}, From: {sender}, Message: {message}, Received at: {received_at}")
# Return a success response
return jsonify({"status": "success"}), 200
if __name__ == '__main__':
app.run(port=5000)
Processing webhook payload in Node.js using Express:
const express = require('express');
const app = express();
app.use(express.json());
app.post('/webhook', (req, res) => {
const { to, message, sender, received_at, type } = req.body;
// Process the webhook data
console.log(`Received ${type || 'status'} webhook:`);
console.log(`To: ${to}, From: ${sender}, Message: ${message}, Received at: ${received_at}`);
// Respond with success
res.status(200).send({ status: 'success' });
});
app.listen(3000, () => {
console.log('Webhook server is listening on port 3000');
});
Processing webhook payload in PHP:
<?php
// Read the raw POST data
$payload = file_get_contents('php://input');
// Decode the JSON payload
$data = json_decode($payload, true);
// Process the webhook data
$to = $data['to'];
$message = $data['message'];
$sender = $data['sender'];
$received_at = $data['received_at'];
$type = $data['type'] ?? 'status'; // Default to 'status' if not inbound
// Output the processed data
error_log("Received $type webhook: To: $to, From: $sender, Message: $message, Received at: $received_at");
// Respond with success
header('Content-Type: application/json');
echo json_encode(['status' => 'success']);
?>
Processing webhook payload in Java using Spring Boot:
import org.springframework.web.bind.annotation.*;
import org.springframework.http.ResponseEntity;
@RestController
@RequestMapping("/webhook")
public class WebhookController {
@PostMapping
public ResponseEntity<String> handleWebhook(@RequestBody WebhookPayload payload) {
// Process the webhook data
System.out.println("Received " + (payload.getType() != null ? payload.getType() : "status") + " webhook:");
System.out.println("To: " + payload.getTo() + ", From: " + payload.getSender() + ", Message: " + payload.getMessage() + ", Received at: " + payload.getReceivedAt());
// Respond with success
return ResponseEntity.ok("{\"status\": \"success\"}");
}
}
class WebhookPayload {
private String to;
private String message;
private String sender;
private String receivedAt;
private String type;
// Getters and setters...
}
Processing webhook payload in C# using ASP.NET Core:
using Microsoft.AspNetCore.Mvc;
[ApiController]
[Route("webhook")]
public class WebhookController : ControllerBase
{
[HttpPost]
public IActionResult HandleWebhook([FromBody] WebhookPayload payload)
{
// Process the webhook data
var type = payload.Type ?? "status"; // Default to 'status' if not inbound
Console.WriteLine($"Received {type} webhook:");
Console.WriteLine($"To: {payload.To}, From: {payload.Sender}, Message: {payload.Message}, Received at: {payload.ReceivedAt}");
// Respond with success
return Ok(new { status = "success" });
}
}
public class WebhookPayload
{
public string To { get; set; }
public string Message { get; set; }
public string Sender { get; set; }
public string ReceivedAt { get; set; }
public string Type { get; set; }
}
Our SMS API is simple to integrate with your existing applications, with detailed documentation.
Personalise your messages with a branded sender name, improving trust and engagement with your audience.
Track your message statuses in real time, ensuring complete transparency and campaign effectiveness.
Receive replies and incoming messages directly into your app for seamless two-way communication.
Looking for a no-code connection to our service? Connect to more than 7,000 apps with Zapier, to send and receive SMS messages automatically.
A bulk SMS gateway is a platform or service that enables businesses to send large volumes of SMS messages quickly and efficiently to multiple recipients. It acts as a bridge between your application or system and Australian mobile network operators, ensuring that your messages are delivered to customers across Australia. Whether you're using an API to send text messages or an online portal, a bulk SMS gateway simplifies the process of managing high-volume communications.
At its core, a bulk SMS API gateway provides developers with tools to automate SMS messaging within Australia, making it ideal for sending promotions, alerts, reminders, and updates to Australian phone numbers. With features like real-time delivery tracking, two-way SMS messaging, and custom sender IDs, it ensures businesses can communicate effectively and reliably with their audience.