List spend logs
Lists the requests the instance served with its keys, newest first, one page at a time. The window defaults to the last 24 hours and spans at most 31 days. A row appears a few seconds after its request. The instance must be ready; otherwise the request answers 409.
GET
/
agent_gateways
/
{instance_id}
/
spend_logs
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.agentGateways.retrieveSpendLogs('instance_id');
console.log(response.data);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.agent_gateways.retrieve_spend_logs(
"instance_id",
)
print(response.data)
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.AgentGateways.GetSpendLogs(
context.TODO(),
"instance_id",
)
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.agentGateways().retrieveSpendLogs("instance_id");
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
response = telnyx.agent_gateways.retrieve_spend_logs("instance_id")
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->agentGateways->retrieveSpendLogs(
'instance_id',
);
var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx agent-gateways retrieve-spend-logs \
--api-key 'My API Key' \
--instance-id ecffdf4b-93ea-4a7b-8295-51dfd2077996curl --request GET \
--url https://api.telnyx.com/v2/agent_gateways/{instance_id}/spend_logs \
--header 'Authorization: Bearer <token>'{
"data": [
{
"id": "chatcmpl-1c0032cc-3d9f-439f-af62-b7f2b6623da4",
"key_id": "5f1c3a0e9b7d4c2a8e6f0b1d3c5a7e9f2b4d6c8a0e1f3a5c7e9b1d3f5a7c9e0b",
"team_id": "0b6c5d4e-3f2a-4b1c-9d8e-7f6a5b4c3d2e",
"model": "zai-org/GLM-5.3-Flash",
"operation": "acompletion",
"status": "success",
"spend": 0.00027747,
"prompt_tokens": 22,
"completion_tokens": 610,
"total_tokens": 632,
"started_at": "2026-10-21T19:41:02.114000Z",
"ended_at": "2026-10-21T19:41:04.879000Z",
"duration_ms": 2765
}
],
"meta": {
"total_results": 1,
"page_number": 1,
"page_size": 50,
"total_pages": 1,
"total_results_capped": false
}
}{
"errors": [
{
"code": "10033",
"title": "Value outside of range",
"detail": "The value is outside of allowed range the start to 31 days after it",
"source": {
"parameter": "end"
},
"meta": {
"url": "https://developers.telnyx.com/docs/overview/errors/10033"
}
}
]
}{
"errors": [
{
"code": "10009",
"title": "Authentication failed",
"detail": "The required authentication headers were either invalid or not included in the request.",
"meta": {
"url": "https://developers.telnyx.com/docs/overview/errors/10009"
}
}
]
}{
"errors": [
{
"code": "10005",
"title": "Resource not found",
"detail": "The requested resource or URL could not be found.",
"meta": {
"url": "https://developers.telnyx.com/docs/overview/errors/10005"
}
}
]
}{
"errors": [
{
"code": "99901",
"title": "Instance not ready",
"detail": "The instance is not ready; its engine is not running."
}
]
}{
"errors": [
{
"code": "99903",
"title": "Engine unavailable",
"detail": "The instance's engine did not answer; try again shortly."
}
]
}Authorizations
Telnyx API key
Path Parameters
The Agent Gateway's id.
Query Parameters
The page to return, counting from 1.
Required range:
x >= 1Results per page.
Required range:
1 <= x <= 100The window's start, an RFC 3339 timestamp with an offset. Defaults to 24 hours before end.
The window's end, an RFC 3339 timestamp with an offset. Defaults to now.
Only the requests made with this key.
Pattern:
^[0-9a-f]{64}$Only the requests made with this team's keys.
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.agentGateways.retrieveSpendLogs('instance_id');
console.log(response.data);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.agent_gateways.retrieve_spend_logs(
"instance_id",
)
print(response.data)
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.AgentGateways.GetSpendLogs(
context.TODO(),
"instance_id",
)
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.agentGateways().retrieveSpendLogs("instance_id");
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
response = telnyx.agent_gateways.retrieve_spend_logs("instance_id")
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->agentGateways->retrieveSpendLogs(
'instance_id',
);
var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx agent-gateways retrieve-spend-logs \
--api-key 'My API Key' \
--instance-id ecffdf4b-93ea-4a7b-8295-51dfd2077996curl --request GET \
--url https://api.telnyx.com/v2/agent_gateways/{instance_id}/spend_logs \
--header 'Authorization: Bearer <token>'{
"data": [
{
"id": "chatcmpl-1c0032cc-3d9f-439f-af62-b7f2b6623da4",
"key_id": "5f1c3a0e9b7d4c2a8e6f0b1d3c5a7e9f2b4d6c8a0e1f3a5c7e9b1d3f5a7c9e0b",
"team_id": "0b6c5d4e-3f2a-4b1c-9d8e-7f6a5b4c3d2e",
"model": "zai-org/GLM-5.3-Flash",
"operation": "acompletion",
"status": "success",
"spend": 0.00027747,
"prompt_tokens": 22,
"completion_tokens": 610,
"total_tokens": 632,
"started_at": "2026-10-21T19:41:02.114000Z",
"ended_at": "2026-10-21T19:41:04.879000Z",
"duration_ms": 2765
}
],
"meta": {
"total_results": 1,
"page_number": 1,
"page_size": 50,
"total_pages": 1,
"total_results_capped": false
}
}{
"errors": [
{
"code": "10033",
"title": "Value outside of range",
"detail": "The value is outside of allowed range the start to 31 days after it",
"source": {
"parameter": "end"
},
"meta": {
"url": "https://developers.telnyx.com/docs/overview/errors/10033"
}
}
]
}{
"errors": [
{
"code": "10009",
"title": "Authentication failed",
"detail": "The required authentication headers were either invalid or not included in the request.",
"meta": {
"url": "https://developers.telnyx.com/docs/overview/errors/10009"
}
}
]
}{
"errors": [
{
"code": "10005",
"title": "Resource not found",
"detail": "The requested resource or URL could not be found.",
"meta": {
"url": "https://developers.telnyx.com/docs/overview/errors/10005"
}
}
]
}{
"errors": [
{
"code": "99901",
"title": "Instance not ready",
"detail": "The instance is not ready; its engine is not running."
}
]
}{
"errors": [
{
"code": "99903",
"title": "Engine unavailable",
"detail": "The instance's engine did not answer; try again shortly."
}
]
}