Get Work Order Usage
curl --request GET \
--url https://agentgate.mynewapi.com/api/v1/usage/work-orders/{workOrderId} \
--header 'Authorization: Bearer <token>'import requests
url = "https://agentgate.mynewapi.com/api/v1/usage/work-orders/{workOrderId}"
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/work-orders/{workOrderId}', 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/work-orders/{workOrderId}",
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/work-orders/{workOrderId}"
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/work-orders/{workOrderId}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://agentgate.mynewapi.com/api/v1/usage/work-orders/{workOrderId}")
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": {
"totalInputTokens": 123,
"totalOutputTokens": 123,
"totalCachedInputTokens": 123,
"totalCostUsd": 123,
"executionCount": 123,
"workOrderCount": 123,
"totalDurationMs": 123,
"byModel": {},
"periodStart": "<string>",
"periodEnd": "<string>"
}
}Usage
Get Work Order Usage
Get usage summary for a specific work order
GET
/
api
/
v1
/
usage
/
work-orders
/
{workOrderId}
Get Work Order Usage
curl --request GET \
--url https://agentgate.mynewapi.com/api/v1/usage/work-orders/{workOrderId} \
--header 'Authorization: Bearer <token>'import requests
url = "https://agentgate.mynewapi.com/api/v1/usage/work-orders/{workOrderId}"
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/work-orders/{workOrderId}', 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/work-orders/{workOrderId}",
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/work-orders/{workOrderId}"
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/work-orders/{workOrderId}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://agentgate.mynewapi.com/api/v1/usage/work-orders/{workOrderId}")
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": {
"totalInputTokens": 123,
"totalOutputTokens": 123,
"totalCachedInputTokens": 123,
"totalCostUsd": 123,
"executionCount": 123,
"workOrderCount": 123,
"totalDurationMs": 123,
"byModel": {},
"periodStart": "<string>",
"periodEnd": "<string>"
}
}Get Work Order Usage
Returns aggregated usage summary for a specific work order.Request
string
required
The work order ID to get usage for
curl https://agentgate.mynewapi.com/api/v1/usage/work-orders/wo_abc123 \
-H "Authorization: Bearer YOUR_API_KEY"
Response
boolean
required
Indicates if the request was successful
object
required
Work order usage summary
Show properties
Show properties
number
required
Total input tokens used
number
required
Total output tokens used
number
required
Total cached input tokens
number
required
Total estimated cost in USD
number
required
Number of iterations/executions
number
required
Always 1 for single work order
number
required
Total execution duration in milliseconds
object
required
Usage breakdown by model
string
required
First execution timestamp
string
required
Last execution timestamp
Example Response
{
"success": true,
"data": {
"totalInputTokens": 45200,
"totalOutputTokens": 8500,
"totalCachedInputTokens": 28000,
"totalCostUsd": 1.23,
"executionCount": 3,
"workOrderCount": 1,
"totalDurationMs": 125000,
"byModel": {
"claude-sonnet-4-20250514": {
"inputTokens": 45200,
"outputTokens": 8500,
"cachedInputTokens": 28000,
"costUsd": 1.23,
"executionCount": 3
}
},
"periodStart": "2024-01-15T10:30:00.000Z",
"periodEnd": "2024-01-15T10:35:25.000Z"
}
}
Use Cases
- Track costs per task
- Analyze iteration efficiency
- Compare work order complexity
- Per-task billing attribution