telnyx-account-access-go

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
<!-- Auto-generated from Telnyx OpenAPI specs. Do not edit. -->
<!-- Auto-generated from Telnyx OpenAPI specs. Do not edit. -->

Telnyx Account Access - Go

Telnyx 账户访问 - Go

Installation

安装

bash
go get github.com/team-telnyx/telnyx-go
bash
go get github.com/team-telnyx/telnyx-go

Setup

初始化配置

go
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.
go
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")),
)
以下所有示例均假定
client
已经按照上述方式完成初始化。

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:
go
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).
所有API调用都可能因网络错误、速率限制(429)、校验错误(422)或身份认证错误(401)而失败。生产环境代码中请始终做好错误处理:
go
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")
  }
}
常见错误码:
401
无效API密钥,
403
权限不足,
404
资源不存在,
422
校验错误(请检查字段格式),
429
触发速率限制(请使用指数退避策略重试)。

Important Notes

重要说明

  • Pagination: Use
    ListAutoPaging()
    for automatic iteration:
    iter := client.Resource.ListAutoPaging(ctx, params); for iter.Next() { item := iter.Current() }
    .
  • 分页: 使用
    ListAutoPaging()
    实现自动遍历:
    iter := client.Resource.ListAutoPaging(ctx, params); for iter.Next() { item := iter.Current() }

List all Access IP Addresses

列出所有访问IP地址

GET /access_ip_address
go
	page, err := client.AccessIPAddress.List(context.Background(), telnyx.AccessIPAddressListParams{})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", page)
Returns:
created_at
(date-time),
description
(string),
id
(string),
ip_address
(string),
source
(string),
status
(enum: pending, added),
updated_at
(date-time),
user_id
(string)
GET /access_ip_address
go
	page, err := client.AccessIPAddress.List(context.Background(), telnyx.AccessIPAddressListParams{})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", page)
返回参数:
created_at
(date-time),
description
(string),
id
(string),
ip_address
(string),
source
(string),
status
(enum: pending, added),
updated_at
(date-time),
user_id
(string)

Create new Access IP Address

创建新的访问IP地址

POST /access_ip_address
— Required:
ip_address
Optional:
description
(string)
go
	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)
Returns:
created_at
(date-time),
description
(string),
id
(string),
ip_address
(string),
source
(string),
status
(enum: pending, added),
updated_at
(date-time),
user_id
(string)
POST /access_ip_address
— 必填参数:
ip_address
可选参数:
description
(string)
go
	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_at
(date-time),
description
(string),
id
(string),
ip_address
(string),
source
(string),
status
(enum: pending, added),
updated_at
(date-time),
user_id
(string)

Retrieve an access IP address

查询单个访问IP地址

GET /access_ip_address/{access_ip_address_id}
go
	accessIPAddressResponse, err := client.AccessIPAddress.Get(context.Background(), "access_ip_address_id")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", accessIPAddressResponse.ID)
Returns:
created_at
(date-time),
description
(string),
id
(string),
ip_address
(string),
source
(string),
status
(enum: pending, added),
updated_at
(date-time),
user_id
(string)
GET /access_ip_address/{access_ip_address_id}
go
	accessIPAddressResponse, err := client.AccessIPAddress.Get(context.Background(), "access_ip_address_id")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", accessIPAddressResponse.ID)
返回参数:
created_at
(date-time),
description
(string),
id
(string),
ip_address
(string),
source
(string),
status
(enum: pending, added),
updated_at
(date-time),
user_id
(string)

Delete access IP address

删除访问IP地址

DELETE /access_ip_address/{access_ip_address_id}
go
	accessIPAddressResponse, err := client.AccessIPAddress.Delete(context.Background(), "access_ip_address_id")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", accessIPAddressResponse.ID)
Returns:
created_at
(date-time),
description
(string),
id
(string),
ip_address
(string),
source
(string),
status
(enum: pending, added),
updated_at
(date-time),
user_id
(string)
DELETE /access_ip_address/{access_ip_address_id}
go
	accessIPAddressResponse, err := client.AccessIPAddress.Delete(context.Background(), "access_ip_address_id")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", accessIPAddressResponse.ID)
