home / skills / openclaw / skills / telnyx-account-go

This skill helps developers manage telnyx accounts with Go by showcasing balance, invoices, audit logs, detail records, webhooks and related SDK usage.

npx playbooks add skill openclaw/skills --skill telnyx-account-go

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
3.4 KB
---
name: telnyx-account-go
description: >-
  Manage account balance, payments, invoices, webhooks, and view audit logs and
  detail records. This skill provides Go SDK examples.
metadata:
  author: telnyx
  product: account
  language: go
  generated_by: telnyx-ext-skills-generator
---

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

# Telnyx Account - Go

## Installation

```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.

## List Audit Logs

Retrieve a list of audit log entries.

`GET /audit_events`

```go
	page, err := client.AuditEvents.List(context.TODO(), telnyx.AuditEventListParams{})
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", page)
```

## Get user balance details

`GET /balance`

```go
	balance, err := client.Balance.Get(context.TODO())
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", balance.Data)
```

## Search detail records

Search for any detail record across the Telnyx Platform

`GET /detail_records`

```go
	page, err := client.DetailRecords.List(context.TODO(), telnyx.DetailRecordListParams{})
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", page)
```

## List invoices

Retrieve a paginated list of invoices.

`GET /invoices`

```go
	page, err := client.Invoices.List(context.TODO(), telnyx.InvoiceListParams{})
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", page)
```

## Get invoice by ID

Retrieve a single invoice by its unique identifier.

`GET /invoices/{id}`

```go
	invoice, err := client.Invoices.Get(
		context.TODO(),
		"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
		telnyx.InvoiceGetParams{},
	)
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", invoice.Data)
```

## List auto recharge preferences

Returns the payment auto recharge preferences.

`GET /payments/auto_recharge_prefs`

```go
	autoRechargePrefs, err := client.Payment.AutoRechargePrefs.List(context.TODO())
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", autoRechargePrefs.Data)
```

## Update auto recharge preferences

Update payment auto recharge preferences.

`PATCH /payments/auto_recharge_prefs`

```go
	autoRechargePref, err := client.Payment.AutoRechargePrefs.Update(context.TODO(), telnyx.PaymentAutoRechargePrefUpdateParams{})
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", autoRechargePref.Data)
```

## List User Tags

List all user tags.

`GET /user_tags`

```go
	userTags, err := client.UserTags.List(context.TODO(), telnyx.UserTagListParams{})
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", userTags.Data)
```

## List webhook deliveries

Lists webhook_deliveries for the authenticated user

`GET /webhook_deliveries`

```go
	page, err := client.WebhookDeliveries.List(context.TODO(), telnyx.WebhookDeliveryListParams{})
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", page)
```

## Find webhook_delivery details by ID

Provides webhook_delivery debug data, such as timestamps, delivery status and attempts.

`GET /webhook_deliveries/{id}`

```go
	webhookDelivery, err := client.WebhookDeliveries.Get(context.TODO(), "C9C0797E-901D-4349-A33C-C2C8F31A92C2")
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", webhookDelivery.Data)
```

Overview

This skill demonstrates how to manage Telnyx account features using the Go SDK. It includes examples for retrieving balances, invoices, audit logs, webhook deliveries, detail records, and payment auto-recharge preferences. The examples show common list, get, and update flows to integrate account operations into Go applications. Use the provided snippets as a quick-start for authenticated API calls.

How this skill works

Initialize a telnyx client with an API key and call the relevant client methods (List, Get, Update) with context and parameter structs. The skill covers endpoints for audit events, balance, detail records, invoices, payment auto-recharge preferences, user tags, and webhook deliveries. Each example handles errors and prints returned data or pages, demonstrating pagination and single-resource retrieval. Use the patterns to adapt filters, pagination, and update payloads for your application.

When to use it

  • You need to programmatically retrieve account balance and billing information in a Go service.
  • You want to list or fetch invoices and paginate through invoice records.
  • You need audit logs or detail records for monitoring, compliance, or debugging.
  • You manage webhook deliveries and need delivery/debug details for troubleshooting.
  • You want to read or update payment auto-recharge preferences for automated billing.

Best practices

  • Always initialize the client with a secure API key stored in environment variables or a secret manager.
  • Use context with timeouts or cancellation for network calls to prevent hanging requests.
  • Handle pagination by iterating pages returned from List methods rather than assuming a single response.
  • Check and handle API errors explicitly; log enough detail for debugging without exposing secrets.
  • Validate and sanitize fields before sending updates to payment preferences or other writable endpoints.

Example use cases

  • Automate a nightly job that exports invoices and balances to your accounting system.
  • Fetch recent audit events to populate an internal security or compliance dashboard.
  • Search detail records for troubleshooting a specific phone number or transaction.
  • Inspect webhook delivery attempts and payloads when a callback to your service failed.
  • Enable or modify auto-recharge rules from an admin panel using the Update example.

FAQ

How do I authenticate requests?

Initialize the telnyx client with option.WithAPIKey using an API key stored in an environment variable or secret store.

How do I handle large result sets?

Use the List methods which return paginated pages and iterate over pages to process large result sets safely.