List Billing Insights
client.Billing.ListInsights(ctx, accountUrn, startDate, endDate, query) (*BillingListInsightsResponse, error)
/v2/billing/{account_urn}/insights/{start_date}/{end_date}
This endpoint returns day-over-day changes in billing resource usage based on nightly invoice items, including total amount, region, SKU, and description for a specified date range. It is important to note that the daily resource usage may not reflect month-end billing totals when totaled for a given month as nightly invoice item estimates do not necessarily encompass all invoicing factors for the entire month.
List Billing Insights
package main
import (
"context"
"fmt"
"time"
"github.com/stainless-sdks/-go"
"github.com/stainless-sdks/-go/option"
)
func main() {
client := gradient.NewClient(
option.WithAccessToken("My Access Token"),
)
response, err := client.Billing.ListInsights(
context.TODO(),
"do:team:12345678-1234-1234-1234-123456789012",
time.Now(),
time.Now(),
gradient.BillingListInsightsParams{
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.CurrentPage)
}
{
"current_page": 1,
"data_points": [
{
"description": "droplet name (c-2-4GiB)",
"group_description": "kubernetes cluster name",
"region": "nyc3",
"sku": "1-DO-DROP-0109",
"start_date": "2025-01-15",
"total_amount": "12.45",
"usage_team_urn": "do:team:12345678-1234-1234-1234-123456789012"
}
],
"total_items": 250,
"total_pages": 3
}Returns Examples
{
"current_page": 1,
"data_points": [
{
"description": "droplet name (c-2-4GiB)",
"group_description": "kubernetes cluster name",
"region": "nyc3",
"sku": "1-DO-DROP-0109",
"start_date": "2025-01-15",
"total_amount": "12.45",
"usage_team_urn": "do:team:12345678-1234-1234-1234-123456789012"
}
],
"total_items": 250,
"total_pages": 3
}