返回参数:
created_at
(date-time),
description
(string),
id
(string),
ip_address
(string),
source
(string),
status
(enum: pending, added),
updated_at
(date-time),
user_id
(string)

List all addresses

列出所有地址

Returns a list of your addresses.
GET /addresses
go
	page, err := client.Addresses.List(context.Background(), telnyx.AddressListParams{})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", page)
Returns:
address_book
(boolean),
administrative_area
(string),
borough
(string),
business_name
(string),
country_code
(string),
created_at
(string),
customer_reference
(string),
extended_address
(string),
first_name
(string),
id
(string),
last_name
(string),
locality
(string),
neighborhood
(string),
phone_number
(string),
postal_code
(string),
record_type
(string),
street_address
(string),
updated_at
(string),
validate_address
(boolean)
返回你的所有地址列表。
GET /addresses
go
	page, err := client.Addresses.List(context.Background(), telnyx.AddressListParams{})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", page)
返回参数:
address_book
(boolean),
administrative_area
(string),
borough
(string),
business_name
(string),
country_code
(string),
created_at
(string),
customer_reference
(string),
extended_address
(string),
first_name
(string),
id
(string),
last_name
(string),
locality
(string),
neighborhood
(string),
phone_number
(string),
postal_code
(string),
record_type
(string),
street_address
(string),
updated_at
(string),
validate_address
(boolean)

Creates an address

创建地址

Creates an address.
POST /addresses
— Required:
first_name
,
last_name
,
business_name
,
street_address
,
locality
,
country_code
Optional:
address_book
(boolean),
administrative_area
(string),
borough
(string),
customer_reference
(string),
extended_address
(string),
neighborhood
(string),
phone_number
(string),
postal_code
(string),
validate_address
(boolean)
go
	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)
Returns:
address_book
(boolean),
administrative_area
(string),
borough
(string),
business_name
(string),
country_code
(string),
created_at
(string),
customer_reference
(string),
extended_address
(string),
first_name
(string),
id
(string),
last_name
(string),
locality
(string),
neighborhood
(string),
phone_number
(string),
postal_code
(string),
record_type
(string),
street_address
(string),
updated_at
(string),
validate_address
(boolean)
创建一个新地址。
POST /addresses
— 必填参数:
first_name
,
last_name
,
business_name
,
street_address
,
locality
,
country_code
可选参数:
address_book
(boolean),
administrative_area
(string),
borough
(string),
customer_reference
(string),
extended_address
(string),
neighborhood
(string),
phone_number
(string),
postal_code
(string),
validate_address
(boolean)
go
	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_book
(boolean),
administrative_area
(string),
borough
(string),
business_name
(string),
country_code
(string),
created_at
(string),
customer_reference
(string),
extended_address
(string),
first_name
(string),
id
(string),
last_name
(string),
locality
(string),
neighborhood
(string),
phone_number
(string),
postal_code
(string),
record_type
(string),
street_address
(string),
updated_at
(string),
validate_address
(boolean)

Validate an address

校验地址

Validates an address for emergency services.
POST /addresses/actions/validate
— Required:
country_code
,
street_address
,
postal_code
Optional:
administrative_area
(string),
extended_address
(string),
locality
(string)
go
	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)
Returns:
errors
(array[object]),
record_type
(string),
result
(enum: valid, invalid),
suggested
(object)
校验地址是否可用于紧急服务。
POST /addresses/actions/validate
— 必填参数:
country_code
,
street_address
,
postal_code
可选参数:
administrative_area
(string),
extended_address
(string),
locality
(string)
go
	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)
返回参数:
errors
(array[object]),
record_type
(string),
result
(enum: valid, invalid),
suggested
(object)

Retrieve an address

查询单个地址

Retrieves the details of an existing address.
GET /addresses/{id}
go
	address, err := client.Addresses.Get(context.Background(), "id")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", address.Data)
