api/javascript/telnyx-account-reports-javascript/SKILL.md
Generate and retrieve usage reports for billing, analytics, and reconciliation. This skill provides JavaScript SDK examples.
npx skillsauth add team-telnyx/telnyx-toolkit telnyx-account-reports-javascriptInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
npm install telnyx
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});
All examples below assume client is already initialized as shown above.
Retrieves all MDR detailed report requests for the authenticated user
GET /legacy_reporting/batch_detail_records/messaging
const messagings = await client.legacy.reporting.batchDetailRecords.messaging.list();
console.log(messagings.data);
Creates a new MDR detailed report request with the specified filters
POST /legacy_reporting/batch_detail_records/messaging — Required: start_time, end_time
const messaging = await client.legacy.reporting.batchDetailRecords.messaging.create({
end_time: '2024-02-12T23:59:59Z',
start_time: '2024-02-01T00:00:00Z',
});
console.log(messaging.data);
Retrieves a specific MDR detailed report request by ID
GET /legacy_reporting/batch_detail_records/messaging/{id}
const messaging = await client.legacy.reporting.batchDetailRecords.messaging.retrieve(
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
);
console.log(messaging.data);
Deletes a specific MDR detailed report request by ID
DELETE /legacy_reporting/batch_detail_records/messaging/{id}
const messaging = await client.legacy.reporting.batchDetailRecords.messaging.delete(
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
);
console.log(messaging.data);
Retrieves all CDR report requests for the authenticated user
GET /legacy_reporting/batch_detail_records/voice
const voices = await client.legacy.reporting.batchDetailRecords.voice.list();
console.log(voices.data);
Creates a new CDR report request with the specified filters
POST /legacy_reporting/batch_detail_records/voice — Required: start_time, end_time
const voice = await client.legacy.reporting.batchDetailRecords.voice.create({
end_time: '2024-02-12T23:59:59Z',
start_time: '2024-02-01T00:00:00Z',
});
console.log(voice.data);
Retrieves a specific CDR report request by ID
GET /legacy_reporting/batch_detail_records/voice/{id}
const voice = await client.legacy.reporting.batchDetailRecords.voice.retrieve(
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
);
console.log(voice.data);
Deletes a specific CDR report request by ID
DELETE /legacy_reporting/batch_detail_records/voice/{id}
const voice = await client.legacy.reporting.batchDetailRecords.voice.delete(
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
);
console.log(voice.data);
Retrieves all available fields that can be used in CDR reports
GET /legacy_reporting/batch_detail_records/voice/fields
const response = await client.legacy.reporting.batchDetailRecords.voice.retrieveFields();
console.log(response.Billing);
Fetch all previous requests for MDR usage reports.
GET /legacy_reporting/usage_reports/messaging
// Automatically fetches more pages as needed.
for await (const mdrUsageReportResponseLegacy of client.legacy.reporting.usageReports.messaging.list()) {
console.log(mdrUsageReportResponseLegacy.id);
}
Creates a new legacy usage V2 MDR report request with the specified filters
POST /legacy_reporting/usage_reports/messaging
const messaging = await client.legacy.reporting.usageReports.messaging.create({
aggregation_type: 0,
});
console.log(messaging.data);
Fetch single MDR usage report by id.
GET /legacy_reporting/usage_reports/messaging/{id}
const messaging = await client.legacy.reporting.usageReports.messaging.retrieve(
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
);
console.log(messaging.data);
Deletes a specific V2 legacy usage MDR report request by ID
DELETE /legacy_reporting/usage_reports/messaging/{id}
const messaging = await client.legacy.reporting.usageReports.messaging.delete(
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
);
console.log(messaging.data);
Retrieve a paginated list of telco data usage reports
GET /legacy_reporting/usage_reports/number_lookup
const numberLookups = await client.legacy.reporting.usageReports.numberLookup.list();
console.log(numberLookups.data);
Submit a new telco data usage report
POST /legacy_reporting/usage_reports/number_lookup
const numberLookup = await client.legacy.reporting.usageReports.numberLookup.create();
console.log(numberLookup.data);
Retrieve a specific telco data usage report by its ID
GET /legacy_reporting/usage_reports/number_lookup/{id}
const numberLookup = await client.legacy.reporting.usageReports.numberLookup.retrieve('id');
console.log(numberLookup.data);
Delete a specific telco data usage report by its ID
DELETE /legacy_reporting/usage_reports/number_lookup/{id}
await client.legacy.reporting.usageReports.numberLookup.delete('id');
Generate and fetch speech to text usage report synchronously.
GET /legacy_reporting/usage_reports/speech_to_text
const response = await client.legacy.reporting.usageReports.retrieveSpeechToText();
console.log(response.data);
Fetch all previous requests for cdr usage reports.
GET /legacy_reporting/usage_reports/voice
// Automatically fetches more pages as needed.
for await (const cdrUsageReportResponseLegacy of client.legacy.reporting.usageReports.voice.list()) {
console.log(cdrUsageReportResponseLegacy.id);
}
Creates a new legacy usage V2 CDR report request with the specified filters
POST /legacy_reporting/usage_reports/voice
const voice = await client.legacy.reporting.usageReports.voice.create({
end_time: '2024-02-01T00:00:00Z',
start_time: '2024-02-01T00:00:00Z',
});
console.log(voice.data);
Fetch single cdr usage report by id.
GET /legacy_reporting/usage_reports/voice/{id}
const voice = await client.legacy.reporting.usageReports.voice.retrieve(
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
);
console.log(voice.data);
Deletes a specific V2 legacy usage CDR report request by ID
DELETE /legacy_reporting/usage_reports/voice/{id}
const voice = await client.legacy.reporting.usageReports.voice.delete(
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
);
console.log(voice.data);
Fetch all messaging usage reports.
GET /reports/mdr_usage_reports
// Automatically fetches more pages as needed.
for await (const mdrUsageReport of client.reports.mdrUsageReports.list()) {
console.log(mdrUsageReport.id);
}
Submit request for new new messaging usage report.
POST /reports/mdr_usage_reports
const mdrUsageReport = await client.reports.mdrUsageReports.create({
aggregation_type: 'NO_AGGREGATION',
end_date: '2020-07-01T00:00:00-06:00',
start_date: '2020-07-01T00:00:00-06:00',
});
console.log(mdrUsageReport.data);
Fetch a single messaging usage report by id
GET /reports/mdr_usage_reports/{id}
const mdrUsageReport = await client.reports.mdrUsageReports.retrieve(
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
);
console.log(mdrUsageReport.data);
Delete messaging usage report by id
DELETE /reports/mdr_usage_reports/{id}
const mdrUsageReport = await client.reports.mdrUsageReports.delete(
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
);
console.log(mdrUsageReport.data);
Generate and fetch messaging usage report synchronously.
GET /reports/mdr_usage_reports/sync
const response = await client.reports.mdrUsageReports.fetchSync({ aggregation_type: 'PROFILE' });
console.log(response.data);
Generate and fetch voice usage report synchronously.
GET /reports/cdr_usage_reports/sync
const response = await client.reports.cdrUsageReports.fetchSync({
aggregation_type: 'NO_AGGREGATION',
product_breakdown: 'NO_BREAKDOWN',
});
console.log(response.data);
Get Telnyx usage data by product, broken out by the specified dimensions
GET /usage_reports
// Automatically fetches more pages as needed.
for await (const usageReportListResponse of client.usageReports.list({
dimensions: ['string'],
metrics: ['string'],
product: 'product',
})) {
console.log(usageReportListResponse);
}
Get the Usage Reports options for querying usage, including the products available and their respective metrics and dimensions
GET /usage_reports/options
const response = await client.usageReports.getOptions();
console.log(response.data);
tools
Build cross-platform VoIP calling apps with React Native using Telnyx Voice SDK. High-level reactive API with automatic lifecycle management, CallKit/ConnectionService integration, and push notifications. Use for mobile VoIP apps with minimal setup.
tools
Build browser-based VoIP calling apps using Telnyx WebRTC JavaScript SDK. Covers authentication, voice calls, events, debugging, call quality metrics, and AI Agent integration. Use for web-based real-time communication.
tools
Build VoIP calling apps on iOS using Telnyx WebRTC SDK. Covers authentication, making/receiving calls, CallKit integration, PushKit/APNS push notifications, call quality metrics, and AI Agent integration. Use when implementing real-time voice communication on iOS.
tools
Build cross-platform VoIP calling apps with Flutter using Telnyx WebRTC SDK. Covers authentication, making/receiving calls, push notifications (FCM + APNS), call quality metrics, and AI Agent integration. Works on Android, iOS, and Web.