Sending an SMS from PHP against a REST SMS API takes a single authenticated POST request. The example below uses cURL and needs no dependencies.
<?php
$ch = curl_init('https://your-domain.example/api/v1/messages');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer swl_live_YOUR_API_KEY',
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'recipient' => '255700000000',
'sender_id' => 'YOURBRAND',
'body' => 'Your order has shipped.',
]),
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
The API key is a Bearer token created from your account. Recipients are E.164-formatted
phone numbers, and sender_id is either your registered sender ID or your account's default sender.
See the full SMS API Tanzania page and the interactive API reference for every field the endpoint accepts.

