API Documentation
FAQs, quick fixes, and official info on every feature. Can't find your question here, try our support forums.
Getting Started
The Smsdojo API allows you to send SMS messages through your Android device as a gateway. To use this API, you must:
- Create an account on SMSdojo.
- Install the Android App to connect your device.
- Authenticate using your API key.
Installation
Android App Download: Download the SMSdojo App to start sending SMS via your device.
API Authentication
- The API requires authentication via an API key.
- Obtain your API key from your SMSDojo account dashboard.
- Authentication URL:
https://app.smsdojo.io/api.php
Endpoint: Send SMS
- URL:
https://app.smsdojo.io/services/send.php - Method:
GET
Request Parameters
- key: Your unique API key (required).
- number: The phone number to send the SMS (required).
- message: The SMS content (URL-encoded; required).
- devices: JSON-encoded array of devices and SIM slots. Format:
["deviceID|simSlot"](required). - type: Type of message. Set to
sms(required). - prioritize: 0 or 1 (optional, default 0). Prioritize device for sending if multiple devices are available.
- Example Request:
https://app.smsdojo.io/services/send.php?key=YOUR_API_KEY&number=0608918217&message=This+message&devices=%5B%22182%7C0%22%2C%22182%7C1%22%5D&type=sms&prioritize=0
API Usage Examples
JavaScript (Fetch)
fetch('https://app.smsdojo.io/services/send.php?key=YOUR_API_KEY&number=0608918217&message=This%20message&devices=%5B%22182%7C0%22%2C%22182%7C1%22%5D&type=sms&prioritize=0')
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
cURL
curl -X GET "https://app.smsdojo.io/services/send.php?key=YOUR_API_KEY&number=0608918217&message=This+message&devices=%5B%22182%7C0%22%2C%22182%7C1%22%5D&type=sms&prioritize=0"
PHP
<?php
$response = file_get_contents("https://app.smsdojo.io/services/send.php?key=YOUR_API_KEY&number=0608918217&message=This+message&devices=%5B%22182%7C0%22%2C%22182%7C1%22%5D&type=sms&prioritize=0");
$data = json_decode($response, true);
print_r($data);
?>
React
import React, { useEffect, useState } from 'react';
function App() {
const [data, setData] = useState(null);
useEffect(() => {
fetch('https://app.smsdojo.io/services/send.php?key=YOUR_API_KEY&number=0608918217&message=This%20message&devices=%5B%22182%7C0%22%2C%22182%7C1%22%5D&type=sms&prioritize=0')
.then(response => response.json())
.then(data => setData(data))
.catch(error => console.error('Error:', error));
}, []);
return <div>{data && JSON.stringify(data)}</div>;
}
export default App;
C#
using System;
using System.Net.Http;
using System.Threading.Tasks;
class Program {
static async Task Main(string[] args) {
using HttpClient client = new HttpClient();
string url = "https://app.smsdojo.io/services/send.php?key=YOUR_API_KEY&number=0608918217&message=This+message&devices=%5B%22182%7C0%22%2C%22182%7C1%22%5D&type=sms&prioritize=0";
HttpResponseMessage response = await client.GetAsync(url);
string result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
}
Python
import requests
url = "https://app.smsdojo.io/services/send.php"
params = {
"key": "YOUR_API_KEY",
"number": "0608918217",
"message": "This message",
"devices": '["182|0","182|1"]',
"type": "sms",
"prioritize": 0
}
response = requests.get(url, params=params)
print(response.json())
Java
import java.io.*;
import java.net.*;
public class SmsdojoApi {
public static void main(String[] args) throws Exception {
String urlStr = "https://app.smsdojo.io/services/send.php?key=YOUR_API_KEY&number=0608918217&message=This+message&devices=%5B%22182%7C0%22%2C%22182%7C1%22%5D&type=sms&prioritize=0";
URL url = new URL(urlStr);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String inputLine;
StringBuffer content = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
content.append(inputLine);
}
in.close();
System.out.println(content.toString());
}
}
Response Format
Success Response
A successful request returns a JSON object with detailed message information:
{
"success": true,
"data": {
"messages": [
{
"ID": 296180,
"number": "0608918217",
"message": "This message",
"deviceID": 182,
"simSlot": 0,
"schedule": null,
"userID": 1,
"groupID": "DEGxMhxJiQUpU9F6nY671d682d63d9e2.96844762",
"status": "Pending",
"resultCode": null,
"errorCode": null,
"type": "sms",
"attachments": null,
"prioritize": false,
"retries": null,
"sentDate": "2024-10-26T23:07:41+0100",
"deliveredDate": null,
"expiryDate": null
}
]
},
"error": null
}
Error Response
In case of an error, the API returns a JSON object with an error code and message:
{
"success": false,
"data": null,
"error": {
"code": 401,
"message": "This API key is invalid."
}
}
Balance Query Response
If querying for credits, the response may look like this:
{
"success": true,
"data": {
"credits": null
},
"error": null
}
Balance Query Response
- 200: Request was successful.
- 400: Bad request (missing parameters, invalid format).
- 401: Unauthorized (invalid API key).
- 500: Internal server error.
Endpoint: Get Message Status
- URL:
https://app.smsdojo.io/services/get-msgs.php - Method:
GET
Request Parameters
- key: Your unique API key (required).
- status: Filter messages by status. Options include:
ReceivedPendingSentFailedQueuedDeliveredScheduled
Example Request:
GET https://app.smsdojo.io/services/get-msgs.php?key=dcf65ee699fe13eec2baaf06d1cfb6826e150a0d&status=Received
Example Code Snippets:
cURL
curlA "https://app.smsdojo.io/services/get-msgs.php?key=dcf65ee699fe13eec2baaf06d1cfb6826e150a0d&status=Received"
PHP:
$url = "https://app.smsdojo.io/services/get-msgs.php?key=dcf65ee699fe13eec2baaf06d1cfb6826e150a0d&status=Received";
$response = file_get_contents($url);
echo $response;
JavaScript (Fetch):
fetch("https://app.smsdojo.io/services/get-msgs.php?key=dcf65ee699fe13eec2baaf06d1cfb6826e150a0d&status=Received")
.then(response => response.json())
.then(data => console.log(data));
Python
import requests
url = "https://app.smsdojo.io/services/get-msgs.php"
params = {
"key": "dcf65ee699fe13eec2baaf06d1cfb6826e150a0d",
"status": "Received"
}
response = requests.get(url, params=params)
print(response.json())
C#
using System;
using System.Net.Http;
using System.Threading.Tasks;
class Program {
static async Task Main(string[] args) {
using HttpClient client = new HttpClient();
string url = "https://app.smsdojo.io/services/send.php?key=YOUR_API_KEY&number=0608918217&message=This+message&devices=%5B%22182%7C0%22%2C%22182%7C1%22%5D&type=sms&prioritize=0";
HttpResponseMessage response = await client.GetAsync(url);
string result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
}
Java
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class GetMessageStatus {
public static void main(String[] args) throws Exception {
String url = "https://app.smsdojo.io/services/get-msgs.php?key=dcf65ee699fe13eec2baaf06d1cfb6826e150a0d&status=Received";
URL obj = new URL(url);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("GET");
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer content = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
content.append(inputLine);
}
in.close();
System.out.println(content.toString());
}
}
Possible Response Format
- Success Response: Message status details
Java
{
"success": true,
"data": {
"messages": [
{
"ID": 296180,
"number": "0608918217",
"message": "This message",
"deviceID": 182,
"status": "Delivered",
// Additional fields...
}
]
},
"error": null
}
Error Response
Example of an invalid API key error.
{
"success": false,
"data": null,
"error": {
"code": 401,
"message": "This API key is invalid."
}
}
SMSdojo Webhook
This documentation provides an overview of setting up and handling webhooks for SMSDojo, allowing developers to receive and respond to events like incoming messages or USSD requests. Webhooks can be configured and managed in the SMSDojo Webhook Management.
Introduction
Webhooks in SMSDojo let you automatically trigger specific actions when events occur, like receiving an SMS message or a USSD request on your connected Android device. You can set up a URL endpoint on your server that SMSDojo can call, delivering event data in real-time. This integration makes it easy to automate responses or trigger workflows based on the incoming data.
Prerequisites
- Webhook URL:: You’ll need an endpoint on your server to receive SMSDojo webhook requests.
- API Key: Define your unique
API_KEYfor hashing signatures. This key will authenticate incoming requests to ensure security.
Prerequisites
HTTP_X_SG_SIGNATURE header to verify the request authenticity. Use your API_KEY to hash the message content and compare it against this signature. Example Code
Here is a PHP example to help developers get started with SMSDojo Webhooks. This script listens for incoming SMS messages and USSD requests, verifies the signature, and processes the data.
<?php
// Replace with your API Key
define("API_KEY", "dcf65ee699fe13eec2baaf06d1cfb6826e150a0d");
try {
if (isset($_SERVER["HTTP_X_SG_SIGNATURE"])) {
// Handling incoming SMS messages
if (isset($_POST["messages"])) {
$hash = base64_encode(hash_hmac('sha256', $_POST["messages"], API_KEY, true));
if ($hash === $_SERVER["HTTP_X_SG_SIGNATURE"]) {
$messages = json_decode($_POST["messages"], true);
foreach ($messages as $message) {
// Check if message content is "hi" and respond
if (strtolower($message["message"]) === "hi") {
// You can respond using an API call here, for example:
// sendReply($message["number"], "Hello! How can I help you?");
}
}
} else {
throw new Exception("Signature doesn't match!");
}
}
// Handling USSD requests
else if (isset($_POST["ussdRequest"])) {
$hash = base64_encode(hash_hmac('sha256', $_POST["ussdRequest"], API_KEY, true));
if ($hash === $_SERVER["HTTP_X_SG_SIGNATURE"]) {
$ussdRequest = json_decode($_POST["ussdRequest"]);
$deviceID = $ussdRequest->deviceID;
$simSlot = $ussdRequest->simSlot;
$request = $ussdRequest->request;
$response = $ussdRequest->response;
// Perform actions based on USSD data
} else {
throw new Exception("Signature doesn't match!");
}
}
} else {
http_response_code(400);
error_log("Signature not found!");
}
} catch (Exception $e) {
http_response_code(401);
error_log($e->getMessage());
}
?>
Explanation of Fields
Incoming SMS Messages
messages array, where each message has the following structure:
- ID: Unique identifier of the message.
- number: The sender’s phone number.
- message: The content of the SMS.
- deviceID: The ID of the device that received the message.
- simSlot: The SIM slot that received the message.
- userID: User ID associated with the message.
- status: Current status of the message (e.g., “Received”).
- sentDate: Date and time the message was received on the device.
- deliveredDate: Date and time the message was received by the server.
- groupID: If the message is part of a group, it contains the group ID; otherwise, it’s null.
Incoming USSD Requests
USSD requests have the following fields:
- deviceID: The ID of the device that received the USSD request.
- simSlot: The SIM slot from which the request was received.
- request: The USSD code entered.
- response: Response text associated with the USSD request.
Setting Up Webhooks on SMSDojo
- Log in to the SMSdojo Webhook Management.
- Enter your webhook URL, where SMSdojo will send requests.
- Select the types of events (e.g., SMS, USSD) you want to receive at this endpoint.
- Save your settings.
This concludes the SMSDojo Webhook documentation, providing developers with the necessary information to set up and handle SMSDojo webhooks.
SMSdojo Webhook
This documentation provides an overview of setting up and handling webhooks for SMSDojo, allowing developers to receive and respond to events like incoming messages or USSD requests. Webhooks can be configured and managed in the SMSDojo Webhook Management.
Introduction
Webhooks in SMSDojo let you automatically trigger specific actions when events occur, like receiving an SMS message or a USSD request on your connected Android device. You can set up a URL endpoint on your server that SMSDojo can call, delivering event data in real-time. This integration makes it easy to automate responses or trigger workflows based on the incoming data.
Prerequisites
- Webhook URL:: You’ll need an endpoint on your server to receive SMSDojo webhook requests.
- API Key: Define your unique
API_KEYfor hashing signatures. This key will authenticate incoming requests to ensure security.
Prerequisites
Each webhook request contains a signature in the HTTP_X_SG_SIGNATURE header to verify the request authenticity. Use your API_KEY to hash the message content and compare it against this signature.
Example Code
Here is a PHP example to help developers get started with SMSDojo Webhooks. This script listens for incoming SMS messages and USSD requests, verifies the signature, and processes the data.
<?php
// Replace with your API Key
define("API_KEY", "dcf65ee699fe13eec2baaf06d1cfb6826e150a0d");
try {
if (isset($_SERVER["HTTP_X_SG_SIGNATURE"])) {
// Handling incoming SMS messages
if (isset($_POST["messages"])) {
$hash = base64_encode(hash_hmac('sha256', $_POST["messages"], API_KEY, true));
if ($hash === $_SERVER["HTTP_X_SG_SIGNATURE"]) {
$messages = json_decode($_POST["messages"], true);
foreach ($messages as $message) {
// Check if message content is "hi" and respond
if (strtolower($message["message"]) === "hi") {
// You can respond using an API call here, for example:
// sendReply($message["number"], "Hello! How can I help you?");
}
}
} else {
throw new Exception("Signature doesn't match!");
}
}
// Handling USSD requests
else if (isset($_POST["ussdRequest"])) {
$hash = base64_encode(hash_hmac('sha256', $_POST["ussdRequest"], API_KEY, true));
if ($hash === $_SERVER["HTTP_X_SG_SIGNATURE"]) {
$ussdRequest = json_decode($_POST["ussdRequest"]);
$deviceID = $ussdRequest->deviceID;
$simSlot = $ussdRequest->simSlot;
$request = $ussdRequest->request;
$response = $ussdRequest->response;
// Perform actions based on USSD data
} else {
throw new Exception("Signature doesn't match!");
}
}
} else {
http_response_code(400);
error_log("Signature not found!");
}
} catch (Exception $e) {
http_response_code(401);
error_log($e->getMessage());
}
?>
Contact information
For any additional questions, technical support, or feature requests, please don’t hesitate to reach out. We’re here to assist you in making the most of your SMSDojo experience!
- Email:
support@smsdojo.io
Thank you for choosing SMSdojo for your SMS solutions!
Effortlessly send unlimited SMS, automate responses, and integrate with your favorite apps, all from your Android device
© SMSDojo.io. All Rights Reserved.