home / skills / openclaw / skills / telnyx-account-python

This skill helps you manage Telnyx account balance, invoices, and webhooks using Python SDK examples for quick integration.

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

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

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

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

# Telnyx Account - Python

## Installation

```bash
pip install telnyx
```

## Setup

```python
import os
from telnyx import Telnyx

client = Telnyx(
    api_key=os.environ.get("TELNYX_API_KEY"),  # This is the default and can be omitted
)
```

All examples below assume `client` is already initialized as shown above.

## List Audit Logs

Retrieve a list of audit log entries.

`GET /audit_events`

```python
page = client.audit_events.list()
page = page.data[0]
print(page.id)
```

## Get user balance details

`GET /balance`

```python
balance = client.balance.retrieve()
print(balance.data)
```

## Search detail records

Search for any detail record across the Telnyx Platform

`GET /detail_records`

```python
page = client.detail_records.list()
page = page.data[0]
print(page)
```

## List invoices

Retrieve a paginated list of invoices.

`GET /invoices`

```python
page = client.invoices.list()
page = page.data[0]
print(page.file_id)
```

## Get invoice by ID

Retrieve a single invoice by its unique identifier.

`GET /invoices/{id}`

```python
invoice = client.invoices.retrieve(
    id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
print(invoice.data)
```

## List auto recharge preferences

Returns the payment auto recharge preferences.

`GET /payments/auto_recharge_prefs`

```python
auto_recharge_prefs = client.payment.auto_recharge_prefs.list()
print(auto_recharge_prefs.data)
```

## Update auto recharge preferences

Update payment auto recharge preferences.

`PATCH /payments/auto_recharge_prefs`

```python
auto_recharge_pref = client.payment.auto_recharge_prefs.update()
print(auto_recharge_pref.data)
```

## List User Tags

List all user tags.

`GET /user_tags`

```python
user_tags = client.user_tags.list()
print(user_tags.data)
```

## List webhook deliveries

Lists webhook_deliveries for the authenticated user

`GET /webhook_deliveries`

```python
page = client.webhook_deliveries.list()
page = page.data[0]
print(page.id)
```

## Find webhook_delivery details by ID

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

`GET /webhook_deliveries/{id}`

```python
webhook_delivery = client.webhook_deliveries.retrieve(
    "C9C0797E-901D-4349-A33C-C2C8F31A92C2",
)
print(webhook_delivery.data)
```

Overview

This skill provides Python examples for managing Telnyx account operations including balances, payments, invoices, webhooks, audit logs, and detail records. It demonstrates how to initialize the Telnyx client and call common account endpoints with concise sample calls. The examples focus on practical tasks you’ll run in scripts or backend services.

How this skill works

Initialize the Telnyx Python client with an API key and call the client methods that map to Telnyx account endpoints. The skill shows listing and retrieving resources such as audit events, balance, invoices, detail records, webhook deliveries, user tags, and auto recharge preferences. Each example returns SDK objects you can inspect or pass into your application logic.

When to use it

  • When you need to retrieve or audit account activity and footprint (audit events, detail records).
  • When checking or displaying current account balance and payment settings.
  • When listing, retrieving, or processing invoices programmatically.
  • When debugging webhook delivery issues or inspecting webhook payload metadata.
  • When automating updates to auto-recharge and payment preferences.
  • When synchronizing user tags or exporting accounting-related data.

Best practices

  • Store TELNYX_API_KEY securely in environment variables and never hard-code it.
  • Paginate list endpoints and handle empty pages to avoid excessive memory use.
  • Log response IDs and timestamps for auditability when processing invoices or webhooks.
  • Retry idempotently on transient network errors and handle API rate limits gracefully.
  • Sanitize and validate webhook payloads, and use delivery debug data to triage failures.

Example use cases

  • A billing worker that lists invoices, downloads invoice metadata, and updates internal records.
  • A monitoring script that retrieves the account balance and triggers alerts when it drops below a threshold.
  • An audit tool that pulls audit events and detail records for compliance reporting.
  • A webhook diagnostics tool that fetches delivery attempts and timestamps to debug failed deliveries.
  • An automation that reads and updates auto-recharge preferences for prepaid accounts.

FAQ

How do I initialize the Telnyx client in Python?

Import Telnyx, set the TELNYX_API_KEY in your environment, then create client = Telnyx(api_key=os.environ.get('TELNYX_API_KEY')).

Which endpoints support pagination?

List endpoints such as audit_events, invoices, detail_records, webhook_deliveries, and user_tags return paginated results and should be iterated or paginated explicitly.