SMS API
Integration Guide
Send SMS messages programmatically from any platform. Simple REST API with GET/POST support, compatible with all major languages and frameworks.
All API requests require an API key passed as the api_key parameter. Your key is available in the platform dashboard.
All five parameters are required for every send-sms request.
| Parameter | Type | Description |
|---|---|---|
| actionrequired | string | Always send-sms |
| api_keyrequired | string | Your API authentication key from the dashboard. |
| torequired | string | Recipient phone in international format e.g. +233244000000. Comma-separate multiple numbers for bulk. |
| fromrequired | string | Registered Sender ID (max 11 alphanumeric chars) or a phone number. |
| smsrequired | string | The message body. Max 160 chars per SMS unit โ longer messages split automatically. |
| unicodeoptional | integer | Set to 1 to send a Unicode SMS (supports Arabic, Chinese, emojis etc.). Max 70 chars per unit. |
| scheduleoptional | string | Schedule delivery time in format mm/dd/yyyy hh:mm AM. Example: 03/19/2026 10:36 AM. Must be a future time. |
Every API response includes a numeric code field. Use this to handle outcomes precisely in your application.
{ "code" : "OK", "message_id" : "MSG1234567890", "to" : "+233244000000", "units" : 1, "balance" : 49 }
{ "code" : 103, "message" : "Invalid phone number" }
| Code | Meaning | How to Handle |
|---|---|---|
| OK | Successfully Sent | Message accepted for delivery. Store the message_id for tracking. |
| 100 | Bad gateway request | Malformed request. Verify the endpoint URL and all parameter names. |
| 101 | Wrong action | The action parameter must be exactly send-sms. |
| 102 | Authentication failed | Invalid api_key. Check your dashboard โ no extra spaces or characters. |
| 103 | Invalid phone number | Use full international format: +233244000000. No spaces or dashes. |
| 104 | Phone coverage not active | The destination network is not supported or coverage is unavailable for that number. |
| 105 | Insufficient balance | Top up your SMS credits in the platform dashboard. |
| 106 | Invalid Sender ID | Your Sender ID is not registered or exceeds 11 alphanumeric characters. |
| 109 | Invalid Schedule Time | The scheduled delivery time is invalid or in the past. |
| 111 | SMS contains spam word | Message flagged for review. Awaiting manual approval โ avoid promotional trigger words. |
Test the API directly from your terminal.
# GET request curl "https://sms.gonlinesites.com/app/sms/api?action=send-sms\ &api_key=YOUR_API_KEY\ &to=+233244000000\ &from=MySenderID\ &sms=Hello%20from%20the%20API"
# POST request curl -X POST "https://sms.gonlinesites.com/app/sms/api" \ -H "Content-Type: application/x-www-form-urlencoded" \ -d "action=send-sms" \ -d "api_key=YOUR_API_KEY" \ -d "to=+233244000000" \ -d "from=MySenderID" \ -d "sms=Hello from the API"
Use requests, built-in urllib, or a reusable client class.
import requests API_URL = "https://sms.gonlinesites.com/app/sms/api" API_KEY = "YOUR_API_KEY" def send_sms(to, sender_id, message): payload = { "action" : "send-sms", "api_key" : API_KEY, "to" : to, "from" : sender_id, "sms" : message, } try: r = requests.get(API_URL, params=payload, timeout=30) r.raise_for_status() data = r.json() if data.get("code") == "OK": print(f"Sent! ID: {data['message_id']}") else: print(f"Error {data['code']}: {data['message']}") return data except requests.exceptions.RequestException as e: return {"code": "error", "message": str(e)} send_sms("+233244000000", "MySenderID", "Hello!")
import urllib.request, urllib.parse, json API_URL = "https://sms.gonlinesites.com/app/sms/api" API_KEY = "YOUR_API_KEY" def send_sms(to, sender_id, message): params = urllib.parse.urlencode({ "action":"send-sms", "api_key":API_KEY, "to":to, "from":sender_id, "sms":message, }) with urllib.request.urlopen(f"{API_URL}?{params}", timeout=30) as r: return json.loads(r.read().decode()) print(send_sms("+233244000000", "MySenderID", "Hello!"))
import requests from typing import Union, List class SMSClient: BASE_URL = "https://sms.gonlinesites.com/app/sms/api" def __init__(self, api_key: str, sender_id: str): self.api_key = api_key self.sender_id = sender_id self.session = requests.Session() def send(self, to: Union[str, List[str]], message: str) -> dict: recipients = ",".join(to) if isinstance(to, list) else to r = self.session.get(self.BASE_URL, params={ "action":"send-sms", "api_key":self.api_key, "to":recipients, "from":self.sender_id, "sms":message }, timeout=30) r.raise_for_status() return r.json() sms = SMSClient("YOUR_API_KEY", "MySenderID") sms.send("+233244000000", "Hello!") sms.send(["+233244000000", "+233200111222"], "Bulk alert!")
Use cURL, file_get_contents, or Guzzle.
<?php define('SMS_API_URL', 'https://sms.gonlinesites.com/app/sms/api'); define('SMS_API_KEY', 'YOUR_API_KEY'); function sendSMS($to, $from, $message): array { $params = http_build_query([ 'action' => 'send-sms', 'api_key' => SMS_API_KEY, 'to' => $to, 'from' => $from, 'sms' => $message, ]); $ch = curl_init(SMS_API_URL . '?' . $params); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 30, CURLOPT_SSL_VERIFYPEER => true, ]); $response = curl_exec($ch); $error = curl_error($ch); curl_close($ch); if ($error) return ['code' => 'error', 'message' => $error]; $data = json_decode($response, true); if ($data['code'] === 'OK') { echo "Sent! ID: {$data['message_id']}"; } else { echo "Error {$data['code']}: {$data['message']}"; } return $data; } sendSMS('+233244000000', 'MySenderID', 'Hello!');
<?php $query = http_build_query([ 'action' => 'send-sms', 'api_key' => 'YOUR_API_KEY', 'to' => '+233244000000', 'from' => 'MySenderID', 'sms' => 'Hello World!', ]); $ctx = stream_context_create(['http' => ['timeout' => 30]]); $data = json_decode(file_get_contents("https://sms.gonlinesites.com/app/sms/api?{$query}", context: $ctx), true); var_dump($data);
<?php // composer require guzzlehttp/guzzle use GuzzleHttp\Client; $client = new Client(['base_uri' => 'https://sms.gonlinesites.com']); $response = $client->get('/app/sms/api', [ 'query' => [ 'action' => 'send-sms', 'api_key' => 'YOUR_API_KEY', 'to' => '+233244000000', 'from' => 'MySenderID', 'sms' => 'Hello via Guzzle!', ], ]); print_r(json_decode($response->getBody(), true));
Service class, Http Facade, config setup, and Notification channel.
<?php namespace App\Services; use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Log; class SmsService { protected string $apiKey; protected string $senderId; protected string $baseUrl = 'https://sms.gonlinesites.com/app/sms/api'; public function __construct() { $this->apiKey = config('sms.api_key'); $this->senderId = config('sms.sender_id'); } public function send(string $to, string $message): array { $response = Http::timeout(30)->get($this->baseUrl, [ 'action' => 'send-sms', 'api_key' => $this->apiKey, 'to' => $to, 'from' => $this->senderId, 'sms' => $message, ]); if ($response->failed()) { Log::error('SMS HTTP error', ['to' => $to]); return ['code' => 'error']; } $data = $response->json(); if ($data['code'] !== 'OK') { Log::warning('SMS send error', $data); } return $data; } public function sendBulk(array $numbers, string $message): array { return $this->send(implode(',', $numbers), $message); } }
<?php use Illuminate\Support\Facades\Http; $response = Http::get('https://sms.gonlinesites.com/app/sms/api', [ 'action' => 'send-sms', 'api_key' => env('SMS_API_KEY'), 'to' => '+233244000000', 'from' => env('SMS_SENDER_ID'), 'sms' => 'Hello from Laravel!', ]); $data = $response->json(); match ($data['code']) { 'OK' => logger("Sent: {$data['message_id']}"), 102 => abort(401, 'SMS authentication failed'), 105 => abort(402, 'Insufficient SMS balance'), default => logger("SMS error {$data['code']}: {$data['message']}"), };
SMS_API_KEY=YOUR_API_KEY SMS_SENDER_ID=MySenderID SMS_BASE_URL=https://sms.gonlinesites.com/app/sms/api
<?php return [ 'api_key' => env('SMS_API_KEY'), 'sender_id' => env('SMS_SENDER_ID', 'MySenderID'), 'base_url' => env('SMS_BASE_URL', 'https://sms.gonlinesites.com/app/sms/api'), ];
<?php namespace App\Notifications; use Illuminate\Notifications\Notification; class SmsNotification extends Notification { public function __construct(protected string $message) {} public function via($notifiable): array { return ['sms']; } public function toSms($notifiable): array { return ['to' => $notifiable->phone_number, 'message' => $this->message]; } } // $user->notify(new SmsNotification('Your OTP is 4921'));
Use axios, the native https module, or TypeScript.
// npm install axios const axios = require('axios'); async function sendSms(to, message) { const { data } = await axios.get('https://sms.gonlinesites.com/app/sms/api', { params: { action:'send-sms', api_key:'YOUR_API_KEY', to, from:'MySenderID', sms: message }, timeout: 30000, }); if (data.code === 'OK') { console.log(`Sent! ID: ${data.message_id}`); } else { console.error(`Error ${data.code}: ${data.message}`); } return data; } sendSms('+233244000000', 'Hello from Node!').catch(console.error);
const https = require('https'); const qs = require('querystring'); function sendSms(to, message) { return new Promise((resolve, reject) => { const q = qs.stringify({ action:'send-sms', api_key:'YOUR_API_KEY', to, from:'MySenderID', sms: message }); https.get(`https://sms.gonlinesites.com/app/sms/api?${q}`, res => { let b = ''; res.on('data', c => b += c); res.on('end', () => resolve(JSON.parse(b))); }).on('error', reject); }); } sendSms('+233244000000', 'Hello!').then(console.log);
import axios from 'axios'; interface SmsResponse { code : string | number; message_id?: string; message? : string; units? : number; balance? : number; } export async function sendSms( to : string | string[], message : string, from : string = process.env.SMS_SENDER_ID ?? '', ): Promise<SmsResponse> { const recipients = Array.isArray(to) ? to.join(',') : to; const { data } = await axios.get<SmsResponse>( 'https://sms.gonlinesites.com/app/sms/api', { params: { action:'send-sms', api_key: process.env.SMS_API_KEY, to: recipients, from, sms: message }, } ); if (data.code !== 'OK') throw new Error(`SMS ${data.code}: ${data.message}`); return data; }
const params = new URLSearchParams({ action:'send-sms', api_key:'YOUR_API_KEY', to:'+233244000000', from:'MySenderID', sms:'Hello from the browser!', }); fetch(`https://sms.gonlinesites.com/app/sms/api?${params}`) .then(r => r.json()) .then(d => d.code === 'OK' ? console.log('Sent!', d) : console.error(d)) .catch(console.error);
async function sendSms({ to, from, message }) { const url = new URL('https://sms.gonlinesites.com/app/sms/api'); Object.entries({ action:'send-sms', api_key:'YOUR_API_KEY', to, from, sms: message }) .forEach(([k,v]) => url.searchParams.set(k,v)); const data = await (await fetch(url)).json(); if (data.code !== 'OK') throw new Error(`[${data.code}] ${data.message}`); return data; }
Java 11+ HttpClient or OkHttp for Android/legacy projects.
import java.net.*; import java.net.http.*; import java.nio.charset.StandardCharsets; import java.time.Duration; public class SmsClient { private static final String BASE = "https://sms.gonlinesites.com/app/sms/api"; private static final String KEY = "YOUR_API_KEY"; private static final String SENDER = "MySenderID"; private final HttpClient http = HttpClient.newBuilder() .connectTimeout(Duration.ofSeconds(30)).build(); public String send(String to, String msg) throws Exception { String url = BASE + "?action=send-sms" + "&api_key=" + URLEncoder.encode(KEY, StandardCharsets.UTF_8) + "&to=" + URLEncoder.encode(to, StandardCharsets.UTF_8) + "&from=" + URLEncoder.encode(SENDER, StandardCharsets.UTF_8) + "&sms=" + URLEncoder.encode(msg, StandardCharsets.UTF_8); return http.send( HttpRequest.newBuilder().uri(URI.create(url)) .GET().timeout(Duration.ofSeconds(30)).build(), HttpResponse.BodyHandlers.ofString() ).body(); } }
// implementation 'com.squareup.okhttp3:okhttp:4.12.0' import okhttp3.*; public class SmsOkHttp { private static final OkHttpClient CLIENT = new OkHttpClient(); public static String send(String to, String msg) throws Exception { HttpUrl url = HttpUrl.parse("https://sms.gonlinesites.com/app/sms/api") .newBuilder() .addQueryParameter("action", "send-sms") .addQueryParameter("api_key", "YOUR_API_KEY") .addQueryParameter("to", to) .addQueryParameter("from", "MySenderID") .addQueryParameter("sms", msg).build(); try (Response r = CLIENT.newCall(new Request.Builder().url(url).build()).execute()) { return r.body().string(); } } }
Use HttpClient directly or register as a DI service.
using System.Net.Http; using System.Text.Json; public class SmsClient { private const string Base = "https://sms.gonlinesites.com/app/sms/api"; private const string ApiKey = "YOUR_API_KEY"; private const string Sender = "MySenderID"; private static readonly HttpClient _http = new(); public static async Task<JsonDocument> SendAsync(string to, string msg) { var b = new UriBuilder(Base); var q = System.Web.HttpUtility.ParseQueryString(string.Empty); q["action"]="send-sms"; q["api_key"]=ApiKey; q["to"]=to; q["from"]=Sender; q["sms"]=msg; b.Query = q.ToString(); var r = await _http.GetAsync(b.Uri); r.EnsureSuccessStatusCode(); return JsonDocument.Parse(await r.Content.ReadAsStringAsync()); } }
// Program.cs builder.Services.AddHttpClient<ISmsService, SmsService>(); builder.Services.Configure<SmsOptions>(builder.Configuration.GetSection("Sms")); public interface ISmsService { Task<bool> SendAsync(string to, string msg); } public class SmsService(HttpClient http, IOptions<SmsOptions> opts) : ISmsService { public async Task<bool> SendAsync(string to, string msg) { var o = opts.Value; var r = await http.GetAsync( $"{o.BaseUrl}?action=send-sms&api_key={o.ApiKey}&to={to}&from={o.SenderId}&sms={Uri.EscapeDataString(msg)}"); return r.IsSuccessStatusCode; } } // appsettings.json: { "Sms": { "ApiKey": "...", "SenderId": "...", "BaseUrl": "..." } }
Built-in net/http or the httparty gem.
require 'net/http'; require 'uri'; require 'json' def send_sms(to:, from:, message:) uri = URI('https://sms.gonlinesites.com/app/sms/api') uri.query = URI.encode_www_form( action: 'send-sms', api_key: 'YOUR_API_KEY', to:, from:, sms: message ) data = JSON.parse(Net::HTTP.get_response(uri).body) data['code'] == 'OK' ? puts("Sent: #{data['message_id']}") : puts("Error: #{data}") data end send_sms(to: '+233244000000', from: 'MySenderID', message: 'Hello!')
# gem install httparty require 'httparty' class SmsClient include HTTParty base_uri 'https://sms.gonlinesites.com' def initialize(api_key, sender) @key = api_key; @sender = sender end def send(to, message) self.class.get('/app/sms/api', query: { action: 'send-sms', api_key: @key, to:, from: @sender, sms: message }) end end sms = SmsClient.new('YOUR_API_KEY', 'MySenderID') data = sms.send('+233244000000', 'Hello!') puts data
Idiomatic Go using net/http with typed response struct and error code handling.
package main import ( "encoding/json"; "fmt"; "net/http"; "net/url"; "time" ) type SMSResponse struct { Code interface{} `json:"code"` MessageID string `json:"message_id,omitempty"` Message string `json:"message,omitempty"` Units int `json:"units,omitempty"` Balance int `json:"balance,omitempty"` } func (r SMSResponse) OK() bool { c, _ := r.Code.(string); return c == "OK" } func SendSMS(to, message string) (SMSResponse, error) { params := url.Values{ "action" : {"send-sms"}, "api_key" : {"YOUR_API_KEY"}, "to" : {to}, "from" : {"MySenderID"}, "sms" : {message}, } c := &http.Client{Timeout: 30 * time.Second} resp, err := c.Get("https://sms.gonlinesites.com/app/sms/api?" + params.Encode()) if err != nil { return SMSResponse{}, err } defer resp.Body.Close() var result SMSResponse json.NewDecoder(resp.Body).Decode(&result) return result, nil } func main() { r, _ := SendSMS("+233244000000", "Hello from Go!") if r.OK() { fmt.Println("Sent:", r.MessageID) } else { fmt.Println("Error:", r.Code, r.Message) } }
Automatically send SMS notifications when a Google Form is submitted โ one to the respondent confirming receipt, and one to your admin number with the full submission details. Uses Google Apps Script bound to your form.
| Step | Action |
|---|---|
| 1 | Open your Google Form โ click the three-dot menu โ Script editor |
| 2 | Paste the full script below, replacing YOUR_API_KEY and YOUR_SENDER_ID |
| 3 | Update adminPhone with your admin number in international format (e.g. 233242625794) |
| 4 | Adjust the field order comments if your form fields are in a different order |
| 5 | Save โ Triggers (clock icon) โ Add trigger โ onFormSubmit โ On form submit |
| 6 | Authorise the script when prompted โ required for UrlFetchApp to make HTTP calls |
/** * Trigger: On form submit * Reads form responses, sends SMS to the respondent * and a summary SMS to the admin. * * Form fields (adjust indices to match your form order): * 0 = Name * 1 = Email * 2 = Phone Number * 3 = Comments */ function onFormSubmit(e) { try { var items = e.response.getItemResponses(); var name = items[0].getResponse().trim(); var email = items[1].getResponse().trim(); var phone = formatGhanaPhone(items[2].getResponse()); var comments = items[3].getResponse().trim(); var adminPhone = "233242625794"; // โ your admin number // SMS sent to the person who filled the form var userMessage = "Hello " + name + ", thanks for submitting the form successfully."; // SMS sent to the admin var adminMessage = "New form submission:\n" + "Name: " + name + "\nEmail: " + email + "\nPhone: " + phone + "\nComments: "+ comments; sendSMS(phone, userMessage); sendSMS(adminPhone, adminMessage); } catch (error) { Logger.log("Error: " + error.toString()); } } /** * Convert Ghana local numbers to international format. * 024xxxxxxx โ 23324xxxxxxx * Accepts already-formatted 233xxxxxxxxx unchanged. */ function formatGhanaPhone(number) { number = number.toString().replace(/\D/g, ""); if (number.length === 10 && number.startsWith("0")) { return "233" + number.substring(1); } if (number.length === 12 && number.startsWith("233")) { return number; } return number; // return as-is if unrecognised format } /** * Send an SMS via the GONlineSites SMS API. * Uses UrlFetchApp โ no external libraries required. */ function sendSMS(to, message) { var url = "https://sms.gonlinesites.com/app/sms/api" + "?action=send-sms" + "&api_key=YOUR_API_KEY" + "&to=" + encodeURIComponent(to) + "&from=YOUR_SENDER_ID" + "&sms=" + encodeURIComponent(message); var response = UrlFetchApp.fetch(url, { muteHttpExceptions: true }); Logger.log(response.getContentText()); }
/** * Reusable SMS helper for Google Apps Script. * Drop this function into any .gs file and call: * sendSMS("+233244000000", "Your message here"); */ function sendSMS(to, message) { var url = "https://sms.gonlinesites.com/app/sms/api" + "?action=send-sms" + "&api_key=YOUR_API_KEY" + "&to=" + encodeURIComponent(to) + "&from=YOUR_SENDER_ID" + "&sms=" + encodeURIComponent(message); var response = UrlFetchApp.fetch(url, { muteHttpExceptions: true }); var result = JSON.parse(response.getContentText()); if (result.code === "OK") { Logger.log("Sent successfully. ID: " + result.message_id); } else { Logger.log("SMS error [" + result.code + "]: " + result.message); } return result; }
/** * Maps responses by question TITLE instead of index position. * More resilient โ survives reordering of form fields. */ function onFormSubmit(e) { try { var responses = {}; e.response.getItemResponses().forEach(function(item) { responses[item.getItem().getTitle()] = item.getResponse(); }); // โ change these strings to match your exact question titles var name = (responses["Full Name"] || "").trim(); var email = (responses["Email Address"] || "").trim(); var phone = formatGhanaPhone(responses["Phone Number"] || ""); var comments = (responses["Comments"] || "N/A").trim(); var adminPhone = "233242625794"; if (!phone) { Logger.log("No phone number found in response."); return; } sendSMS(phone, "Hello " + name + ", thanks for submitting the form successfully." ); sendSMS(adminPhone, "New submission:\nName: " + name + "\nEmail: " + email + "\nPhone: " + phone + "\nComments: "+ comments ); } catch (err) { Logger.log("Error: " + err.toString()); } } // Paste formatGhanaPhone() and sendSMS() from the Full Script tab above
The API supports three message types โ plain text, Unicode (extended character sets), and scheduled delivery. All share the same base endpoint.
| Type | Extra Param | Char Limit / Unit | Use Case |
|---|---|---|---|
| Plain Text | none | 160 chars | Standard English/Latin SMS |
| Unicode | unicode=1 | 70 chars | Arabic, Chinese, emoji, special scripts |
| Scheduled | schedule=mm/dd/yyyy hh:mm AM | 160 chars | Deliver at a future date and time |
https://sms.gonlinesites.com/app/sms/api ?action=send-sms &api_key=YOUR_API_KEY &to=PhoneNumber &from=SenderID &sms=YourMessage
https://sms.gonlinesites.com/app/sms/api ?action=send-sms &api_key=YOUR_API_KEY &to=PhoneNumber &from=SenderID &sms=YourMessage &unicode=1
https://sms.gonlinesites.com/app/sms/api ?action=send-sms &api_key=YOUR_API_KEY &to=PhoneNumber &from=SenderID &sms=YourMessage &schedule=03/19/2026 10:36 AM
Add the optional schedule parameter to any send-sms request to delay delivery to a specific future time.
| Parameter | Format | Example |
|---|---|---|
| scheduleoptional | mm/dd/yyyy hh:mm AM | 03/19/2026 10:36 AM |
import requests from datetime import datetime # Format: mm/dd/yyyy hh:mm AM schedule_time = "03/19/2026 10:36 AM" # Or build it dynamically dt = datetime(2026, 3, 19, 10, 36) schedule_time = dt.strftime("%m/%d/%Y %I:%M %p") payload = { "action" : "send-sms", "api_key" : "YOUR_API_KEY", "to" : "+233244000000", "from" : "MySenderID", "sms" : "This is a scheduled reminder!", "schedule" : schedule_time, # mm/dd/yyyy hh:mm AM } r = requests.get("https://sms.gonlinesites.com/app/sms/api", params=payload, timeout=30) print(r.json())
<?php // Format: mm/dd/yyyy hh:mm AM $scheduleTime = '03/19/2026 10:36 AM'; // Or build it dynamically $scheduleTime = date('m/d/Y h:i A', strtotime('+2 hours')); $params = http_build_query([ 'action' => 'send-sms', 'api_key' => 'YOUR_API_KEY', 'to' => '+233244000000', 'from' => 'MySenderID', 'sms' => 'This is a scheduled reminder!', 'schedule' => $scheduleTime, ]); $ch = curl_init('https://sms.gonlinesites.com/app/sms/api?' . $params); curl_setopt_array($ch, [CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 30]); $data = json_decode(curl_exec($ch), true); curl_close($ch); print_r($data);
use Carbon\Carbon; use Illuminate\Support\Facades\Http; // Format: mm/dd/yyyy hh:mm AM $scheduleTime = Carbon::now()->addHours(2)->format('m/d/Y h:i A'); $response = Http::get('https://sms.gonlinesites.com/app/sms/api', [ 'action' => 'send-sms', 'api_key' => config('sms.api_key'), 'to' => '+233244000000', 'from' => config('sms.sender_id'), 'sms' => 'Scheduled reminder from Laravel!', 'schedule' => $scheduleTime, ]); return $response->json();
const axios = require('axios'); // Format: mm/dd/yyyy hh:mm AM function formatSchedule(date) { const mm = String(date.getMonth() + 1).padStart(2, '0'); const dd = String(date.getDate()).padStart(2, '0'); const yy = date.getFullYear(); let hh = date.getHours(); const min = String(date.getMinutes()).padStart(2, '0'); const ampm = hh >= 12 ? 'PM' : 'AM'; hh = hh % 12 || 12; return `${mm}/${dd}/${yy} ${hh}:${min} ${ampm}`; } const sendAt = new Date(Date.now() + 2 * 60 * 60 * 1000); // 2 hrs from now axios.get('https://sms.gonlinesites.com/app/sms/api', { params: { action : 'send-sms', api_key : 'YOUR_API_KEY', to : '+233244000000', from : 'MySenderID', sms : 'Scheduled reminder!', schedule : formatSchedule(sendAt), }, }).then(r => console.log(r.data));
curl "https://sms.gonlinesites.com/app/sms/api\
?action=send-sms\
&api_key=YOUR_API_KEY\
&to=+233244000000\
&from=MySenderID\
&sms=Scheduled+reminder\
&schedule=03/19/2026+10:36+AM"
Query your account's remaining SMS credit balance at any time using the check-balance action.
https://sms.gonlinesites.com/app/sms/api ?action=check-balance &api_key=YOUR_API_KEY &response=json
| Parameter | Value | Description |
|---|---|---|
| action | check-balance | Action type for balance queries. |
| api_key | Your key | Your API authentication key. |
| response | json | Return format. Always use json. |
{ "status" : "success", "balance" : "245", "currency": "credits" }
import requests def check_balance(api_key): r = requests.get( "https://sms.gonlinesites.com/app/sms/api", params={"action": "check-balance", "api_key": api_key, "response": "json"}, timeout=30 ) data = r.json() print(f"Balance: {data['balance']} {data.get('currency','credits')}") return data check_balance("YOUR_API_KEY")
<?php $query = http_build_query([ 'action' => 'check-balance', 'api_key' => 'YOUR_API_KEY', 'response' => 'json', ]); $ctx = stream_context_create(['http' => ['timeout' => 30]]); $data = json_decode( file_get_contents("https://sms.gonlinesites.com/app/sms/api?{$query}", context: $ctx), true ); echo "Balance: {$data['balance']} credits";
public function checkBalance(): array { return Http::timeout(30)->get($this->baseUrl, [ 'action' => 'check-balance', 'api_key' => $this->apiKey, 'response' => 'json', ])->json(); } // Usage: $smsService->checkBalance()['balance']
const axios = require('axios'); async function checkBalance(apiKey) { const { data } = await axios.get( 'https://sms.gonlinesites.com/app/sms/api', { params: { action: 'check-balance', api_key: apiKey, response: 'json' }, } ); console.log(`Balance: ${data.balance} credits`); return data; } checkBalance('YOUR_API_KEY');
curl "https://sms.gonlinesites.com/app/sms/api\
?action=check-balance\
&api_key=YOUR_API_KEY\
&response=json"
Add phone numbers directly to a contact list (phonebook) in your account using the Contacts API endpoint.
https://sms.gonlinesites.com/app/contacts/api ?action=subscribe-us &api_key=YOUR_API_KEY &phone_book=ContactListName &phone_number=PhoneNumber &first_name=FirstName (optional) &last_name=LastName (optional) &email=EmailAddress (optional) &company=Company (optional) &user_name=UserName (optional)
| Parameter | Type | Description |
|---|---|---|
| actionrequired | string | Always subscribe-us for contact inserts. |
| api_keyrequired | string | Your API authentication key. |
| phone_bookrequired | string | Name of the contact list / phonebook to add the contact to. |
| phone_numberrequired | string | Phone number in international format e.g. +233244000000. |
| first_nameoptional | string | Contact's first name. |
| last_nameoptional | string | Contact's last name. |
| emailoptional | string | Contact's email address. |
| companyoptional | string | Contact's company or organisation name. |
| user_nameoptional | string | A username or unique identifier for the contact. |
import requests CONTACTS_URL = "https://sms.gonlinesites.com/app/contacts/api" API_KEY = "YOUR_API_KEY" def add_contact(phone_book, phone_number, **kwargs): """ Add a contact to a phonebook. Optional kwargs: first_name, last_name, email, company, user_name """ payload = { "action" : "subscribe-us", "api_key" : API_KEY, "phone_book" : phone_book, "phone_number" : phone_number, **kwargs, } r = requests.get(CONTACTS_URL, params=payload, timeout=30) return r.json() # Minimal add_contact("Customers", "+233244000000") # With optional fields add_contact( "Customers", "+233244000000", first_name="Kwame", last_name="Mensah", email="kwame@example.com", company="Acme Ltd", )
<?php function addContact(string $phoneBook, string $phoneNumber, array $extra = []): array { $params = http_build_query(array_filter(array_merge([ 'action' => 'subscribe-us', 'api_key' => 'YOUR_API_KEY', 'phone_book' => $phoneBook, 'phone_number' => $phoneNumber, ], $extra))); $ctx = stream_context_create(['http' => ['timeout' => 30]]); return json_decode( file_get_contents("https://sms.gonlinesites.com/app/contacts/api?{$params}", context: $ctx), true ); } // Minimal addContact('Customers', '+233244000000'); // With optional fields addContact('Customers', '+233244000000', [ 'first_name' => 'Kwame', 'last_name' => 'Mensah', 'email' => 'kwame@example.com', 'company' => 'Acme Ltd', ]);
protected string $contactsUrl = 'https://sms.gonlinesites.com/app/contacts/api'; public function addContact( string $phoneBook, string $phoneNumber, array $extra = [] ): array { return Http::timeout(30)->get($this->contactsUrl, array_filter(array_merge([ 'action' => 'subscribe-us', 'api_key' => $this->apiKey, 'phone_book' => $phoneBook, 'phone_number' => $phoneNumber, ], $extra)))->json(); } // Usage // $sms->addContact('Customers', '+233244000000', ['first_name' => 'Kwame']);
const axios = require('axios'); async function addContact(phoneBook, phoneNumber, extra = {}) { const { data } = await axios.get( 'https://sms.gonlinesites.com/app/contacts/api', { params: { action : 'subscribe-us', api_key : 'YOUR_API_KEY', phone_book : phoneBook, phone_number : phoneNumber, ...extra, }, } ); return data; } // Minimal addContact('Customers', '+233244000000'); // With optional fields addContact('Customers', '+233244000000', { first_name : 'Kwame', last_name : 'Mensah', email : 'kwame@example.com', company : 'Acme Ltd', });
# Minimal curl "https://sms.gonlinesites.com/app/contacts/api\ ?action=subscribe-us\ &api_key=YOUR_API_KEY\ &phone_book=Customers\ &phone_number=+233244000000" # With optional fields curl "https://sms.gonlinesites.com/app/contacts/api\ ?action=subscribe-us\ &api_key=YOUR_API_KEY\ &phone_book=Customers\ &phone_number=+233244000000\ &first_name=Kwame\ &last_name=Mensah\ &email=kwame%40example.com\ &company=Acme+Ltd"
Send to multiple recipients by comma-separating the to parameter.
import requests numbers = ["+233244000001", "+233244000002", "+233200111222"] r = requests.get("https://sms.gonlinesites.com/app/sms/api", params={ "action":"send-sms", "api_key":"YOUR_API_KEY", "to":",".join(numbers), "from":"MySenderID", "sms":"Important announcement!", }) data = r.json() print("Sent" if data['code'] == 'OK' else data)
<?php $numbers = ['+233244000001', '+233244000002', '+233200111222']; $query = http_build_query([ 'action' => 'send-sms', 'api_key' => 'YOUR_API_KEY', 'to' => implode(',', $numbers), 'from' => 'MySenderID', 'sms' => 'Announcement for all customers!', ]); print_r(json_decode(file_get_contents("https://sms.gonlinesites.com/app/sms/api?{$query}"), true));
const axios = require('axios'); const numbers = ['+233244000001', '+233244000002', '+233200111222']; axios.get('https://sms.gonlinesites.com/app/sms/api', { params: { action:'send-sms', api_key:'YOUR_API_KEY', to: numbers.join(','), from:'MySenderID', sms:'Announcement!' } }).then(r => console.log(r.data));
Keep these in mind when integrating the SMS API into your application.
&to=+233244000001,+233244000002,+233200111222
Most HTTP libraries (requests, axios, Guzzle, Http facade) handle this automatically when you pass parameters as a dictionary or array. When building URLs manually, use your language's encoding function:
Python:
urllib.parse.quote(text)PHP:
urlencode($text)JS:
encodeURIComponent(text)Java:
URLEncoder.encode(text, StandardCharsets.UTF_8)
Complete list of all API response codes and recommended handling for each.
| Code | Meaning | Recommended Action |
|---|---|---|
| OK | Successfully Sent | Message accepted. Log the message_id and update delivery status. |
| 100 | Bad gateway request | Check the endpoint URL, HTTP method, and all parameter names. Likely a malformed request. |
| 101 | Wrong action | The action parameter value must be exactly send-sms. Check for typos. |
| 102 | Authentication failed | The api_key is invalid or expired. Verify your key in the dashboard. No leading/trailing spaces. |
| 103 | Invalid phone number | Use full international format with country code: +233244000000. Remove spaces, dashes, and parentheses. |
| 104 | Phone coverage not active | The destination network or country is not covered. Contact support to check available routes. |
| 105 | Insufficient balance | Your account credit is too low. Log in to the dashboard and top up before retrying. |
| 106 | Invalid Sender ID | The Sender ID is not registered on the platform or exceeds 11 alphanumeric characters. Register it in your dashboard. |
| 109 | Invalid Schedule Time | The scheduled time is in the past or uses an invalid format. Use a future UTC timestamp. |
| 111 | SMS contains spam word | Message was flagged and is awaiting manual approval. Revise content to avoid common spam trigger words. |