SKILL.md
<!-- Auto-generated from Telnyx OpenAPI specs. Do not edit. -->
Telnyx Messaging Profiles - Go
Installation
go get github.com/team-telnyx/telnyx-go
Setup
import (
"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")),
)
All examples below assume client is already initialized as shown above.
Error Handling
All API calls can fail with network errors, rate limits (429), validation errors (422), or authentication errors (401). Always handle errors in production code:
import "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")
}
}
Common error codes: 401 invalid API key, 403 insufficient permissions, 404 resource not found, 422 validation error (check field formats), 429 rate limited (retry with exponential backoff).
Important Notes
- Pagination: Use
ListAutoPaging()for automatic iteration:iter := client.Resource.ListAutoPaging(ctx, params); for iter.Next() { item := iter.Current() }.
List messaging profiles
GET /messaging_profiles
page, err := client.MessagingProfiles.List(context.Background(), telnyx.MessagingProfileListParams{})
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", page)
Returns: aiassistantid (string | null), alphasender (string | null), createdat (date-time), dailyspendlimit (string), dailyspendlimitenabled (boolean), enabled (boolean), healthwebhookurl (url), id (uuid), mmsfallbacktosms (boolean), mmstranscoding (boolean), mobileonly (boolean), name (string), numberpoolsettings (object | null), organizationid (string), recordtype (enum: messagingprofile), redactionenabled (boolean), redactionlevel (integer), resourcegroupid (string | null), smartencoding (boolean), updatedat (date-time), urlshortenersettings (object | null), v1secret (string), webhookapiversion (enum: 1, 2, 2010-04-01), webhookfailoverurl (url), webhookurl (url), whitelisted_destinations (array[string])
Create a messaging profile
POST /messagingprofiles — Required: name, whitelisteddestinations
Optional: aiassistantid (string | null), alphasender (string | null), dailyspendlimit (string), dailyspendlimitenabled (boolean), enabled (boolean), healthwebhookurl (url), mmsfallbacktosms (boolean), mmstranscoding (boolean), mobileonly (boolean), numberpoolsettings (object | null), resourcegroupid (string | null), smartencoding (boolean), urlshortenersettings (object | null), webhookapiversion (enum: 1, 2, 2010-04-01), webhookfailoverurl (url), webhookurl (url)
messagingProfile, err := client.MessagingProfiles.New(context.Background(), telnyx.MessagingProfileNewParams{
Name: "My name",
WhitelistedDestinations: []string{"US"},
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", messagingProfile.Data)
Returns: aiassistantid (string | null), alphasender (string | null), createdat (date-time), dailyspendlimit (string), dailyspendlimitenabled (boolean), enabled (boolean), healthwebhookurl (url), id (uuid), mmsfallbacktosms (boolean), mmstranscoding (boolean), mobileonly (boolean), name (string), numberpoolsettings (object | null), organizationid (string), recordtype (enum: messagingprofile), redactionenabled (boolean), redactionlevel (integer), resourcegroupid (string | null), smartencoding (boolean), updatedat (date-time), urlshortenersettings (object | null), v1secret (string), webhookapiversion (enum: 1, 2, 2010-04-01), webhookfailoverurl (url), webhookurl (url), whitelisted_destinations (array[string])
Retrieve a messaging profile
GET /messaging_profiles/{id}
messagingProfile, err := client.MessagingProfiles.Get(context.Background(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", messagingProfile.Data)
Returns: aiassistantid (string | null), alphasender (string | null), createdat (date-time), dailyspendlimit (string), dailyspendlimitenabled (boolean), enabled (boolean), healthwebhookurl (url), id (uuid), mmsfallbacktosms (boolean), mmstranscoding (boolean), mobileonly (boolean), name (string), numberpoolsettings (object | null), organizationid (string), recordtype (enum: messagingprofile), redactionenabled (boolean), redactionlevel (integer), resourcegroupid (string | null), smartencoding (boolean), updatedat (date-time), urlshortenersettings (object | null), v1secret (string), webhookapiversion (enum: 1, 2, 2010-04-01), webhookfailoverurl (url), webhookurl (url), whitelisted_destinations (array[string])
Update a messaging profile
PATCH /messaging_profiles/{id}
Optional: aiassistantid (string | null), alphasender (string | null), createdat (date-time), dailyspendlimit (string), dailyspendlimitenabled (boolean), enabled (boolean), id (uuid), mmsfallbacktosms (boolean), mmstranscoding (boolean), mobileonly (boolean), name (string), numberpoolsettings (object | null), recordtype (enum: messagingprofile), smartencoding (boolean), updatedat (date-time), urlshortenersettings (object | null), v1secret (string), webhookapiversion (enum: 1, 2, 2010-04-01), webhookfailoverurl (url), webhookurl (url), whitelisteddestinations (array[string])
messagingProfile, err := client.MessagingProfiles.Update(
context.Background(),
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
telnyx.MessagingProfileUpdateParams{},
)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", messagingProfile.Data)
Returns: aiassistantid (string | null), alphasender (string | null), createdat (date-time), dailyspendlimit (string), dailyspendlimitenabled (boolean), enabled (boolean), healthwebhookurl (url), id (uuid), mmsfallbacktosms (boolean), mmstranscoding (boolean), mobileonly (boolean), name (string), numberpoolsettings (object | null), organizationid (string), recordtype (enum: messagingprofile), redactionenabled (boolean), redactionlevel (integer), resourcegroupid (string | null), smartencoding (boolean), updatedat (date-time), urlshortenersettings (object | null), v1secret (string), webhookapiversion (enum: 1, 2, 2010-04-01), webhookfailoverurl (url), webhookurl (url), whitelisted_destinations (array[string])
Delete a messaging profile
DELETE /messaging_profiles/{id}
messagingProfile, err := client.MessagingProfiles.Delete(context.Background(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", messagingProfile.Data)
Returns: aiassistantid (string | null), alphasender (string | null), createdat (date-time), dailyspendlimit (string), dailyspendlimitenabled (boolean), enabled (boolean), healthwebhookurl (url), id (uuid), mmsfallbacktosms (boolean), mmstranscoding (boolean), mobileonly (boolean), name (string), numberpoolsettings (object | null), organizationid (string), recordtype (enum: messagingprofile), redactionenabled (boolean), redactionlevel (integer), resourcegroupid (string | null), smartencoding (boolean), updatedat (date-time), urlshortenersettings (object | null), v1secret (string), webhookapiversion (enum: 1, 2, 2010-04-01), webhookfailoverurl (url), webhookurl (url), whitelisted_destinations (array[string])
List phone numbers associated with a messaging profile
GET /messagingprofiles/{id}/phonenumbers
page, err := client.MessagingProfiles.ListPhoneNumbers(
context.Background(),
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
telnyx.MessagingProfileListPhoneNumbersParams{},
)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", page)
Returns: countrycode (string), createdat (date-time), eligiblemessagingproducts (array[string]), features (object), health (object), id (string), messagingproduct (string), messagingprofileid (string | null), organizationid (string), phonenumber (string), recordtype (enum: messagingphonenumber, messagingsettings), tags (array[string]), traffictype (string), type (enum: long-code, toll-free, short-code, longcode, tollfree, shortcode), updated_at (date-time)
List short codes associated with a messaging profile
GET /messagingprofiles/{id}/shortcodes
page, err := client.MessagingProfiles.ListShortCodes(
context.Background(),
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
telnyx.MessagingProfileListShortCodesParams{},
)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", page)
Returns: countrycode (string), createdat (date-time), id (uuid), messagingprofileid (string | null), recordtype (enum: shortcode), shortcode (string), tags (array), updatedat (date-time)
List short codes
GET /short_codes
page, err := client.ShortCodes.List(context.Background(), telnyx.ShortCodeListParams{})
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", page)
Returns: countrycode (string), createdat (date-time), id (uuid), messagingprofileid (string | null), recordtype (enum: shortcode), shortcode (string), tags (array), updatedat (date-time)
Retrieve a short code
GET /short_codes/{id}
shortCode, err := client.ShortCodes.Get(context.Background(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", shortCode.Data)
Returns: countrycode (string), createdat (date-time), id (uuid), messagingprofileid (string | null), recordtype (enum: shortcode), shortcode (string), tags (array), updatedat (date-time)
Update short code
Update the settings for a specific short code. To unbind a short code from a profile, set the messagingprofileid to null or an empty string. To add or update tags, include the tags field as an array of strings.
PATCH /shortcodes/{id} — Required: messagingprofile_id
Optional: tags (array)
shortCode, err := client.ShortCodes.Update(
context.Background(),
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
telnyx.ShortCodeUpdateParams{
MessagingProfileID: "abc85f64-5717-4562-b3fc-2c9600000000",
},
)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", shortCode.Data)
Returns: countrycode (string), createdat (date-time), id (uuid), messagingprofileid (string | null), recordtype (enum: shortcode), shortcode (string), tags (array), updatedat (date-time)