Skip to main content

Telnyx Other APIs: Account & Billing — Full Documentation

Complete page content for Account & Billing (Other APIs section) of the Telnyx developer docs (https://developers.telnyx.com). Root index: https://developers.telnyx.com/llms.txt · Lightweight index for this subsection: https://developers.telnyx.com/development/llms/other-apis-account-billing-llms-txt.md

Usage reports

Usage Reports

Source: https://developers.telnyx.com/docs/reporting/usage-reports.md

Overview

The (v2) Usage Reports API is a single endpoint that enables viewing aggregated usage data across all of a customer’s Telnyx products. It is built to be flexible and customizable, so that you have programmatic access to view data in a way that makes sense to your business and use cases. It can be used to efficiently monitor usage trends and costs, as well as to directly integrate with your internal systems.

Query Requirements

Products

A product from the Options response (see next section) must be included. At this time, there is not a way to view usage for all or multiple products at once. Products Supported:
  • Sip-Trunking (sip-trunking)
  • Messaging (messaging)
  • Voice API (call-control)
  • Wireless (wireless)
  • Cloud Storage (cloud-storage)
  • Inference (inference)
  • Verify 2fa (verify-2fa)
  • Fax API (fax-api)
  • WebRTC (webrtc)
  • Calls per Second (cps)
  • Conference (conference)
  • Video API (programmable-video)
  • Call Control Features (call-control-features)
  • Customer Service Record (customer-service-record)
  • Media Streaming (media-streaming)
  • Noise Suppression (noise-suppression)
  • Text to Speech (text-to-speech)
  • Speech to Text (speech-to-text)
  • Recording (recording)
  • Forking (forking)
  • Media Storage (media-storage)
  • Answering Machine Detection (amd)

Dates

The start and end date parameters should be in the format YYYY-MM-DDThh:mm:ssTZD (eg 2022-12-24T19:20:30-05:00). This allows you to specify the timespan in your local time by including the timezone offset. The start_date parameter is inclusive, while the end_date parameter is exclusive - e.g. if you wanted data for all of February, the start_date would be 2023-02-01T00:00:00-00:00 and the end_date would be 2023-03-01T00:00:00-00:00. Billing usage is calculated using UTC. The maximum range supported is 31 days. Another way to specify the timespan you want is to utilize the date literals spelled out in our developer docs - https://developers.telnyx.com/api#date-literals. This can be achieved by replacing start_date & end_date with date_range like this: date_range=last_1_weeks. To see the requested data broken out by day for the timespan selected, there is a date dimension available on all products. Additionally, there’s a breakout by hour available using the date_time dimension.

Format

Specifying a format is optional. The endpoint returns JSON by default. At this time, the API also supports generating a CSV file from the response by specifying format=csv in your query.

Dimensions & Metrics Options Per Product

To view the products with their dimensions and metrics available for reporting, you can make a request to the endpoint below. Metrics are the values you’re interested in, for example, the number of calls attempted or the total cost of your usage. Dimensions are how you want your data broken out, for example, by connection, messaging profile, or the traffic’s direction. Below, you’ll see a sample of the “Options” response for Sip-Trunking. If you already know the product you want and are looking for only its supported dimensions/metrics, you can pass the product parameter as shown in the example. If you want to see all products, simply leave off the product parameter.
Request:
Don’t forget to update YOUR_API_KEY here.
Response:

Product Examples

SIP Trunking

Example 1: Simple SIP Report

Let’s say we’re interested in our sip-trunking usage for the week of January 23rd. And let’s say we want to see the total calls connected versus calls attempted and the total cost. And we need these numbers broken out by direction and country. We first make a query to the Options endpoint listed above to make sure those requirements are all supported and to see how to query for them. These are our requirements shown next to how we’d construct our query for them: Product: sip-trunking product=sip-trunking Date(s): January 23rd - 28th 2024 start_date=2024-01-23T00:00:00-00:00end_date=2024-01-29T00:00:00-00:00 Metrics: calls connected, calls attempted, cotal cost metrics=connected,attempted,cost Broken out by destination countryNote: Since we’re filtering on the direction, we must include it. dimensions=country_code,direction Outbound only filter[direction]=outbound API Response’s Page Size/Number page[number]=1page[size]=20
Request:
Response:
From the response below, we can see that during the week in question, our account only had traffic to the US (country code = 1). Our connected versus attempted is 883,930 vs 1,245,811 calls respectively. And the total cost for those outbound calls was 1911.624 (Note: If you had wanted the currency, that is another dimension that can be added in the query with dimensions=currency).

Example 2: Short Duration Calls

Telnyx enforces automatic surcharges for customer accounts whose short duration calls (greater than 0 and less than or equal to 6 seconds) total 15% or more of their outbound traffic. As someone running SIP traffic, I may want to know if I’m in danger of receiving the surcharge at the end of the month. We have exposed a metric solely for the purpose of this calculation. Product: sip-trunking product=sip-trunking Date(s): January 2024 start_date=2024-01-01T00:00:00-00:00end_date=2024-02-01T00:00:00-00:00 Metrics: calls completed metrics=completed Broken out by SDC (short duration call: true or false)Note: Since we’re filtering on the direction, we must include it. dimensions=short_duration_call,direction Outbound only filter[direction]=outbound API Response’s Page Size/Number page[number]=1page[size]=20
Request:
Response:
From the response below, we can determine the percentage of our traffic that is currently considered short duration: 414515 / (414515 + 522094) = 44%. If we wanted to take this a step further, we could see which connections are the biggest offenders by adding “connection_id” to the dimensions list.

Messaging

Example 1: Simple Messaging Report

In this example, we’ll put together a simple request to view our Messaging usage for a single day. Product: messaging product=messaging Date(s): Today date_range=today Metrics: total cost, total messages sent, total message parts metrics=cost,count,parts Broken out by CarrierNote: Since we’re filtering on the direction, we must include it. dimensions=short_duration_call,direction Outbound only filter[direction]=outbound API Response’s Page Size/Number page[number]=1page[size]=20
Request:
Response (abbreviated):

Example 2: Alphanumeric by MNC/MCC

This example is a little more complex, and lays out a monthly Messaging report of our Alphanumeric traffic per country, broken out by MCC (Mobile Country Code) and MNC (Mobile Network Code). Product: messaging product=messaging Date(s): January 2024 start_date=2024-01-01T00:00:00-00:00end_date=2024-02-01T00:00:00-00:00 Metrics: total cost, total message parts metrics=cost,parts Dimensions: mcc, mnc, destination country, status_v2 dimensions=direction,mcc,mnc,country_iso,product_name,status_v2 Filters: alphanumeric, outbound, billable statuses only filter[product_name]=alphanumeric_idfilter[direction]=outboundfilter[status_v2]=deliveredfilter[status_v2]=delivery_failedfilter[status_v2]=delivery_unconfirmed
Request:
Response (abbreviated):

Session analysis

Session Analysis

Source: https://developers.telnyx.com/docs/reporting/session-analysis.md

Session Analysis API Usage Guide

Understand the full cost and event tree for any Telnyx AI or voice session — from a single inference call to complex multi-product conversations.

What is Session Analysis?

Session Analysis gives you a complete view of costs and events for any usage session on the Telnyx platform:
  • Full event tree — parent events, child events, and their relationships
  • Rollup costs — per-event costs plus cumulative totals across the session
  • Product linkages — how different Telnyx products interacted in a single session
This is especially valuable for AI-powered sessions, where a single call can involve multiple Telnyx products — AI Voice Assistant, inference, speech-to-text, text-to-speech, call control, SIP trunking, and more — all layered into one conversation.

When to Use It


Core Concepts

Record Types

A record type identifies the category of usage event for a Telnyx product. Each record type maps to a specific product and has defined relationships to other record types. Example: ai-voice-assistant is the record type for AI Voice Assistant sessions, which have inference events as children.

Sessions

A session is a tree of related usage events. The root event is the primary event you’re analyzing. Child events are related usage that occurred as part of that session. Example: An AI Voice Assistant call involves a call-session root with a call-control child, which in turn has an ai-voice-assistant child with inference events underneath — each representing one LLM turn in the conversation.

Relationships

Events are connected via relationships: Relationships are defined via field mappings — the child’s local_field matches the parent’s parent_field. For example, inference events link to their ai-voice-assistant parent via the conversation_id field.

Cost Rollup

Each event node includes:
  • event_cost — Cost of this individual event
  • cumulative_cost — This event’s cost plus all descendant costs
The root event’s cumulative_cost equals the total session cost. For AI sessions, this means the call-session cumulative cost includes everything — the AI assistant, each inference turn, STT, TTS, call control, and SIP trunking — rolled up into one number.

Endpoints

1. List All Record Types

Returns all available record types, their relationships, and query parameter options. Response includes:
  • record_types[] — Array of all record types with their parent/child relationships
  • query_parameters — Valid parameters for session analysis queries
  • meta — Total count and last updated timestamp
Example:

2. Get Record Type Details

Returns metadata for a specific record type with additional details:
  • Valid child and parent relationships
  • Example query URLs
  • Recommended max depth for traversal
Example:

3. Get Session Analysis

Retrieves the full session analysis tree for a specific event. Path Parameters: You can find event IDs in the individual webhooks or detail records for the applicable event. Which record type should I use? If you’re analyzing a call made with your AI assistant, start with call-session. This gives you the full picture — AI assistant sessions, inference events, call control, SIP trunking, and all other products in one tree. Use the metadata endpoint to explore other starting points for different products. Query Parameters: Example:

Response Structure

Top-Level Fields

Event Node Structure

Each event in the tree follows this structure:

Relationship Object

For child events, the relationship field explains the connection:
Note: The via fields vary by relationship. AI-related linkages often use conversation_id, while voice/telephony relationships typically use telnyx_session_id or call_session_id.

Example: AI Voice Assistant Session

A customer makes an inbound call to an AI Voice Assistant using the Telnyx Web Dialer. The assistant handles a multi-turn conversation over ~152 seconds. Query:
Session tree:
Summary: Key observations:
  • The call-session root has $0.00 event cost — it’s a container for the session, not a billable event itself.
  • ai-voice-assistant is the dominant cost at 0.18(billedat0.18 (billed at 0.06/min for 3 billed minutes). Its cumulative cost of $0.1921 includes 5 inference events underneath.
  • Each inference event represents a single LLM call during the conversation — one per assistant turn. The cost per turn varies based on the model and token count.
  • call-control has a 0.0052eventcostbuta0.0052 event cost but a 0.1973 cumulative cost — the difference is the ai-voice-assistant subtree rolling up underneath it.
  • recording, webrtc, and sip-trunking are leaf nodes with no children, so their event cost equals their cumulative cost.

Understanding the AI Cost Structure

In an AI-powered call, costs come from multiple layers: Session Analysis rolls all of these into one tree, so you can see exactly where cost accumulates — whether it’s the AI assistant minute rate, the number of inference turns, or the underlying voice transport.

Common Use Cases

Debugging High-Cost AI Sessions

  1. Query the session with max_depth=5 to get the full tree
  2. Look at meta.products to see which products were involved
  3. Compare event_cost across children — if ai-voice-assistant is the driver, check how many inference turns occurred underneath
  4. Check record fields for rate information (rate, rate_measured_in) and duration
  1. Start from any event in the tree
  2. Use relationship.via to understand the field linkage
  3. Query the parent or children directly using their id

Exporting for Analysis

  1. Use expand=none to get just the tree structure without full records
  2. Flatten the tree programmatically for spreadsheet import
  3. Or keep full records and parse specific fields (e.g., rate, duration_sec)

Best Practices

Performance

  • Provide date_time when you know it — this narrows the index search and improves response time
  • Use appropriate max_depth — start with 2, increase only if needed. AI sessions with inference events typically need max_depth=4 or 5 to reach the leaf level.
  • Use expand=none if you only need cost rollups, not full records

Querying

  • Start from the root event — the most complete picture comes from the top-level event
  • Check metadata first/metadata/{record_type} shows expected children and recommended depth
  • Use links.records to get the underlying detail records for deeper analysis

Error Handling


Record Types Reference

AI & Voice Intelligence

Voice & Telephony

Media & Storage

Conferencing

Messaging

Video

Other Products


On-Demand Reports

On-Demand Reports

Source: https://developers.telnyx.com/docs/reporting/on-demand-reports.md
On-Demand Reports lets you query your Telnyx usage data using natural language. Instead of building filters and exporting CSVs, describe the report you want in plain English and the system generates it.

Overview

On-Demand Reports uses AI to translate natural language into structured queries against your Usage Report data. You can request specific chart types, date ranges, groupings, and breakdowns — all from a single text input.

Getting started

  1. Log in to the Mission Control Portal.
  2. Navigate to Reporting > On-Demand Reports.
  3. Type a query describing the report you need and submit it.
On-Demand Reports query interface

Example queries

  • “Daily wireless spend for the last 10 days”
  • “Number of messages by direction for last week as a pie chart”
  • “Weekly total calls last quarter”
  • “Average SIP cost for last 2 weeks as line graph”
  • “SIP usage for the last month as a table”

What you can do


Current limitations

  • Queries run against v2 Usage Report data only. Products and dimensions available in Usage Reports are available here.
  • Not a general knowledge assistant — the system answers questions about your Telnyx usage data, not general questions.
  • This is the first release. Coverage and capabilities will expand over time.

API Reference (Account & Billing)

AutoRechargePreferences

Notifications

Addresses

Billing

Authentication Providers

IP Addresses

IP Ranges

Managed Accounts

Organization Users

Billing Groups

Detail Records

MDR Detailed Reports

CDR Reports

MDR Usage Reports

Telco Data Usage Reports

Speech to text Usage Reports

  • Get speech to text usage report: Generate and fetch speech to text usage report synchronously. This endpoint will both generate and fetch the speech to text report over a specified time period.

CDR Usage Reports

Usage Reports (BETA)

Speech to Text Batch Reports

MDR Detail Reports

WDR Detail Reports

Session Analysis

  • Get metadata overview: Returns all available record types and supported query parameters for session analysis.
  • Get record type metadata: Returns detailed metadata for a specific record type, including relationships and examples.
  • Get session analysis: Retrieves a full session analysis tree for a given event, including costs, child events, and product linkages.

Webhooks

Audit Logs

  • List Audit Logs: Retrieve a list of audit log entries. Audit logs are a best-effort, eventually consistent record of significant account-related changes.

User Tags

UserAddresses

Integration Secrets