Code Samples
Ready-to-use code samples for integrating SBS TELECOM into your application. All samples use the HTTP REST API and authenticate with your API key and secret pair from the portal.
cURL
curl -X POST https://portal.sbstelecom.net/api/v1/sms \
-u "YOUR_API_KEY:YOUR_API_SECRET" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: order-4471-sms" \
-d '{"to":"+447911123456","from":"SBSTEL","text":"Your OTP is 847291"}'
PHP
<?php
$apiKey = 'YOUR_API_KEY';
$apiSecret = 'YOUR_API_SECRET';
$data = [
'to' => '+447911123456',
'from' => 'SBSTEL',
'text' => 'Your OTP is 847291',
];
$ch = curl_init('https://portal.sbstelecom.net/api/v1/sms');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, $apiKey . ':' . $apiSecret);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'Idempotency-Key: order-4471-sms',
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
echo $response['message_id'];
Python
import requests
response = requests.post(
"https://portal.sbstelecom.net/api/v1/sms",
auth=("YOUR_API_KEY", "YOUR_API_SECRET"),
headers={"Idempotency-Key": "order-4471-sms"},
json={"to": "+447911123456", "from": "SBSTEL", "text": "Your OTP is 847291"},
)
response.raise_for_status()
print(response.json()["message_id"])
Node.js
const axios = require("axios");
const response = await axios.post(
"https://portal.sbstelecom.net/api/v1/sms",
{ to: "+447911123456", from: "SBSTEL", text: "Your OTP is 847291" },
{
auth: { username: "YOUR_API_KEY", password: "YOUR_API_SECRET" },
headers: { "Idempotency-Key": "order-4471-sms" },
}
);
console.log(response.data.message_id);
Checking Delivery
A successful submission returns 202 Accepted. Pass the returned message_id to the status endpoint to follow delivery:
curl -u "YOUR_API_KEY:YOUR_API_SECRET" \
https://portal.sbstelecom.net/api/v1/sms/MESSAGE_ID