REST API Documentation
Integrate high-speed SMS delivery, secure OTP verifications, and custom sender ID masks directly into your website, CRM, or application with our RESTful endpoints.
Authentication
All REST API requests must authenticate using a unique API Key. Your API key should be included in the request headers as X-API-Key. You can manage or rotate your API keys on the Settings page under developer options.
Keep Your API Key Secure
API keys grant full access to send SMS and OTPs from your account. Do not share them, expose them in public frontend client-side code (like raw browser JavaScript), or commit them to public code repositories (e.g. GitHub). Always use secure environment variables on your server.
Required HTTP Headers
sg_).Sandbox & Testing Environment
Simulate carrier delivery, trigger webhooks, and test edge cases with zero cost
SMSGo provides a complete, isolated Sandbox environment to test your software integrations without deducting your balance or sending real SMS to mobile networks. You can run automated test suites, staging environments, and local apps in parallel with production.
- Header:
X-API-Key: sg_live_... - Deducts credits from your SMS balance
- Dispatches actual SMS to Dialog, Mobitel, Hutch, Airtel
- Dispatches live delivery reports to your Live Webhook URL
- Header:
X-API-Key: sg_test_... - Zero cost (
cost: 0) — balance is never deducted - Mock telecom operator simulation with synthetic reference IDs
- Dispatches test delivery events to your Sandbox Webhook URL
Test Phone Numbers (Simulation Scenarios)
Sandbox OnlyUse these designated phone numbers to verify how your system handles both successful deliveries and telecom failure callbacks:
Sandbox API Call Example
curl -X POST https://api.smsgo.lk/api/v1/sms/send \
-H "Content-Type: application/json" \
-H "X-API-Key: sg_test_YOUR_SANDBOX_KEY" \
-d '{
"to": "94770000000",
"message": "Testing OTP: 948201",
"mask": "SMSGO"
}'{
"success": true,
"environment": "sandbox",
"data": {
"id": "cm1a2b3c40001...",
"to": "94770000000",
"mask": "SMSGO",
"status": "sent",
"cost": 0,
"serverRef": "582910",
"sentAt": "2026-09-14T02:00:00.000Z"
}
}Webhooks & Delivery Reports
Real-time asynchronous HTTP callbacks for status changes
Webhooks eliminate the need to poll our REST API for delivery status. When an SMS is accepted by the telecom operator or encounters a delivery error, SMSGo instantly dispatches an HTTP POST request containing the message ID, status, telecom reference, and error logs directly to your server.
Webhook Configuration
Configure your callback endpoint in the Settings > Integration dashboard, or update it programmatically via POST /api/v1/user/profile with {"webhookUrl":"https://..."}.
HTTP Specifications
- Method:
POST - Content-Type:
application/json - Signature Header:
X-SMSGo-Signature(HMAC SHA-256 hash using your API key) - Expected Response: Return HTTP
200 OKwithin 5 seconds to acknowledge receipt.
Events Fired
| Event Name | Trigger Condition |
|---|---|
| sms.status_update | Fired when an SMS changes state to sent (transmitted to carrier) or failed (carrier or gateway error). Triggered for Single SMS, OTPs, and each individual recipient in Bulk campaigns. |
Payload Schema Reference
| Field | Type | Requirement | Description |
|---|---|---|---|
| event | string | REQUIRED | Event identifier (always sms.status_update). |
| data.id | string | REQUIRED | The unique SMS ID returned when the message was sent via API. |
| data.status | string | REQUIRED | Current message status: sent or failed. |
| data.numbers | string | REQUIRED | Recipient mobile number in Sri Lankan international format (e.g. 94771234567). |
| data.serverRef | string | OPTIONAL | Telecom operator transaction or tracking reference ID (present when status: "sent"). |
| data.error | string | OPTIONAL | Reason for failure from telecom carrier or gateway (present when status: "failed"). |
| timestamp | string | REQUIRED | ISO 8601 UTC timestamp of the status event. |
Webhook Payload Examples
{
"event": "sms.status_update",
"data": {
"id": "cm1a2b3c40001xyz",
"status": "sent",
"numbers": "94771234567",
"serverRef": "ref-987654"
},
"timestamp": "2026-09-09T06:40:00.000Z"
}Webhook Receiver Code Examples
Set up an endpoint on your server to handle incoming POST requests and immediately return HTTP 200 OK:
const express = require('express');
const crypto = require('crypto');
const app = express();
app.use(express.json());
// Webhook listener endpoint
app.post('/webhooks/smsgo', (req, res) => {
const signature = req.headers['x-smsgo-signature'];
const apiKey = process.env.SMSGO_API_KEY;
// Optional: Cryptographically verify webhook authenticity
if (signature && apiKey) {
const expected = crypto
.createHmac('sha256', apiKey)
.update(JSON.stringify(req.body))
.digest('hex');
if (signature !== expected) {
return res.status(401).json({ error: 'Invalid webhook signature' });
}
}
const { event, data } = req.body;
if (event === 'sms.status_update') {
const { id, status, numbers, serverRef, error } = data;
if (status === 'sent') {
console.log(`SMS ${id} to ${numbers} delivered! Carrier Ref: ${serverRef}`);
// Update database: status = 'sent'
} else if (status === 'failed') {
console.error(`SMS ${id} to ${numbers} failed: ${error}`);
// Handle failure / alert
}
}
// Acknowledge receipt
res.status(200).json({ received: true });
});
app.listen(3000, () => console.log('Webhook server listening on port 3000'));WooCommerce Integration
We offer a dedicated WooCommerce plugin that allows you to easily send SMS order alerts, transaction updates, and note notifications directly from your WordPress store to your customers.
SMSGo for WooCommerce Plugin
Version 1.1.0 (Includes WooCommerce deferred hook updates)
Quick Setup Guide
- Download the zip file using the button above.
- In your WordPress Admin, go to Plugins > Add New > Upload Plugin, select the zip, install and activate it.
- Navigate to WooCommerce > Settings > SMSGo.
- Enter your SMSGo API Key (starts with
sg_) and select your approved sender mask. - Enable and write custom SMS templates for individual order status changes.
Shopify Integration
Integrate SMSGo directly with your Shopify store. The most efficient way to send automated transactional SMS notifications (such as order confirmations and shipping updates) is by using Shopify's official Shopify Flow app to trigger HTTP REST requests directly to the SMSGo API.
Setup Guide using Shopify Flow
- Install the free, official Shopify Flow app from the Shopify App Store.
- Create a new workflow and select a trigger event (e.g.,
Order createdorFulfillment created). - Add a new Action and choose Send HTTP request.
- Configure the HTTP Request block with the following settings:
- HTTP Method:
POST - URL:
https://api.smsgo.lk/api/v1/sms/send - Headers:Content-Type: application/jsonX-API-Key: YOUR_API_KEY
- Body (JSON):
{ "to": "{{order.billingAddress.phone}}", "message": "Hi {{order.billingAddress.firstName}}, your order {{order.name}} has been placed successfully! Order total is {{order.totalPriceSet.shopMoney.amount}} LKR.", "mask": "YOUR_MASK" }
- HTTP Method:
- Turn on the workflow to start dispatching automated messages.
Laravel Integration
Connect your Laravel application to the SMSGo API. You can dispatch transactional alerts directly using Laravel's native HTTP Client, or create a custom Notification Channel to manage SMS alerts across your database entities.
Option A: Using HTTP Client Facade
use Illuminate\Support\Facades\Http;
$response = Http::withHeaders([
'X-API-Key' => env('SMSGO_API_KEY'),
'Content-Type' => 'application/json',
])->post('https://api.smsgo.lk/api/v1/sms/send', [
'to' => '94771234567',
'message' => 'Your order #1001 has been placed successfully!',
'mask' => 'SMSGO', // Your approved sender ID
]);
if ($response->successful()) {
$data = $response->json();
// Message sent successfully
}Option B: Custom Notification Channel
Create a custom SMS channel to dispatch database-driven user notifications. Define a helper class under app/Notifications/Channels/SmsGoChannel.php:
namespace App\Notifications\Channels;
use Illuminate\Notifications\Notification;
use Illuminate\Support\Facades\Http;
class SmsGoChannel
{
public function send($notifiable, Notification $notification)
{
$message = $notification->toSmsGo($notifiable);
$to = $notifiable->routeNotificationFor('smsgo') ?? $notifiable->phone;
if (!$to) {
return;
}
Http::withHeaders([
'X-API-Key' => config('services.smsgo.key'),
'Content-Type' => 'application/json',
])->post('https://api.smsgo.lk/api/v1/sms/send', [
'to' => $to,
'message' => $message,
'mask' => config('services.smsgo.mask', 'SMSGO'),
]);
}
}Node.js Integration
Integrate SMSGo directly into your Node.js application. Use third-party libraries like axios to write clean utility modules to send OTP verifications and transactional SMS messages.
Step 1: Create an SMS Helper
const axios = require('axios');
async function sendSMS(to, message, mask = 'SMSGO') {
try {
const response = await axios.post('https://api.smsgo.lk/api/v1/sms/send', {
to,
message,
mask
}, {
headers: {
'X-API-Key': process.env.SMSGO_API_KEY,
'Content-Type': 'application/json'
}
});
return response.data;
} catch (error) {
console.error('SMSGo API Error:', error.response?.data || error.message);
throw error;
}
}Step 2: Use Helper in Express Endpoint
const express = require('express');
const app = express();
app.use(express.json());
app.post('/api/send-alert', async (req, res) => {
const { phoneNumber, alertText } = req.body;
try {
const result = await sendSMS(phoneNumber, alertText);
res.json({ success: true, data: result.data });
} catch (error) {
res.status(500).json({ success: false, error: 'SMS dispatch failed' });
}
});/api/v1/sms/sendSend Single SMS
Send a single transactional or promotional SMS to a recipient mobile number.
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| to | string | REQUIRED | Recipient phone number in Sri Lankan format (e.g. 94771234567). |
| message | string | REQUIRED | The content of the SMS. Max 160 characters for a single segment (longer messages will be split into multiple parts). |
| mask | string | OPTIONAL | Your approved sender ID mask. Uses your first approved mask if omitted. |
| campaignName | string | OPTIONAL | Optional tag name to group stats in the dashboard. Defaults to 'API'. |
Request Example
curl -X POST https://api.smsgo.lk/api/v1/sms/send \
-H "Content-Type: application/json" \
-H "X-API-Key: YOUR_API_KEY" \
-d '{
"to": "94771234567",
"message": "Your SMSGo verification code is 492019",
"mask": "SMSGO"
}'Response Example (200 OK)
{
"success": true,
"data": {
"id": "cm1a2b3c40001...",
"to": "94771234567",
"mask": "SMSGO",
"status": "sent",
"cost": 2.2,
"serverRef": "ref-987654",
"sentAt": "2026-06-05T04:00:00.000Z"
}
}/api/v1/sms/bulkSend Bulk SMS
Send multiple customized SMS messages in a single API call. Maximum 1000 messages per request.
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| messages | array | REQUIRED | Array of message objects. Each object must contain 'to' and 'message', and optionally 'mask' and 'campaignName'. |
Request Example
curl -X POST https://api.smsgo.lk/api/v1/sms/bulk \
-H "Content-Type: application/json" \
-H "X-API-Key: YOUR_API_KEY" \
-d '{
"messages": [
{ "to": "94771234567", "message": "Hi Alice, your order is ready." },
{ "to": "94777654321", "message": "Hi Bob, your order is ready." }
]
}'Response Example (200 OK)
{
"success": true,
"data": {
"total": 2,
"sent": 2,
"failed": 0,
"messages": [
{
"id": "cm1a2b...",
"to": "94771234567",
"status": "sent",
"cost": 2.2
},
{
"id": "cm1a2c...",
"to": "94777654321",
"status": "sent",
"cost": 2.2
}
]
}
}/api/v1/otp/sendSend OTP (One-Time Password)
Generate and dispatch a secure verification code to a user's mobile number. SMSGo automatically generates the code and tracks the validation transaction.
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| phone | string | REQUIRED | Recipient mobile number (e.g. 94771234567). |
| mask | string | OPTIONAL | Your approved sender ID mask. Uses your first approved mask if omitted. |
| template | string | OPTIONAL | Custom template. Must include '{otp}' and optional '{expiry}'. E.g. 'Code is {otp}'. |
| length | number | OPTIONAL | Length of the OTP code. Defaults to 4 digits. |
| expiryMinutes | number | OPTIONAL | Validity time in minutes. Defaults to 5 minutes. |
Request Example
curl -X POST https://api.smsgo.lk/api/v1/otp/send \
-H "Content-Type: application/json" \
-H "X-API-Key: YOUR_API_KEY" \
-d '{
"phone": "94771234567",
"length": 6,
"expiryMinutes": 10
}'Response Example (200 OK)
{
"success": true,
"data": {
"referenceId": "otp-ref-4a5b6c...",
"phone": "94771234567",
"expiresAt": "2026-06-05T04:05:00.000Z"
}
}/api/v1/otp/verifyVerify OTP
Verify an OTP code submitted by a user using the reference ID returned by the send OTP endpoint.
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| referenceId | string | REQUIRED | The referenceId generated during the OTP request. |
| otp | string | REQUIRED | The verification code input by the user. |
Request Example
curl -X POST https://api.smsgo.lk/api/v1/otp/verify \
-H "Content-Type: application/json" \
-H "X-API-Key: YOUR_API_KEY" \
-d '{
"referenceId": "otp-ref-4a5b6c...",
"otp": "482910"
}'Response Example (200 OK)
{
"success": true,
"data": {
"referenceId": "otp-ref-4a5b6c...",
"status": "verified",
"verifiedAt": "2026-06-05T04:02:15.000Z"
}
}/api/v1/account/balanceCheck Balance
Retrieve your remaining LKR credit balance for active messaging operations.
Request Example
curl -X GET https://api.smsgo.lk/api/v1/account/balance \
-H "X-API-Key: YOUR_API_KEY"Response Example (200 OK)
{
"success": true,
"data": {
"balance": 2515.72,
"currency": "LKR"
}
}/api/v1/account/masksRetrieve Approved Masks
Fetch a list of all custom sender ID masks currently approved and active on your account.
Request Example
curl -X GET https://api.smsgo.lk/api/v1/account/masks \
-H "X-API-Key: YOUR_API_KEY"Response Example (200 OK)
{
"success": true,
"data": [
"SMSGO",
"MYBRAND",
"ALERT"
]
}