Official AgentPhone Go SDK. Maintained by the AgentPhone team for building integrations with the AgentPhone platform.
Give your AI agents real phone numbers, SMS, and voice calls — from Go.
AgentPhone provides a REST API for provisioning phone numbers, managing AI agents, sending SMS, and placing voice calls. This SDK wraps that API in idiomatic Go.
go get github.com/AgentPhone-AI/agentphone-goRequires Go 1.21 or later.
package main
import (
"context"
"fmt"
"log"
"os"
agentphone "github.com/AgentPhone-AI/agentphone-go"
)
func main() {
client := agentphone.NewClient(os.Getenv("AGENTPHONE_API_KEY"))
msg, err := client.Messages.Send(context.Background(), &agentphone.SendMessageParams{
AgentID: "agent_123",
ToNumber: "+14155551234",
Body: "Hello from Go!",
})
if err != nil {
log.Fatal(err)
}
fmt.Println("Message sent:", msg.ID)
}The SDK reads your API key from the AGENTPHONE_API_KEY environment variable by default, or you can pass it explicitly:
client := agentphone.NewClient("your-api-key")Get your API key from agentphone.to under Settings → API Keys.
| Resource | Description |
|---|---|
Agents |
Create and manage AI phone agents, voices, and agent webhooks |
Numbers |
Buy, list, and manage phone numbers |
Calls |
Place outbound calls, fetch recordings and transcripts |
Messages |
Send SMS/iMessage and reactions |
Conversations |
Manage threaded SMS conversations |
Contacts |
Create and manage contacts |
Contact Cards |
Manage per-number contact card info |
Webhooks |
Configure inbound event webhooks and view delivery logs |
Verification |
Send and check verification codes |
Usage |
Query usage stats by account, number, or agent |
Sub-Accounts |
Manage sub-accounts |
SIP Trunks |
Configure SIP trunk connections |
WhatsApp |
Connect and manage WhatsApp numbers and templates |
Registration |
Manage A2P 10DLC registration |
Location |
Look up and refresh number location data |
Full endpoint-level reference: docs.agentphone.ai/api-reference
API errors are returned as *agentphone.APIError, which includes the HTTP status code and the error message returned by the API:
msg, err := client.Messages.Send(ctx, params)
if err != nil {
var apiErr *agentphone.APIError
if errors.As(err, &apiErr) {
fmt.Println("status:", apiErr.StatusCode, "message:", apiErr.Message)
}
}Contributions are welcome! If you'd like to add a feature, fix a bug, or improve coverage of an endpoint, feel free to open an issue or pull request.
MIT — see LICENSE for details.