Skip to main content
GET
/
v0
/
costs
/
{id}
/
summary
Query Summary
curl --request GET \
  --url https://api.paygentic.io/v0/costs/{id}/summary \
  --header 'Authorization: Bearer <token>'
import requests

url = "https://api.paygentic.io/v0/costs/{id}/summary"

headers = {"Authorization": "Bearer <token>"}

response = requests.get(url, headers=headers)

print(response.text)
const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};

fetch('https://api.paygentic.io/v0/costs/{id}/summary', 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://api.paygentic.io/v0/costs/{id}/summary",
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://api.paygentic.io/v0/costs/{id}/summary"

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://api.paygentic.io/v0/costs/{id}/summary")
.header("Authorization", "Bearer <token>")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.paygentic.io/v0/costs/{id}/summary")

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
{
  "object": "cost",
  "id": "<string>",
  "name": "<string>",
  "type": "metered",
  "currency": "<string>",
  "totalCost": 123,
  "eventType": "<string>",
  "totalQuantity": 123,
  "groups": [
    {
      "dimensions": {},
      "quantity": 123,
      "cost": 123
    }
  ],
  "timeSeries": [
    {
      "windowStart": "2023-11-07T05:31:56Z",
      "windowEnd": "2023-11-07T05:31:56Z",
      "quantity": 123,
      "cost": 123
    }
  ]
}
{
"message": "The requested resource was not found",
"error": "not_found"
}
{
"message": "The requested resource was not found",
"error": "not_found"
}
{
"message": "The requested resource was not found",
"error": "not_found"
}
{
"message": "The requested resource was not found",
"error": "not_found"
}

Authorizations

Authorization
string
header
required

API key authentication

Path Parameters

id
string
required

The unique identifier of the cost Unique identifier for a cost

Pattern: ^cst_[a-zA-Z0-9]+$

Query Parameters

subject
string

Filter usage to a specific subject (billing entity). When provided, only cost events matching this subject are included. When omitted, usage is aggregated across all subjects for the merchant.

from
string<date-time>
required

Start of the query window (ISO 8601). Required together with 'to'.

to
string<date-time>
required

End of the query window (ISO 8601). Required together with 'from'.

groupBy
string

Comma-separated dimension keys to group results by.

window
enum<string>

Time window granularity for time-series breakdown.

Available options:
MINUTE,
HOUR,
DAY
filterGroupBy
string

JSON-encoded dimension filter (e.g. {"model":"gpt-4","region":"us-east"}). Keys must match those defined in the cost's groupBy configuration. Retrieve the cost first to determine valid keys.

Response

Usage and cost data

object
enum<string>
default:cost
required
Available options:
cost
id
string
required

Unique identifier for a cost

Pattern: ^cst_[a-zA-Z0-9]+$
name
string
required
type
enum<string>
required
Available options:
metered
currency
string
required
totalCost
number | null
required

Total cost for the query window. Null if usage data could not be computed.

eventType
string

CloudEvents type for metered costs.

totalQuantity
number | null

Total usage quantity (metered costs only). Null when usage was not computed.

groups
object[]

Per-group breakdown (present when groupBy is specified).

timeSeries
object[]

Time-series breakdown (present when window is specified).