telnyx-account-management-go
npx skills add https://github.com/team-telnyx/telnyx-ext-agent-skills --skill telnyx-account-management-go
Agent 安装分布
Skill 文档
Telnyx Account Management – 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.
Lists accounts managed by the current user.
Lists the accounts managed by the current user.
GET /managed_accounts
page, err := client.ManagedAccounts.List(context.TODO(), telnyx.ManagedAccountListParams{})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", page)
Create a new managed account.
Create a new managed account owned by the authenticated user.
POST /managed_accounts â Required: business_name
Optional: email (string), managed_account_allow_custom_pricing (boolean), password (string), rollup_billing (boolean)
managedAccount, err := client.ManagedAccounts.New(context.TODO(), telnyx.ManagedAccountNewParams{
BusinessName: "Larry's Cat Food Inc",
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", managedAccount.Data)
Retrieve a managed account
Retrieves the details of a single managed account.
GET /managed_accounts/{id}
managedAccount, err := client.ManagedAccounts.Get(context.TODO(), "id")
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", managedAccount.Data)
Update a managed account
Update a single managed account.
PATCH /managed_accounts/{id}
Optional: managed_account_allow_custom_pricing (boolean)
managedAccount, err := client.ManagedAccounts.Update(
context.TODO(),
"id",
telnyx.ManagedAccountUpdateParams{},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", managedAccount.Data)
Disables a managed account
Disables a managed account, forbidding it to use Telnyx services, including sending or receiving phone calls and SMS messages.
POST /managed_accounts/{id}/actions/disable
response, err := client.ManagedAccounts.Actions.Disable(context.TODO(), "id")
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Data)
Enables a managed account
Enables a managed account and its sub-users to use Telnyx services.
POST /managed_accounts/{id}/actions/enable
Optional: reenable_all_connections (boolean)
response, err := client.ManagedAccounts.Actions.Enable(
context.TODO(),
"id",
telnyx.ManagedAccountActionEnableParams{},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Data)
Update the amount of allocatable global outbound channels allocated to a specific managed account.
PATCH /managed_accounts/{id}/update_global_channel_limit
Optional: channel_limit (integer)
response, err := client.ManagedAccounts.UpdateGlobalChannelLimit(
context.TODO(),
"id",
telnyx.ManagedAccountUpdateGlobalChannelLimitParams{},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Data)
Display information about allocatable global outbound channels for the current user.
GET /managed_accounts/allocatable_global_outbound_channels
response, err := client.ManagedAccounts.GetAllocatableGlobalOutboundChannels(context.TODO())
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Data)