Get a usage summary by product
List the products the account has usage on in the time range, with the record count and the total cost in each currency. Products with no usage are omitted. Use it to find which products to request from the usage reports endpoint.
Provide either date_range or both start_date and end_date. The time range can span at most 31 days. Usage is counted by the hour, so the range is widened to whole UTC hours, and meta returns the range that was counted.
GET
/
usage_reports
/
summary
JavaScript
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});
const response = await client.usageReports.retrieveSummary();
console.log(response.meta);import os
from telnyx import Telnyx
client = Telnyx(
api_key=os.environ.get("TELNYX_API_KEY"), # This is the default and can be omitted
)
response = client.usage_reports.retrieve_summary()
print(response.meta)
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"),
)
response, err := client.UsageReports.GetSummary(context.TODO())
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Data)
}
package com.telnyx.sdk.example;
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
var response = client.usageReports().retrieveSummary();
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
response = telnyx.usage_reports.retrieve_summary
puts(response)<?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 {
$response = $client->usageReports->retrieveSummary();
var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx usage-reports retrieve-summary \
--api-key 'My API Key'curl --request GET \
--url https://api.telnyx.com/v2/usage_reports/summary \
--header 'Authorization: Bearer <token>'{
"meta": {
"start_time": "2024-02-01T00:00:00.000Z",
"end_time": "2024-03-01T00:00:00.000Z"
},
"data": [
{
"product": "messaging",
"record_count": 1520,
"costs": [
{
"currency": "USD",
"amount": 12.345
}
]
},
{
"product": "sip-trunking",
"record_count": 8734,
"costs": [
{
"currency": "EUR",
"amount": 3.2
},
{
"currency": "USD",
"amount": 41.0625
}
]
},
{
"product": "verify-2fa",
"record_count": 96,
"costs": []
}
]
}{
"errors": [
{
"code": "10004",
"title": "Invalid date/time interval.",
"detail": "Start/end combination should be provided,having end date equal or greater than start; and start/end date difference less or equals to 31 days in any chronology units.",
"source": {
"parameter": "start_date/end_date"
}
}
]
}{
"errors": [
{
"code": "10007",
"title": "Unexpected error",
"detail": "The usage summary could not be computed. Please retry later."
}
]
}Authorizations
Headers
Query Parameters
Was this page helpful?
JavaScript
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});
const response = await client.usageReports.retrieveSummary();
console.log(response.meta);import os
from telnyx import Telnyx
client = Telnyx(
api_key=os.environ.get("TELNYX_API_KEY"), # This is the default and can be omitted
)
response = client.usage_reports.retrieve_summary()
print(response.meta)
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"),
)
response, err := client.UsageReports.GetSummary(context.TODO())
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Data)
}
package com.telnyx.sdk.example;
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
var response = client.usageReports().retrieveSummary();
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
response = telnyx.usage_reports.retrieve_summary
puts(response)<?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 {
$response = $client->usageReports->retrieveSummary();
var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx usage-reports retrieve-summary \
--api-key 'My API Key'curl --request GET \
--url https://api.telnyx.com/v2/usage_reports/summary \
--header 'Authorization: Bearer <token>'{
"meta": {
"start_time": "2024-02-01T00:00:00.000Z",
"end_time": "2024-03-01T00:00:00.000Z"
},
"data": [
{
"product": "messaging",
"record_count": 1520,
"costs": [
{
"currency": "USD",
"amount": 12.345
}
]
},
{
"product": "sip-trunking",
"record_count": 8734,
"costs": [
{
"currency": "EUR",
"amount": 3.2
},
{
"currency": "USD",
"amount": 41.0625
}
]
},
{
"product": "verify-2fa",
"record_count": 96,
"costs": []
}
]
}{
"errors": [
{
"code": "10004",
"title": "Invalid date/time interval.",
"detail": "Start/end combination should be provided,having end date equal or greater than start; and start/end date difference less or equals to 31 days in any chronology units.",
"source": {
"parameter": "start_date/end_date"
}
}
]
}{
"errors": [
{
"code": "10007",
"title": "Unexpected error",
"detail": "The usage summary could not be computed. Please retry later."
}
]
}