Loading...
Loading...
Look up phone number information (carrier, type, caller name) and verify users via SMS/voice OTP. Use for phone verification and data enrichment. This skill provides Go SDK examples.
npx skill4agent add team-telnyx/skills telnyx-verify-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")
}
}401403404422429+13125550001+ListAutoPaging()iter := client.Resource.ListAutoPaging(ctx, params); for iter.Next() { item := iter.Current() }GET /number_lookup/{phone_number} numberLookup, err := client.NumberLookup.Get(
context.Background(),
"+18665552368",
telnyx.NumberLookupGetParams{},
)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", numberLookup.Data)caller_namecarriercountry_codefraudnational_formatphone_numberportabilityrecord_typeGET /verifications/by_phone_number/{phone_number} byPhoneNumbers, err := client.Verifications.ByPhoneNumber.List(context.Background(), "+13035551234")
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", byPhoneNumbers.Data)created_atcustom_codeidphone_numberrecord_typestatustimeout_secstypeupdated_atverify_profile_idPOST /verifications/by_phone_number/{phone_number}/actions/verifycodeverify_profile_id verifyVerificationCodeResponse, err := client.Verifications.ByPhoneNumber.Actions.Verify(
context.Background(),
"+13035551234",
telnyx.VerificationByPhoneNumberActionVerifyParams{
Code: "17686",
VerifyProfileID: "12ade33a-21c0-473b-b055-b3c836e1c292",
},
)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", verifyVerificationCodeResponse.Data)phone_numberresponse_codePOST /verifications/callphone_numberverify_profile_idcustom_codeextensiontimeout_secs createVerificationResponse, err := client.Verifications.TriggerCall(context.Background(), telnyx.VerificationTriggerCallParams{
PhoneNumber: "+13035551234",
VerifyProfileID: "12ade33a-21c0-473b-b055-b3c836e1c292",
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", createVerificationResponse.Data)created_atcustom_codeidphone_numberrecord_typestatustimeout_secstypeupdated_atverify_profile_idPOST /verifications/flashcallphone_numberverify_profile_idtimeout_secs createVerificationResponse, err := client.Verifications.TriggerFlashcall(context.Background(), telnyx.VerificationTriggerFlashcallParams{
PhoneNumber: "+13035551234",
VerifyProfileID: "12ade33a-21c0-473b-b055-b3c836e1c292",
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", createVerificationResponse.Data)created_atcustom_codeidphone_numberrecord_typestatustimeout_secstypeupdated_atverify_profile_idPOST /verifications/smsphone_numberverify_profile_idcustom_codetimeout_secs createVerificationResponse, err := client.Verifications.TriggerSMS(context.Background(), telnyx.VerificationTriggerSMSParams{
PhoneNumber: "+13035551234",
VerifyProfileID: "12ade33a-21c0-473b-b055-b3c836e1c292",
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", createVerificationResponse.Data)created_atcustom_codeidphone_numberrecord_typestatustimeout_secstypeupdated_atverify_profile_idGET /verifications/{verification_id} verification, err := client.Verifications.Get(context.Background(), "12ade33a-21c0-473b-b055-b3c836e1c292")
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", verification.Data)created_atcustom_codeidphone_numberrecord_typestatustimeout_secstypeupdated_atverify_profile_idPOST /verifications/{verification_id}/actions/verifycodestatus verifyVerificationCodeResponse, err := client.Verifications.Actions.Verify(
context.Background(),
"12ade33a-21c0-473b-b055-b3c836e1c292",
telnyx.VerificationActionVerifyParams{
Code: "12345",
},
)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", verifyVerificationCodeResponse.Data)phone_numberresponse_codeGET /verify_profiles page, err := client.VerifyProfiles.List(context.Background(), telnyx.VerifyProfileListParams{})
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", page)callcreated_atflashcallidlanguagenamercsrecord_typesmsupdated_atwebhook_failover_urlwebhook_urlPOST /verify_profilesnamecallflashcalllanguagercssmswebhook_failover_urlwebhook_url verifyProfileData, err := client.VerifyProfiles.New(context.Background(), telnyx.VerifyProfileNewParams{
Name: "Test Profile",
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", verifyProfileData.Data)callcreated_atflashcallidlanguagenamercsrecord_typesmsupdated_atwebhook_failover_urlwebhook_urlGET /verify_profiles/templates response, err := client.VerifyProfiles.GetTemplates(context.Background())
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", response.Data)idtextPOST /verify_profiles/templatestext messageTemplate, err := client.VerifyProfiles.NewTemplate(context.Background(), telnyx.VerifyProfileNewTemplateParams{
Text: "Your {{app_name}} verification code is: {{code}}.",
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", messageTemplate.Data)idtextPATCH /verify_profiles/templates/{template_id}text messageTemplate, err := client.VerifyProfiles.UpdateTemplate(
context.Background(),
"12ade33a-21c0-473b-b055-b3c836e1c292",
telnyx.VerifyProfileUpdateTemplateParams{
Text: "Your {{app_name}} verification code is: {{code}}.",
},
)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", messageTemplate.Data)idtextGET /verify_profiles/{verify_profile_id} verifyProfileData, err := client.VerifyProfiles.Get(context.Background(), "12ade33a-21c0-473b-b055-b3c836e1c292")
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", verifyProfileData.Data)callcreated_atflashcallidlanguagenamercsrecord_typesmsupdated_atwebhook_failover_urlwebhook_urlPATCH /verify_profiles/{verify_profile_id}callflashcalllanguagenamercssmswebhook_failover_urlwebhook_url verifyProfileData, err := client.VerifyProfiles.Update(
context.Background(),
"12ade33a-21c0-473b-b055-b3c836e1c292",
telnyx.VerifyProfileUpdateParams{},
)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", verifyProfileData.Data)callcreated_atflashcallidlanguagenamercsrecord_typesmsupdated_atwebhook_failover_urlwebhook_urlDELETE /verify_profiles/{verify_profile_id} verifyProfileData, err := client.VerifyProfiles.Delete(context.Background(), "12ade33a-21c0-473b-b055-b3c836e1c292")
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", verifyProfileData.Data)callcreated_atflashcallidlanguagenamercsrecord_typesmsupdated_atwebhook_failover_urlwebhook_url