Loading...
Loading...
Configure notification channels and settings for account alerts and events. This skill provides Go SDK examples.
npx skill4agent add team-telnyx/skills telnyx-account-notifications-gogo get github.com/team-telnyx/telnyx-goimport (
"context"
"fmt"
"os"
"github.com/team-telnyx/telnyx-go"
"github.com/team-telnyx/telnyx-go/option"
)
client := telnyx.NewClient(
option.WithAPIKey(os.Getenv("TELNYX_API_KEY")),
)clientimport "errors"
result, err := client.Messages.Send(ctx, params)
if err != nil {
var apiErr *telnyx.Error
if errors.As(err, &apiErr) {
switch apiErr.StatusCode {
case 422:
fmt.Println("Validation error — check required fields and formats")
case 429:
// Rate limited — wait and retry with exponential backoff
fmt.Println("Rate limited, retrying...")
default:
fmt.Printf("API error %d: %s\n", apiErr.StatusCode, apiErr.Error())
}
} else {
fmt.Println("Network error — check connectivity and retry")
}
}401403404422429ListAutoPaging()iter := client.Resource.ListAutoPaging(ctx, params); for iter.Next() { item := iter.Current() }GET /notification_channels page, err := client.NotificationChannels.List(context.Background(), telnyx.NotificationChannelListParams{})
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", page)channel_destinationchannel_type_idcreated_atidnotification_profile_idupdated_atPOST /notification_channelschannel_destinationchannel_type_idcreated_atidnotification_profile_idupdated_at notificationChannel, err := client.NotificationChannels.New(context.Background(), telnyx.NotificationChannelNewParams{
ChannelTypeID: "550e8400-e29b-41d4-a716-446655440000",
ChannelDestination: "https://example.com/webhooks",
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", notificationChannel.Data)channel_destinationchannel_type_idcreated_atidnotification_profile_idupdated_atGET /notification_channels/{id} notificationChannel, err := client.NotificationChannels.Get(context.Background(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", notificationChannel.Data)channel_destinationchannel_type_idcreated_atidnotification_profile_idupdated_atPATCH /notification_channels/{id}channel_destinationchannel_type_idcreated_atidnotification_profile_idupdated_at notificationChannel, err := client.NotificationChannels.Update(
context.Background(),
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
telnyx.NotificationChannelUpdateParams{
NotificationChannel: telnyx.NotificationChannelParam{},
},
)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", notificationChannel.Data)channel_destinationchannel_type_idcreated_atidnotification_profile_idupdated_atDELETE /notification_channels/{id} notificationChannel, err := client.NotificationChannels.Delete(context.Background(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", notificationChannel.Data)channel_destinationchannel_type_idcreated_atidnotification_profile_idupdated_atGET /notification_event_conditions page, err := client.NotificationEventConditions.List(context.Background(), telnyx.NotificationEventConditionListParams{})
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", page)allow_multiple_channelsassociated_record_typeasynchronouscreated_atdescriptionenabledidnamenotification_event_idparameterssupported_channelsupdated_atGET /notification_events page, err := client.NotificationEvents.List(context.Background(), telnyx.NotificationEventListParams{})
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", page)created_atenabledidnamenotification_categoryupdated_atGET /notification_profiles page, err := client.NotificationProfiles.List(context.Background(), telnyx.NotificationProfileListParams{})
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", page)created_atidnameupdated_atPOST /notification_profilescreated_atidnameupdated_at notificationProfile, err := client.NotificationProfiles.New(context.Background(), telnyx.NotificationProfileNewParams{
Name: "My Notification Profile",
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", notificationProfile.Data)created_atidnameupdated_atGET /notification_profiles/{id} notificationProfile, err := client.NotificationProfiles.Get(context.Background(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", notificationProfile.Data)created_atidnameupdated_atPATCH /notification_profiles/{id}created_atidnameupdated_at notificationProfile, err := client.NotificationProfiles.Update(
context.Background(),
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
telnyx.NotificationProfileUpdateParams{
NotificationProfile: telnyx.NotificationProfileParam{},
},
)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", notificationProfile.Data)created_atidnameupdated_atDELETE /notification_profiles/{id} notificationProfile, err := client.NotificationProfiles.Delete(context.Background(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", notificationProfile.Data)created_atidnameupdated_atGET /notification_settings page, err := client.NotificationSettings.List(context.Background(), telnyx.NotificationSettingListParams{})
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", page)associated_record_typeassociated_record_type_valuecreated_atidnotification_channel_idnotification_event_condition_idnotification_profile_idparametersstatusupdated_atPOST /notification_settingsassociated_record_typeassociated_record_type_valuecreated_atidnotification_channel_idnotification_event_condition_idnotification_profile_idparametersstatusupdated_at notificationSetting, err := client.NotificationSettings.New(context.Background(), telnyx.NotificationSettingNewParams{})
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", notificationSetting.Data)associated_record_typeassociated_record_type_valuecreated_atidnotification_channel_idnotification_event_condition_idnotification_profile_idparametersstatusupdated_atGET /notification_settings/{id} notificationSetting, err := client.NotificationSettings.Get(context.Background(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", notificationSetting.Data)associated_record_typeassociated_record_type_valuecreated_atidnotification_channel_idnotification_event_condition_idnotification_profile_idparametersstatusupdated_atDELETE /notification_settings/{id} notificationSetting, err := client.NotificationSettings.Delete(context.Background(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", notificationSetting.Data)associated_record_typeassociated_record_type_valuecreated_atidnotification_channel_idnotification_event_condition_idnotification_profile_idparametersstatusupdated_at