Skip to main content
GET
/
usage_reports
JavaScript
import Telnyx from 'telnyx';

const client = new Telnyx({
  apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});

// Automatically fetches more pages as needed.
for await (const usageReportListResponse of client.usageReports.list({
  dimensions: ['string'],
  metrics: ['string'],
  product: 'product',
})) {
  console.log(usageReportListResponse);
}
import os
from telnyx import Telnyx

client = Telnyx(
api_key=os.environ.get("TELNYX_API_KEY"), # This is the default and can be omitted
)
page = client.usage_reports.list(
dimensions=["string"],
metrics=["string"],
product="product",
)
page = page.data[0]
print(page)
package main

import (
"context"
"fmt"

"github.com/team-telnyx/telnyx-go"
"github.com/team-telnyx/telnyx-go/option"
)

func main() {
client := telnyx.NewClient(
option.WithAPIKey("My API Key"),
)
page, err := client.UsageReports.List(context.TODO(), telnyx.UsageReportListParams{
Dimensions: []string{"string"},
Metrics: []string{"string"},
Product: "product",
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", page)
}
package com.telnyx.sdk.example;

import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
import com.telnyx.sdk.models.usagereports.UsageReportListPage;
import com.telnyx.sdk.models.usagereports.UsageReportListParams;

public final class Main {
private Main() {}

public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();

UsageReportListParams params = UsageReportListParams.builder()
.addDimension("string")
.addMetric("string")
.product("product")
.build();
UsageReportListPage page = client.usageReports().list(params);
}
}
require "telnyx"

telnyx = Telnyx::Client.new(api_key: "My API Key")

page = telnyx.usage_reports.list(dimensions: ["string"], metrics: ["string"], product: "product")

puts(page)
<?php

require_once dirname(__DIR__) . '/vendor/autoload.php';

use Telnyx\Client;
use Telnyx\Core\Exceptions\APIException;

$client = new Client(apiKey: getenv('TELNYX_API_KEY') ?: 'My API Key');

try {
$page = $client->usageReports->list(
dimensions: ['string'],
metrics: ['string'],
product: 'product',
dateRange: 'date_range',
endDate: 'end_date',
filter: 'filter',
format: 'csv',
managedAccounts: true,
pageNumber: 0,
pageSize: 0,
sort: ['string'],
startDate: 'start_date',
authorizationBearer: 'authorization_bearer',
);

var_dump($page);
} catch (APIException $e) {
echo $e->getMessage();
}
telnyx usage-reports list \
--api-key 'My API Key' \
--dimension string \
--metric string \
--product product
curl --request GET \
--url https://api.telnyx.com/v2/usage_reports \
--header 'Authorization: Bearer <token>'
{
  "meta": {
    "total_pages": 5,
    "total_results": 100,
    "page_number": 1,
    "page_size": 20
  },
  "data": [
    {
      "product": "messaging",
      "cost": 0.012,
      "parts": 12,
      "count": 8,
      "customer_carrier_fee": 0,
      "product_name": "long_code",
      "country_iso": "LC",
      "direction": "outbound"
    },
    {
      "product": "messaging",
      "cost": 0.021,
      "parts": 21,
      "count": 12,
      "customer_carrier_fee": 0,
      "product_name": "long_code",
      "country_iso": "MP",
      "direction": "outbound"
    }
  ]
}
{
"errors": [
{
"code": "10003",
"title": "Metrics invalid values",
"detail": "Available metrics values for sip-trunking: connected,cost,completed,call_sec,attempted,billed_sec.",
"source": {
"pointer": "/title",
"parameter": "metrics"
},
"meta": {
"url": "https://developers.telnyx.com/docs/overview/errors/10001"
}
}
]
}
{
"errors": [
{
"code": "10003",
"title": "Metrics invalid values",
"detail": "Available metrics values for sip-trunking: connected,cost,completed,call_sec,attempted,billed_sec.",
"source": {
"pointer": "/title",
"parameter": "metrics"
},
"meta": {
"url": "https://developers.telnyx.com/docs/overview/errors/10001"
}
}
]
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Headers

authorization_bearer
string

Bearer token used to authenticate the request. Authenticates the request with your Telnyx API V2 KEY

Query Parameters

product
string
required

Telnyx product

dimensions
string[]
required

Breakout by specified product dimensions

metrics
string[]
required

Specified product usage values

start_date
string

The start date for the time range you are interested in. The maximum time range is 31 days. Format: YYYY-MM-DDTHH:mm:ssZ

end_date
string

The end date for the time range you are interested in. The maximum time range is 31 days. Format: YYYY-MM-DDTHH:mm:ssZ

date_range
string

A more user-friendly way to specify the timespan you want to filter by. More options can be found in the Telnyx API Reference docs.

filter
string

Filter records on dimensions

managed_accounts
boolean

Return the aggregations for all Managed Accounts under the user making the request.

sort
string[]

Specifies the sort order for results

format
enum<string>

Specify the response format (csv or json). JSON is returned by default, even if not specified.

Available options:
csv,
json
page
object

Consolidated page parameter (deepObject style). Originally: page[number], page[size]

Response

Successful

meta
object
data
object[]
Example:
[
{
"product": "messaging",
"cost": 0.012,
"parts": 12,
"count": 8,
"customer_carrier_fee": 0,
"product_name": "long_code",
"country_iso": "LC",
"direction": "outbound"
},
{
"product": "messaging",
"cost": 0.021,
"parts": 21,
"count": 12,
"customer_carrier_fee": 0,
"product_name": "long_code",
"country_iso": "MP",
"direction": "outbound"
}
]