Getting Started
From zero to your first message sent in under a minute.
1. Install the SDK
go get github.com/SendAfrica/GO-SDK2. Set your API key
export SENDAFRICA_API_KEY="SA-..."If the API key argument to NewClient is empty, the SDK reads SENDAFRICA_API_KEY from the environment.
3. Send a message
package main
import (
"context"
"fmt"
"os"
sendafrica "github.com/SendAfrica/GO-SDK"
)
func main() {
client := sendafrica.NewClient(os.Getenv("SENDAFRICA_API_KEY"))
result, err := client.SMS.Send(context.Background(), sendafrica.SendSMSRequest{
To: "0712345678",
Message: "Your verification code is 4921.",
})
if err != nil {
fmt.Println("send failed:", err)
return
}
fmt.Printf("message_id=%s status=%s credits=%d\n",
result.MessageID, result.Status, result.CreditsUsed)
}4. What you get
result is a typed SMSResult with MessageID, Status, Cost, CreditsUsed, and To. Status: "Success" means the provider accepted the message — it is not handset delivery confirmation. React to delivery with webhooks.
See Client & Authentication for options, and Sending SMS for the full method surface.
Last updated on