Simple API authentication for quick integration via api.mobile.digital
The Basic API uses standard authentication methods that are simple to implement and understand. This is the original API authentication method, maintained for backwards compatibility and ease of use.
Pass your API key directly in the URL as a query parameter:
GET https://api.mobile.digital/endpoint?api_key=YOUR_API_KEY
Include your API key in a custom header:
GET https://api.mobile.digital/endpoint
X-API-Key: YOUR_API_KEY
Use standard HTTP Basic Auth with your username and password:
GET https://api.mobile.digital/endpoint
Authorization: Basic base64(username:password)
Your API credentials are available from:
Contact your administrator or check your account dashboard to obtain your API key.
Test with a simple API call using cURL:
curl -X GET 'https://api.mobile.digital/test?api_key=YOUR_API_KEY'
import requests
api_key = "your_api_key_here"
base_url = "https://api.mobile.digital"
# Example: Send SMS
endpoint = f"{base_url}/sendSMS"
params = {
"api_key": api_key,
"recipient": "+61400000000",
"message": "Hello from Python!"
}
response = requests.get(endpoint, params=params)
print(response.json())
import requests
api_key = "your_api_key_here"
base_url = "https://api.mobile.digital"
# Example: Send SMS with header auth
endpoint = f"{base_url}/sendSMS"
headers = {
"X-API-Key": api_key,
"Content-Type": "application/json"
}
data = {
"recipient": "+61400000000",
"message": "Hello from Python with headers!"
}
response = requests.post(endpoint, headers=headers, json=data)
print(response.json())
curl -X POST 'https://api.mobile.digital/sendSMS?api_key=YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"recipient": "+61400000000",
"message": "Hello from cURL!"
}'
curl -X POST 'https://api.mobile.digital/sendSMS' \
-H 'X-API-Key: YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"recipient": "+61400000000",
"message": "Hello from cURL with headers!"
}'
<?php
$api_key = "your_api_key_here";
$base_url = "https://api.mobile.digital";
// Example: Send SMS
$endpoint = "$base_url/sendSMS";
$data = [
"recipient" => "+61400000000",
"message" => "Hello from PHP!"
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $endpoint . "?api_key=" . urlencode($api_key));
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo "Response ($http_code): $response\n";
?>
const axios = require('axios');
const apiKey = 'your_api_key_here';
const baseUrl = 'https://api.mobile.digital';
// Example: Send SMS with header auth
async function sendSMS() {
try {
const response = await axios.post(
`${baseUrl}/sendSMS`,
{
recipient: '+61400000000',
message: 'Hello from Node.js!'
},
{
headers: {
'X-API-Key': apiKey,
'Content-Type': 'application/json'
}
}
);
console.log('Response:', response.data);
} catch (error) {
console.error('Error:', error.response?.data || error.message);
}
}
sendSMS();
const apiKey = 'your_api_key_here';
const baseUrl = 'https://api.mobile.digital';
// Example: Send SMS
fetch(`${baseUrl}/sendSMS`, {
method: 'POST',
headers: {
'X-API-Key': apiKey,
'Content-Type': 'application/json'
},
body: JSON.stringify({
recipient: '+61400000000',
message: 'Hello from JavaScript!'
})
})
.then(response => response.json())
.then(data => console.log('Response:', data))
.catch(error => console.error('Error:', error));
While the Basic API is simple and functional, OAuth2 offers several advantages:
| Feature | Basic API | OAuth2 API |
|---|---|---|
| Token Expiration | Never expires | 1 hour (automatically renewable) |
| Granular Permissions | All-or-nothing access | Scope-based access control |
| Token Revocation | Manual key rotation required | Instant token revocation |
| Security | Static credentials | Time-limited tokens + secret storage |
| Audit Trail | Limited | Detailed token usage logs |
client_id and client_secret from your administratorBasic API:
curl -X POST 'https://api.mobile.digital/sendSMS?api_key=YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{"recipient": "+61400000000", "message": "Hello!"}'
OAuth2 API:
# Step 1: Get token (cache this for 1 hour)
TOKEN=$(curl -X POST 'https://ah1ta9hc59.execute-api.ap-southeast-2.amazonaws.com/prod/oauth2/token' \
-H 'Authorization: Basic $(echo -n "client_id:client_secret" | base64)' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'grant_type=client_credentials&scope=read write' \
| jq -r '.access_token')
# Step 2: Use token in API call
curl -X POST 'https://ah1ta9hc59.execute-api.ap-southeast-2.amazonaws.com/prod/sendSMS' \
-H "Authorization: Bearer $TOKEN" \
-H 'Content-Type: application/json' \
-d '{"recipient": "+61400000000", "message": "Hello!"}'