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_).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"
]
}