Loading...
Loading...
Configure account addresses, authentication providers, IP access controls, billing groups, and integration secrets. This skill provides Go SDK examples.
npx skill4agent add team-telnyx/skills telnyx-account-access-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 /access_ip_address page, err := client.AccessIPAddress.List(context.Background(), telnyx.AccessIPAddressListParams{})
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", page)created_atdescriptionidip_addresssourcestatusupdated_atuser_idPOST /access_ip_addressip_addressdescription accessIPAddressResponse, err := client.AccessIPAddress.New(context.Background(), telnyx.AccessIPAddressNewParams{
IPAddress: "203.0.113.10",
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", accessIPAddressResponse.ID)created_atdescriptionidip_addresssourcestatusupdated_atuser_idGET /access_ip_address/{access_ip_address_id} accessIPAddressResponse, err := client.AccessIPAddress.Get(context.Background(), "access_ip_address_id")
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", accessIPAddressResponse.ID)created_atdescriptionidip_addresssourcestatusupdated_atuser_idDELETE /access_ip_address/{access_ip_address_id} accessIPAddressResponse, err := client.AccessIPAddress.Delete(context.Background(), "access_ip_address_id")
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", accessIPAddressResponse.ID)created_atdescriptionidip_addresssourcestatusupdated_atuser_idGET /addresses page, err := client.Addresses.List(context.Background(), telnyx.AddressListParams{})
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", page)address_bookadministrative_areaboroughbusiness_namecountry_codecreated_atcustomer_referenceextended_addressfirst_nameidlast_namelocalityneighborhoodphone_numberpostal_coderecord_typestreet_addressupdated_atvalidate_addressPOST /addressesfirst_namelast_namebusiness_namestreet_addresslocalitycountry_codeaddress_bookadministrative_areaboroughcustomer_referenceextended_addressneighborhoodphone_numberpostal_codevalidate_address address, err := client.Addresses.New(context.Background(), telnyx.AddressNewParams{
BusinessName: "Toy-O'Kon",
CountryCode: "US",
FirstName: "Alfred",
LastName: "Foster",
Locality: "Austin",
StreetAddress: "600 Congress Avenue",
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", address.Data)address_bookadministrative_areaboroughbusiness_namecountry_codecreated_atcustomer_referenceextended_addressfirst_nameidlast_namelocalityneighborhoodphone_numberpostal_coderecord_typestreet_addressupdated_atvalidate_addressPOST /addresses/actions/validatecountry_codestreet_addresspostal_codeadministrative_areaextended_addresslocality response, err := client.Addresses.Actions.Validate(context.Background(), telnyx.AddressActionValidateParams{
CountryCode: "US",
PostalCode: "78701",
StreetAddress: "600 Congress Avenue",
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", response.Data)errorsrecord_typeresultsuggestedGET /addresses/{id} address, err := client.Addresses.Get(context.Background(), "id")
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", address.Data)address_bookadministrative_areaboroughbusiness_namecountry_codecreated_atcustomer_referenceextended_addressfirst_nameidlast_namelocalityneighborhoodphone_numberpostal_coderecord_typestreet_addressupdated_atvalidate_addressDELETE /addresses/{id} address, err := client.Addresses.Delete(context.Background(), "id")
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", address.Data)address_bookadministrative_areaboroughbusiness_namecountry_codecreated_atcustomer_referenceextended_addressfirst_nameidlast_namelocalityneighborhoodphone_numberpostal_coderecord_typestreet_addressupdated_atvalidate_addressPOST /addresses/{id}/actions/accept_suggestionsid response, err := client.Addresses.Actions.AcceptSuggestions(
context.Background(),
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
telnyx.AddressActionAcceptSuggestionsParams{},
)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", response.Data)acceptedidrecord_typeGET /authentication_providers page, err := client.AuthenticationProviders.List(context.Background(), telnyx.AuthenticationProviderListParams{})
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", page)activated_atactivecreated_atidnameorganization_idrecord_typesettingsshort_nameupdated_atPOST /authentication_providersnameshort_namesettingsactivesettings_url authenticationProvider, err := client.AuthenticationProviders.New(context.Background(), telnyx.AuthenticationProviderNewParams{
Name: "Okta",
Settings: telnyx.SettingsParam{
IdpCertFingerprint: "13:38:C7:BB:C9:FF:4A:70:38:3A:E3:D9:5C:CD:DB:2E:50:1E:80:A7",
IdpEntityID: "https://myorg.myidp.com/saml/metadata",
IdpSSOTargetURL: "https://myorg.myidp.com/trust/saml2/http-post/sso",
},
ShortName: "myorg",
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", authenticationProvider.Data)activated_atactivecreated_atidnameorganization_idrecord_typesettingsshort_nameupdated_atGET /authentication_providers/{id} authenticationProvider, err := client.AuthenticationProviders.Get(context.Background(), "id")
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", authenticationProvider.Data)activated_atactivecreated_atidnameorganization_idrecord_typesettingsshort_nameupdated_atPATCH /authentication_providers/{id}activenamesettingssettings_urlshort_name authenticationProvider, err := client.AuthenticationProviders.Update(
context.Background(),
"id",
telnyx.AuthenticationProviderUpdateParams{
Active: telnyx.Bool(true),
Name: telnyx.String("Okta"),
Settings: telnyx.SettingsParam{
IdpEntityID: "https://myorg.myidp.com/saml/metadata",
IdpSSOTargetURL: "https://myorg.myidp.com/trust/saml2/http-post/sso",
IdpCertFingerprint: "13:38:C7:BB:C9:FF:4A:70:38:3A:E3:D9:5C:CD:DB:2E:50:1E:80:A7",
IdpCertFingerprintAlgorithm: telnyx.SettingsIdpCertFingerprintAlgorithmSha1,
},
ShortName: telnyx.String("myorg"),
},
)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", authenticationProvider.Data)activated_atactivecreated_atidnameorganization_idrecord_typesettingsshort_nameupdated_atDELETE /authentication_providers/{id} authenticationProvider, err := client.AuthenticationProviders.Delete(context.Background(), "id")
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", authenticationProvider.Data)activated_atactivecreated_atidnameorganization_idrecord_typesettingsshort_nameupdated_atGET /billing_groups page, err := client.BillingGroups.List(context.Background(), telnyx.BillingGroupListParams{})
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", page)created_atdeleted_atidnameorganization_idrecord_typeupdated_atPOST /billing_groupsname billingGroup, err := client.BillingGroups.New(context.Background(), telnyx.BillingGroupNewParams{
Name: telnyx.String("string"),
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", billingGroup.Data)created_atdeleted_atidnameorganization_idrecord_typeupdated_atGET /billing_groups/{id} billingGroup, err := client.BillingGroups.Get(context.Background(), "f5586561-8ff0-4291-a0ac-84fe544797bd")
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", billingGroup.Data)created_atdeleted_atidnameorganization_idrecord_typeupdated_atPATCH /billing_groups/{id}name billingGroup, err := client.BillingGroups.Update(
context.Background(),
"f5586561-8ff0-4291-a0ac-84fe544797bd",
telnyx.BillingGroupUpdateParams{
Name: telnyx.String("string"),
},
)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", billingGroup.Data)created_atdeleted_atidnameorganization_idrecord_typeupdated_atDELETE /billing_groups/{id} billingGroup, err := client.BillingGroups.Delete(context.Background(), "f5586561-8ff0-4291-a0ac-84fe544797bd")
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", billingGroup.Data)created_atdeleted_atidnameorganization_idrecord_typeupdated_atGET /integration_secrets page, err := client.IntegrationSecrets.List(context.Background(), telnyx.IntegrationSecretListParams{})
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", page)created_atididentifierrecord_typeupdated_atPOST /integration_secretsidentifiertypepasswordtokenusername integrationSecret, err := client.IntegrationSecrets.New(context.Background(), telnyx.IntegrationSecretNewParams{
Identifier: "my_secret",
Type: telnyx.IntegrationSecretNewParamsTypeBearer,
Token: telnyx.String("my_secret_value"),
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", integrationSecret.Data)created_atididentifierrecord_typeupdated_atDELETE /integration_secrets/{id} err := client.IntegrationSecrets.Delete(context.Background(), "id")
if err != nil {
log.Fatal(err)
}POST /telephony_credentials/{id}/token response, err := client.TelephonyCredentials.NewToken(context.Background(), "id")
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", response)