Returns:
address_book
(boolean),
administrative_area
(string),
borough
(string),
business_name
(string),
country_code
(string),
created_at
(string),
customer_reference
(string),
extended_address
(string),
first_name
(string),
id
(string),
last_name
(string),
locality
(string),
neighborhood
(string),
phone_number
(string),
postal_code
(string),
record_type
(string),
street_address
(string),
updated_at
(string),
validate_address
(boolean)
查询现有地址的详细信息。
GET /addresses/{id}
go
	address, err := client.Addresses.Get(context.Background(), "id")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", address.Data)
返回参数:
address_book
(boolean),
administrative_area
(string),
borough
(string),
business_name
(string),
country_code
(string),
created_at
(string),
customer_reference
(string),
extended_address
(string),
first_name
(string),
id
(string),
last_name
(string),
locality
(string),
neighborhood
(string),
phone_number
(string),
postal_code
(string),
record_type
(string),
street_address
(string),
updated_at
(string),
validate_address
(boolean)

Deletes an address

删除地址

Deletes an existing address.
DELETE /addresses/{id}
go
	address, err := client.Addresses.Delete(context.Background(), "id")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", address.Data)
Returns:
address_book
(boolean),
administrative_area
(string),
borough
(string),
business_name
(string),
country_code
(string),
created_at
(string),
customer_reference
(string),
extended_address
(string),
first_name
(string),
id
(string),
last_name
(string),
locality
(string),
neighborhood
(string),
phone_number
(string),
postal_code
(string),
record_type
(string),
street_address
(string),
updated_at
(string),
validate_address
(boolean)
删除现有地址。
DELETE /addresses/{id}
go
	address, err := client.Addresses.Delete(context.Background(), "id")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", address.Data)
返回参数:
address_book
(boolean),
administrative_area
(string),
borough
(string),
business_name
(string),
country_code
(string),
created_at
(string),
customer_reference
(string),
extended_address
(string),
first_name
(string),
id
(string),
last_name
(string),
locality
(string),
neighborhood
(string),
phone_number
(string),
postal_code
(string),
record_type
(string),
street_address
(string),
updated_at
(string),
validate_address
(boolean)

Accepts this address suggestion as a new emergency address for Operator Connect and finishes the uploads of the numbers associated with it to Microsoft.

接受该地址建议作为Operator Connect的新紧急地址,并完成关联号码到微软平台的上传。

POST /addresses/{id}/actions/accept_suggestions
Optional:
id
(string)
go
	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)
Returns:
accepted
(boolean),
id
(uuid),
record_type
(enum: address_suggestion)
POST /addresses/{id}/actions/accept_suggestions
可选参数:
id
(string)
go
	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)
返回参数:
accepted
(boolean),
id
(uuid),
record_type
(enum: address_suggestion)

List all SSO authentication providers

列出所有SSO身份认证提供商

Returns a list of your SSO authentication providers.
GET /authentication_providers
go
	page, err := client.AuthenticationProviders.List(context.Background(), telnyx.AuthenticationProviderListParams{})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", page)
Returns:
activated_at
(date-time),
active
(boolean),
created_at
(date-time),
id
(uuid),
name
(string),
organization_id
(uuid),
record_type
(string),
settings
(object),
short_name
(string),
updated_at
(date-time)
返回你的所有SSO身份认证提供商列表。
GET /authentication_providers
go
	page, err := client.AuthenticationProviders.List(context.Background(), telnyx.AuthenticationProviderListParams{})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", page)
返回参数:
activated_at
(date-time),
active
(boolean),
created_at
(date-time),
id
(uuid),
name
(string),
organization_id
(uuid),
record_type
(string),
settings
(object),
short_name
(string),
updated_at
(date-time)

Creates an authentication provider

创建身份认证提供商

Creates an authentication provider.
POST /authentication_providers
— Required:
name
,
short_name
,
settings
Optional:
active
(boolean),
settings_url
(uri)
go
	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)
Returns:
activated_at
(date-time),
active
(boolean),
created_at
(date-time),
id
(uuid),
name
(string),
organization_id
(uuid),
record_type
(string),
settings
(object),
short_name
(string),
updated_at
(date-time)
创建一个新的身份认证提供商。
POST /authentication_providers
— 必填参数:
name
,
short_name
,
settings
可选参数:
active
(boolean),
settings_url
(uri)
go
	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_at
