Skip to content
telnyx-account-reports-python logo

Telnyx Account Reports - Python

telnyx-account-reports-python

Generate and retrieve usage reports for billing, analytics, and reconciliation. This skill provides Python SDK examples.

SKILL.md

Full skill instructions

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

Telnyx Account Reports - Python

Installation

pip install telnyx

Setup

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.

Get all MDR detailed report requests

Retrieves all MDR detailed report requests for the authenticated user

GET /​legacy_reporting/​batch_detail_records/​messaging

messagings = client.legacy.reporting.batch_detail_records.messaging.list()
print(messagings.data)

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

from datetime import datetime

messaging = client.legacy.reporting.batch_detail_records.messaging.create(
    end_time=datetime.fromisoformat("2024-02-12T23:59:59"),
    start_time=datetime.fromisoformat("2024-02-01T00:00:00"),
)
print(messaging.data)

Get a specific MDR detailed report request

Retrieves a specific MDR detailed report request by ID

GET /​legacy_reporting/​batch_detail_records/​messaging/​{id}

messaging = client.legacy.reporting.batch_detail_records.messaging.retrieve(
    "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
print(messaging.data)

Delete a MDR detailed report request

Deletes a specific MDR detailed report request by ID

DELETE /​legacy_reporting/​batch_detail_records/​messaging/​{id}

messaging = client.legacy.reporting.batch_detail_records.messaging.delete(
    "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
print(messaging.data)

Get all CDR report requests

Retrieves all CDR report requests for the authenticated user

GET /​legacy_reporting/​batch_detail_records/​voice

voices = client.legacy.reporting.batch_detail_records.voice.list()
print(voices.data)

Create a new CDR report request

Creates a new CDR report request with the specified filters

POST /​legacy_reporting/​batch_detail_records/​voice — Required: start_time, end_time

from datetime import datetime

voice = client.legacy.reporting.batch_detail_records.voice.create(
    end_time=datetime.fromisoformat("2024-02-12T23:59:59"),
    start_time=datetime.fromisoformat("2024-02-01T00:00:00"),
)
print(voice.data)

Get a specific CDR report request

Retrieves a specific CDR report request by ID

GET /​legacy_reporting/​batch_detail_records/​voice/​{id}

voice = client.legacy.reporting.batch_detail_records.voice.retrieve(
    "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
print(voice.data)

Delete a CDR report request

Deletes a specific CDR report request by ID

DELETE /​legacy_reporting/​batch_detail_records/​voice/​{id}

voice = client.legacy.reporting.batch_detail_records.voice.delete(
    "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
print(voice.data)

Get available CDR report fields

Retrieves all available fields that can be used in CDR reports

GET /​legacy_reporting/​batch_detail_records/​voice/​fields

response = client.legacy.reporting.batch_detail_records.voice.retrieve_fields()
print(response.billing)

List MDR usage reports

Fetch all previous requests for MDR usage reports.

GET /​legacy_reporting/​usage_reports/​messaging

page = client.legacy.reporting.usage_reports.messaging.list()
page = page.data[0]
print(page.id)

Create a new legacy usage V2 MDR report request

Creates a new legacy usage V2 MDR report request with the specified filters

POST /​legacy_reporting/​usage_reports/​messaging

messaging = client.legacy.reporting.usage_reports.messaging.create(
    aggregation_type=0,
)
print(messaging.data)

Get an MDR usage report

Fetch single MDR usage report by id.

GET /​legacy_reporting/​usage_reports/​messaging/​{id}

messaging = client.legacy.reporting.usage_reports.messaging.retrieve(
    "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
print(messaging.data)

Delete a V2 legacy usage MDR report request

Deletes a specific V2 legacy usage MDR report request by ID

DELETE /​legacy_reporting/​usage_reports/​messaging/​{id}

messaging = client.legacy.reporting.usage_reports.messaging.delete(
    "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
print(messaging.data)

List telco data usage reports

Retrieve a paginated list of telco data usage reports

GET /​legacy_reporting/​usage_reports/​number_lookup

number_lookups = client.legacy.reporting.usage_reports.number_lookup.list()
print(number_lookups.data)

Submit telco data usage report

Submit a new telco data usage report

POST /​legacy_reporting/​usage_reports/​number_lookup

number_lookup = client.legacy.reporting.usage_reports.number_lookup.create()
print(number_lookup.data)

Get telco data usage report by ID

Retrieve a specific telco data usage report by its ID

GET /​legacy_reporting/​usage_reports/​number_lookup/​{id}

number_lookup = client.legacy.reporting.usage_reports.number_lookup.retrieve(
    "id",
)
print(number_lookup.data)

Delete telco data usage report

Delete a specific telco data usage report by its ID

DELETE /​legacy_reporting/​usage_reports/​number_lookup/​{id}

client.legacy.reporting.usage_reports.number_lookup.delete(
    "id",
)

Get speech to text usage report

Generate and fetch speech to text usage report synchronously.

GET /​legacy_reporting/​usage_reports/​speech_to_text

response = client.legacy.reporting.usage_reports.retrieve_speech_to_text()
print(response.data)

List CDR usage reports

Fetch all previous requests for cdr usage reports.

GET /​legacy_reporting/​usage_reports/​voice

page = client.legacy.reporting.usage_reports.voice.list()
page = page.data[0]
print(page.id)

Create a new legacy usage V2 CDR report request

Creates a new legacy usage V2 CDR report request with the specified filters

POST /​legacy_reporting/​usage_reports/​voice

from datetime import datetime

voice = client.legacy.reporting.usage_reports.voice.create(
    end_time=datetime.fromisoformat("2024-02-01T00:00:00"),
    start_time=datetime.fromisoformat("2024-02-01T00:00:00"),
)
print(voice.data)

Get a CDR usage report

Fetch single cdr usage report by id.

GET /​legacy_reporting/​usage_reports/​voice/​{id}

voice = client.legacy.reporting.usage_reports.voice.retrieve(
    "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
print(voice.data)

Delete a V2 legacy usage CDR report request

Deletes a specific V2 legacy usage CDR report request by ID

DELETE /​legacy_reporting/​usage_reports/​voice/​{id}

voice = client.legacy.reporting.usage_reports.voice.delete(
    "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
print(voice.data)

Fetch all Messaging usage reports

Fetch all messaging usage reports.

GET /​reports/​mdr_usage_reports

page = client.reports.mdr_usage_reports.list()
page = page.data[0]
print(page.id)

Create MDR Usage Report

Submit request for new new messaging usage report.

POST /​reports/​mdr_usage_reports

from datetime import datetime

mdr_usage_report = client.reports.mdr_usage_reports.create(
    aggregation_type="NO_AGGREGATION",
    end_date=datetime.fromisoformat("2020-07-01T00:00:00-06:00"),
    start_date=datetime.fromisoformat("2020-07-01T00:00:00-06:00"),
)
print(mdr_usage_report.data)

Retrieve messaging report

Fetch a single messaging usage report by id

GET /​reports/​mdr_usage_reports/​{id}

mdr_usage_report = client.reports.mdr_usage_reports.retrieve(
    "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
print(mdr_usage_report.data)

Delete MDR Usage Report

Delete messaging usage report by id

DELETE /​reports/​mdr_usage_reports/​{id}

mdr_usage_report = client.reports.mdr_usage_reports.delete(
    "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
print(mdr_usage_report.data)

Generate and fetch MDR Usage Report

Generate and fetch messaging usage report synchronously.

GET /​reports/​mdr_usage_reports/​sync

response = client.reports.mdr_usage_reports.fetch_sync(
    aggregation_type="PROFILE",
)
print(response.data)

Generates and fetches CDR Usage Reports

Generate and fetch voice usage report synchronously.

GET /​reports/​cdr_usage_reports/​sync

response = client.reports.cdr_usage_reports.fetch_sync(
    aggregation_type="NO_AGGREGATION",
    product_breakdown="NO_BREAKDOWN",
)
print(response.data)

Get Telnyx product usage data (BETA)

Get Telnyx usage data by product, broken out by the specified dimensions

GET /​usage_reports

page = client.usage_reports.list(
    dimensions=["string"],
    metrics=["string"],
    product="product",
)
page = page.data[0]
print(page)

Get Usage Reports query options (BETA)

Get the Usage Reports options for querying usage, including the products available and their respective metrics and dimensions

GET /​usage_reports/​options

response = client.usage_reports.get_options()
print(response.data)

More skills from team-telnyx

10dlc-registration logo
team-telnyx/telnyx-toolkit

10dlc-registration

Register for 10DLC as a sole proprietor to enable SMS messaging in the USA. Use when setting up A2P SMS, registering brands/campaigns, or assigning phone numbers for compliant US messaging. Requires Telnyx CLI.

3 0
View
telnyx-embeddings logo
team-telnyx/telnyx-toolkit

telnyx-embeddings

Text-to-vector embeddings and semantic search using Telnyx AI. Generate embedding vectors via an OpenAI-compatible API — no OpenAI or Google API keys required.

3 0
View
telnyx-rag logo
team-telnyx/telnyx-toolkit

telnyx-rag

Semantic search and Q&A over workspace files using Telnyx Storage + AI embeddings. Index your memory, knowledge, and skills for natural language retrieval and AI-powered answers.

3 0
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View