PHP
The SMS Bridge API is plain HTTPS and JSON, so you do not need a special package. This example uses the standard HTTP client — it needs PHP 8 with the curl extension. Official client packages are planned; until then, copy this into your project.
Send an SMS
Put your API key in the SMS_BRIDGE_KEY environment variable, and use one of your paired phone numbers as from_number.
<?php
// PHP 8+ with the curl extension
$ch = curl_init("https://api.99billingsolutions.com/v1/messages/send");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"x-api-key: " . getenv("SMS_BRIDGE_KEY"),
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode([
"from_number" => "+15550100001",
"to_number" => "+15550100002",
"content" => "Your order #A12 has shipped",
]),
]);
$body = json_decode(curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($status >= 400) {
throw new RuntimeException($body["error_code"] . ": " . $body["message"]);
}
echo $body["data"]["id"], " ", $body["data"]["status"], PHP_EOL;Good practice
- Keep the key on your server, never in browser or app code.
- Pass a unique
request_idper message, so retrying after a timeout can never send twice. - On
429, wait for theRetry-Afterseconds before retrying. - Receive replies and delivery updates with webhooks and verify their signature.