(date-time),
active
(boolean),
created_at
(date-time),
id
(uuid),
name
(string),
organization_id
(uuid),
record_type
(string),
settings
(object),
short_name
(string),
updated_at
(date-time)

Retrieve an authentication provider

查询单个身份认证提供商

Retrieves the details of an existing authentication provider.
GET /authentication_providers/{id}
go
	authenticationProvider, err := client.AuthenticationProviders.Get(context.Background(), "id")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", authenticationProvider.Data)
Returns:
activated_at
(date-time),
active
(boolean),
created_at
(date-time),
id
(uuid),
name
(string),
organization_id
(uuid),
record_type
(string),
settings
(object),
short_name
(string),
updated_at
(date-time)
查询现有身份认证提供商的详细信息。
GET /authentication_providers/{id}
go
	authenticationProvider, err := client.AuthenticationProviders.Get(context.Background(), "id")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", authenticationProvider.Data)
返回参数:
activated_at
(date-time),
active
(boolean),
created_at
(date-time),
id
(uuid),
name
(string),
organization_id
(uuid),
record_type
(string),
settings
(object),
short_name
(string),
updated_at
(date-time)

Update an authentication provider

更新身份认证提供商

Updates settings of an existing authentication provider.
PATCH /authentication_providers/{id}
Optional:
active
(boolean),
name
(string),
settings
(object),
settings_url
(uri),
short_name
(string)
go
	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)
Returns:
activated_at
(date-time),
active
(boolean),
created_at
(date-time),
id
(uuid),
name
(string),
organization_id
(uuid),
record_type
(string),
settings
(object),
short_name
(string),
updated_at
(date-time)
更新现有身份认证提供商的配置。
PATCH /authentication_providers/{id}
可选参数:
active
(boolean),
name
(string),
settings
(object),
settings_url
(uri),
short_name
(string)
go
	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_at
(date-time),
active
(boolean),
created_at
(date-time),
id
(uuid),
name
(string),
organization_id
(uuid),
record_type
(string),
settings
(object),
short_name
(string),
updated_at
(date-time)

Deletes an authentication provider

删除身份认证提供商

Deletes an existing authentication provider.
DELETE /authentication_providers/{id}
go
	authenticationProvider, err := client.AuthenticationProviders.Delete(context.Background(), "id")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", authenticationProvider.Data)
Returns:
activated_at
(date-time),
active
(boolean),
created_at
(date-time),
id
(uuid),
name
(string),
organization_id
(uuid),
record_type
(string),
settings
(object),
short_name
(string),
updated_at
(date-time)
删除现有身份认证提供商。
DELETE /authentication_providers/{id}
go
	authenticationProvider, err := client.AuthenticationProviders.Delete(context.Background(), "id")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", authenticationProvider.Data)
返回参数:
activated_at
(date-time),
active
(boolean),
created_at
(date-time),
id
(uuid),
name
(string),
organization_id
(uuid),
record_type
(string),
settings
(object),
short_name
(string),
updated_at
(date-time)

List all billing groups

列出所有账单组

GET /billing_groups
go
	page, err := client.BillingGroups.List(context.Background(), telnyx.BillingGroupListParams{})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", page)
Returns:
created_at
(date-time),
deleted_at
(date-time),
id
(uuid),
name
(string),
organization_id
(uuid),
record_type
(enum: billing_group),
updated_at
(date-time)
GET /billing_groups
go
	page, err := client.BillingGroups.List(context.Background(), telnyx.BillingGroupListParams{})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", page)
返回参数:
created_at
(date-time),
deleted_at
(date-time),
id
(uuid),
name
(string),
organization_id
(uuid),
record_type
(enum: billing_group),
updated_at
(date-time)

Create a billing group

创建账单组

POST /billing_groups
Optional:
name
(string)
go
	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)
Returns:
created_at
(date-time),
deleted_at
(date-time),
id
(uuid),
name
(string),
organization_id
(uuid),
record_type
(enum: billing_group),
updated_at
(date-time)
POST /billing_groups
可选参数:
name
(string)
go
	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_at
(date-time),
deleted_at
(date-time),
id
(uuid),
name
(string),
organization_id
(uuid),
record_type
(enum: billing_group),
updated_at
(date-time)

