Send an SMS
curl --request POST \
--url https://api.sendbaze.com/v1/sms \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"to": "+27821234567",
"body": "Your OTP is 482 913. It expires in 5 minutes.",
"class": "transactional"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
to: '+27821234567',
body: JSON.stringify('Your OTP is 482 913. It expires in 5 minutes.'),
class: 'transactional'
})
};
fetch('https://api.sendbaze.com/v1/sms', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.sendbaze.com/v1/sms"
payload = {
"to": "+27821234567",
"body": "Your OTP is 482 913. It expires in 5 minutes.",
"class": "transactional"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)require 'uri'
require 'net/http'
url = URI("https://api.sendbaze.com/v1/sms")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"to\": \"+27821234567\",\n \"body\": \"Your OTP is 482 913. It expires in 5 minutes.\",\n \"class\": \"transactional\"\n}"
response = http.request(request)
puts response.read_body<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.sendbaze.com/v1/sms",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'to' => '+27821234567',
'body' => 'Your OTP is 482 913. It expires in 5 minutes.',
'class' => 'transactional'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.sendbaze.com/v1/sms"
payload := strings.NewReader("{\n \"to\": \"+27821234567\",\n \"body\": \"Your OTP is 482 913. It expires in 5 minutes.\",\n \"class\": \"transactional\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"id": "sm_01j9x7k2r4m8q3v5n6b7c8d9e0",
"status": "queued",
"mode": "live",
"segments": 1,
"credits": 1
}{
"error": {
"code": "validation_error",
"message": "<string>",
"docs": "<string>",
"fields": {},
"limit": 123,
"upgradeUrl": "<string>",
"topUpUrl": "<string>",
"settingsUrl": "<string>",
"domainsUrl": "<string>"
}
}{
"error": {
"code": "validation_error",
"message": "The request has invalid fields.",
"docs": "https://docs.sendbaze.com/errors#validation_error",
"fields": {
"to.1": [
"must be a valid email address"
]
}
}
}{
"error": {
"code": "validation_error",
"message": "<string>",
"docs": "<string>",
"fields": {},
"limit": 123,
"upgradeUrl": "<string>",
"topUpUrl": "<string>",
"settingsUrl": "<string>",
"domainsUrl": "<string>"
}
}SMS
Send an SMS
Counts segments, checks credits, applies the compliance rules for the message class, debits credits and
queues the message. Marketing SMS outside 08:00 to 20:00 SAST (or on Sundays and public holidays) is held
and sent at 08:00 on the next permitted day with status scheduled. Requires sms:send.
POST
/
v1
/
sms
Send an SMS
curl --request POST \
--url https://api.sendbaze.com/v1/sms \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"to": "+27821234567",
"body": "Your OTP is 482 913. It expires in 5 minutes.",
"class": "transactional"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
to: '+27821234567',
body: JSON.stringify('Your OTP is 482 913. It expires in 5 minutes.'),
class: 'transactional'
})
};
fetch('https://api.sendbaze.com/v1/sms', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.sendbaze.com/v1/sms"
payload = {
"to": "+27821234567",
"body": "Your OTP is 482 913. It expires in 5 minutes.",
"class": "transactional"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)require 'uri'
require 'net/http'
url = URI("https://api.sendbaze.com/v1/sms")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"to\": \"+27821234567\",\n \"body\": \"Your OTP is 482 913. It expires in 5 minutes.\",\n \"class\": \"transactional\"\n}"
response = http.request(request)
puts response.read_body<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.sendbaze.com/v1/sms",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'to' => '+27821234567',
'body' => 'Your OTP is 482 913. It expires in 5 minutes.',
'class' => 'transactional'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.sendbaze.com/v1/sms"
payload := strings.NewReader("{\n \"to\": \"+27821234567\",\n \"body\": \"Your OTP is 482 913. It expires in 5 minutes.\",\n \"class\": \"transactional\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"id": "sm_01j9x7k2r4m8q3v5n6b7c8d9e0",
"status": "queued",
"mode": "live",
"segments": 1,
"credits": 1
}{
"error": {
"code": "validation_error",
"message": "<string>",
"docs": "<string>",
"fields": {},
"limit": 123,
"upgradeUrl": "<string>",
"topUpUrl": "<string>",
"settingsUrl": "<string>",
"domainsUrl": "<string>"
}
}{
"error": {
"code": "validation_error",
"message": "The request has invalid fields.",
"docs": "https://docs.sendbaze.com/errors#validation_error",
"fields": {
"to.1": [
"must be a valid email address"
]
}
}
}{
"error": {
"code": "validation_error",
"message": "<string>",
"docs": "<string>",
"fields": {},
"limit": 123,
"upgradeUrl": "<string>",
"topUpUrl": "<string>",
"settingsUrl": "<string>",
"domainsUrl": "<string>"
}
}Authorizations
An API key from the dashboard. sk_live_… sends; sk_test_… validates and returns ids without sending.
Headers
Up to 255 characters. The same key and body return the same response for 24 hours.
Maximum string length:
255Body
application/json
E.164.
Example:
"+27821234567"
Maximum string length:
1600Available options:
transactional, marketing A registered alphanumeric sender id.
Up to 30 days ahead.
Maximum array length:
10Maximum string length:
64