Go
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 Go 1.20 or newer, standard library only. 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.
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
"os"
)
func main() {
payload, _ := json.Marshal(map[string]string{
"from_number": "+15550100001",
"to_number": "+15550100002",
"content": "Your order #A12 has shipped",
})
req, _ := http.NewRequest("POST", "https://api.99billingsolutions.com/v1/messages/send", bytes.NewReader(payload))
req.Header.Set("x-api-key", os.Getenv("SMS_BRIDGE_KEY"))
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
var body struct {
Message string `json:"message"`
ErrorCode string `json:"error_code"`
Data struct {
ID string `json:"id"`
Status string `json:"status"`
} `json:"data"`
}
if err := json.NewDecoder(res.Body).Decode(&body); err != nil {
panic(err)
}
if res.StatusCode >= 400 {
panic(body.ErrorCode + ": " + body.Message)
}
fmt.Println(body.Data.ID, body.Data.Status)
}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.