Get a billing group

查询单个账单组

GET /billing_groups/{id}
go
	billingGroup, err := client.BillingGroups.Get(context.Background(), "f5586561-8ff0-4291-a0ac-84fe544797bd")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", billingGroup.Data)
Returns:
created_at
(date-time),
deleted_at
(date-time),
id
(uuid),
name
(string),
organization_id
(uuid),
record_type
(enum: billing_group),
updated_at
(date-time)
GET /billing_groups/{id}
go
	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_at
(date-time),
deleted_at
(date-time),
id
(uuid),
name
(string),
organization_id
(uuid),
record_type
(enum: billing_group),
updated_at
(date-time)

Update a billing group

更新账单组

PATCH /billing_groups/{id}
Optional:
name
(string)
go
	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)
Returns:
created_at
(date-time),
deleted_at
(date-time),
id
(uuid),
name
(string),
organization_id
(uuid),
record_type
(enum: billing_group),
updated_at
(date-time)
PATCH /billing_groups/{id}
可选参数:
name
(string)
go
	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_at
(date-time),
deleted_at
(date-time),
id
(uuid),
name
(string),
organization_id
(uuid),
record_type
(enum: billing_group),
updated_at
(date-time)

Delete a billing group

删除账单组

DELETE /billing_groups/{id}
go
	billingGroup, err := client.BillingGroups.Delete(context.Background(), "f5586561-8ff0-4291-a0ac-84fe544797bd")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", billingGroup.Data)
Returns:
created_at
(date-time),
deleted_at
(date-time),
id
(uuid),
name
(string),
organization_id
(uuid),
record_type
(enum: billing_group),
updated_at
(date-time)
DELETE /billing_groups/{id}
go
	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_at
(date-time),
deleted_at
(date-time),
id
(uuid),
name
(string),
organization_id
(uuid),
record_type
(enum: billing_group),
updated_at
(date-time)

List integration secrets

列出集成密钥

Retrieve a list of all integration secrets configured by the user.
GET /integration_secrets
go
	page, err := client.IntegrationSecrets.List(context.Background(), telnyx.IntegrationSecretListParams{})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", page)
Returns:
created_at
(date-time),
id
(string),
identifier
(string),
record_type
(string),
updated_at
(date-time)
查询用户配置的所有集成密钥列表。
GET /integration_secrets
go
	page, err := client.IntegrationSecrets.List(context.Background(), telnyx.IntegrationSecretListParams{})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", page)
返回参数:
created_at
(date-time),
id
(string),
identifier
(string),
record_type
(string),
updated_at
(date-time)

Create a secret

创建密钥

Create a new secret with an associated identifier that can be used to securely integrate with other services.
POST /integration_secrets
— Required:
identifier
,
type
Optional:
password
(string),
token
(string),
username
(string)
go
	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)
Returns:
created_at
(date-time),
id
(string),
identifier
(string),
record_type
(string),
updated_at
(date-time)
创建关联了唯一标识符的新密钥,可用于与其他服务的安全集成。
POST /integration_secrets
— 必填参数:
identifier
,
type
可选参数:
password
(string),
token
(string),
username
(string)
go
	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_at
(date-time),
id
(string),
identifier
(string),
record_type
(string),
updated_at
(date-time)

Delete an integration secret

删除集成密钥

Delete an integration secret given its ID.
DELETE /integration_secrets/{id}
go
	err := client.IntegrationSecrets.Delete(context.Background(), "id")
	if err != nil {
		log.Fatal(err)
	}
根据ID删除指定的集成密钥。
DELETE /integration_secrets/{id}
go
	err := client.IntegrationSecrets.Delete(context.Background(), "id")
	if err != nil {
		log.Fatal(err)
	}

Create an Access Token.

创建访问令牌

Create an Access Token (JWT) for the credential.
POST /telephony_credentials/{id}/token
go
	response, err := client.TelephonyCredentials.NewToken(context.Background(), "id")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", response)
为凭证创建访问令牌(JWT)。
POST /telephony_credentials/{id}/token
go
	response, err := client.TelephonyCredentials.NewToken(context.Background(), "id")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", response)