Instalar en Claude Code
Copiargit clone --depth 1 https://github.com/team-telnyx/ai /tmp/telnyx-account-reports-go && cp -r /tmp/telnyx-account-reports-go/providers/claude/plugin/skills/telnyx-account-reports-go ~/.claude/skills/telnyx-account-reports-goDespués abre una sesión nueva de Claude Code; el skill carga automáticamente.
Definición
SKILL.md
<!-- Auto-generated from Telnyx OpenAPI specs. Do not edit. -->
# Telnyx Account Reports - 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.
## 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).
## Important Notes
- **Pagination:** Use `ListAutoPaging()` for automatic iteration: `iter := client.Resource.ListAutoPaging(ctx, params); for iter.Next() { item := iter.Current() }`.
## List call events
Filters call events by given filter parameters. Events are ordered by `occurred_at`. If filter for `leg_id` or `application_session_id` is not present, it only filters events from the last 24 hours.
`GET /call_events`
```go
page, err := client.CallEvents.List(context.Background(), telnyx.CallEventListParams{})
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", page)
```
Returns: `call_leg_id` (string), `call_session_id` (string), `event_timestamp` (string), `metadata` (object), `name` (string), `record_type` (enum: call_event), `type` (enum: command, webhook)
## Create a ledger billing group report
`POST /ledger_billing_group_reports`
Optional: `month` (integer), `year` (integer)
```go
ledgerBillingGroupReport, err := client.LedgerBillingGroupReports.New(context.Background(), telnyx.LedgerBillingGroupReportNewParams{
Month: telnyx.Int(10),
Year: telnyx.Int(2019),
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", ledgerBillingGroupReport.Data)
```
Returns: `created_at` (date-time), `id` (uuid), `organization_id` (uuid), `record_type` (enum: ledger_billing_group_report), `report_url` (uri), `status` (enum: pending, complete, failed, deleted), `updated_at` (date-time)
## Get a ledger billing group report
`GET /ledger_billing_group_reports/{id}`
```go
ledgerBillingGroupReport, err := client.LedgerBillingGroupReports.Get(context.Background(), "f5586561-8ff0-4291-a0ac-84fe544797bd")
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", ledgerBillingGroupReport.Data)
```
Returns: `created_at` (date-time), `id` (uuid), `organization_id` (uuid), `record_type` (enum: ledger_billing_group_report), `report_url` (uri), `status` (enum: pending, complete, failed, deleted), `updated_at` (date-time)
## Get all MDR detailed report requests
Retrieves all MDR detailed report requests for the authenticated user
`GET /legacy/reporting/batch_detail_records/messaging`
```go
messagings, err := client.Legacy.Reporting.BatchDetailRecords.Messaging.List(context.Background())
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", messagings.Data)
```
Returns: `connections` (array[integer]), `created_at` (date-time), `directions` (array[string]), `end_date` (date-time), `filters` (array[object]), `id` (uuid), `profiles` (array[string]), `record_type` (string), `record_types` (array[string]), `report_name` (string), `report_url` (string), `start_date` (date-time), `status` (enum: PENDING, COMPLETE, FAILED, EXPIRED), `updated_at` (date-time)
## Create a new MDR detailed report request
Creates a new MDR detailed report request with the specified filters
`POST /legacy/reporting/batch_detail_records/messaging` — Required: `start_time`, `end_time`
Optional: `connections` (array[integer]), `directions` (array[integer]), `filters` (array[object]), `include_message_body` (boolean), `managed_accounts` (array[string]), `profiles` (array[string]), `record_types` (array[integer]), `report_name` (string), `select_all_managed_accounts` (boolean), `timezone` (string)
```go
messaging, err := client.Legacy.Reporting.BatchDetailRecords.Messaging.New(context.Background(), telnyx.LegacyReportingBatchDetailRecordMessagingNewParams{
EndTime: time.Now(),
StartTime: time.Now(),
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", messaging.Data)
```
Returns: `connections` (array[integer]), `created_at` (date-time), `directions` (array[string]), `end_date` (date-time), `filters` (array[object]), `id` (uuid), `profiles` (array[string]), `record_type` (string), `record_types` (array[string]), `report_name` (string), `report_url` (string), `start_date` (date-time), `status` (enum: PENDING, COMPLETE, FAILED, EXPIRED), `updated_at` (date-time)
## Get a specific MDR detailed report request
Retrieves a specific MDR detailed report request by ID
`GET /legacy/reporting/batch_detail_records/messaging/{id}`
```go
messaging, err := client.Legacy.Reporting.BatchDetailRecords.Messaging.Get(context.Background(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", messaging.Data)
```
Returns: `connections` (array[integer]), `created_at` (date-time), `directions` (array[string]), `end_date` (date-time), `filters` (array[object]), `id` (uuid), `profiles` (array[string]), `record_type` (string), `record_types` (array[string]), `report_name` (strin