List Usage Records
curl --request GET \
--url https://agentgate.mynewapi.com/api/v1/usage \
--header 'Authorization: Bearer <token>'import requests
url = "https://agentgate.mynewapi.com/api/v1/usage"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://agentgate.mynewapi.com/api/v1/usage', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://agentgate.mynewapi.com/api/v1/usage",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://agentgate.mynewapi.com/api/v1/usage"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://agentgate.mynewapi.com/api/v1/usage")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://agentgate.mynewapi.com/api/v1/usage")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"success": true,
"data": [
{
"id": "<string>",
"workOrderId": "<string>",
"runId": "<string>",
"iteration": 123,
"model": "<string>",
"inputTokens": 123,
"outputTokens": 123,
"cachedInputTokens": 123,
"costUsd": 123,
"durationMs": 123,
"timestamp": "<string>"
}
]
}Usage
List Usage Records
Get usage records with optional filters
GET
/
api
/
v1
/
usage
List Usage Records
curl --request GET \
--url https://agentgate.mynewapi.com/api/v1/usage \
--header 'Authorization: Bearer <token>'import requests
url = "https://agentgate.mynewapi.com/api/v1/usage"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://agentgate.mynewapi.com/api/v1/usage', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://agentgate.mynewapi.com/api/v1/usage",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://agentgate.mynewapi.com/api/v1/usage"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://agentgate.mynewapi.com/api/v1/usage")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://agentgate.mynewapi.com/api/v1/usage")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"success": true,
"data": [
{
"id": "<string>",
"workOrderId": "<string>",
"runId": "<string>",
"iteration": 123,
"model": "<string>",
"inputTokens": 123,
"outputTokens": 123,
"cachedInputTokens": 123,
"costUsd": 123,
"durationMs": 123,
"timestamp": "<string>"
}
]
}List Usage Records
Returns token usage records with optional filtering by work order, run, model, and date range.Request
Filter by work order ID
Filter by run ID
Filter by model name (e.g.,
claude-sonnet-4-20250514)Start date filter (ISO 8601)
End date filter (ISO 8601)
Maximum number of records to return (1-1000)
Number of records to skip for pagination
curl "https://agentgate.mynewapi.com/api/v1/usage?limit=50&model=claude-sonnet-4-20250514" \
-H "Authorization: Bearer YOUR_API_KEY"
Response
Indicates if the request was successful
Array of usage records
Show properties
Show properties
Unique usage record ID
Associated work order ID
Associated run ID
Iteration number within the run
Model used (e.g.,
claude-sonnet-4-20250514)Number of input tokens
Number of output tokens
Number of cached input tokens
Estimated cost in USD
Execution duration in milliseconds
ISO 8601 timestamp of the usage
Example Response
{
"success": true,
"data": [
{
"id": "usage_abc123",
"workOrderId": "wo_xyz789",
"runId": "run_def456",
"iteration": 1,
"model": "claude-sonnet-4-20250514",
"inputTokens": 15420,
"outputTokens": 3250,
"cachedInputTokens": 8000,
"costUsd": 0.0523,
"durationMs": 45230,
"timestamp": "2024-01-15T10:30:00.000Z"
},
{
"id": "usage_def456",
"workOrderId": "wo_xyz789",
"runId": "run_def456",
"iteration": 2,
"model": "claude-sonnet-4-20250514",
"inputTokens": 18200,
"outputTokens": 2100,
"cachedInputTokens": 12000,
"costUsd": 0.0412,
"durationMs": 32100,
"timestamp": "2024-01-15T10:32:15.000Z"
}
]
}
Use Cases
- Track token usage per work order
- Analyze model costs over time
- Audit execution history
- Generate billing reports
⌘I