v1

latestOpenAPI 3.1.02026-08-042453938.9 KB
Charges

Estimate costs from existing usage

Estimate costs from existing usage events without creating charges.

Queries usage events in the specified period and calculates what they would cost based on pricing plans. Supports custom pricing overrides for "what-if" scenarios.

Use cases:

  • Budget planning and forecasting
  • Cost allocation previews
  • Retroactive pricing analysis
  • Comparing pricing strategies

The response includes per-usage-type line items with quantity, unit price, and estimated cost. Notes indicate which usage types used custom pricing, default pricing, or had no pricing plan available.

post/v1/cost-estimate/from-usage

Request body

customerIdstring

Filter to a specific customer. Omit to estimate across all customers.

periodStartstring date-time required

Start of the estimation period (ISO 8601)

periodEndstring date-time required

End of the estimation period (ISO 8601)

defaultUnitPricestring

Default unit price (USDC) for usage types without a pricing plan

includeChargedEventsboolean

Include events that already have charges (default: true)

usageTypesstring[]

Filter to specific usage types

customPricingobject

Custom pricing overrides: usageType → unitPrice. Takes precedence over DB pricing plans.

Example request

{
  "periodStart": "2024-01-01T00:00:00.000Z",
  "periodEnd": "2024-01-31T23:59:59.999Z",
  "defaultUnitPrice": "0.001",
  "customPricing": {
    "api_call": "0.005",
    "token": "0.0001"
  }
}

Response

Cost estimate with line item breakdown

businessIdstring
customerIdstring
periodStartstring
periodEndstring
subtotalUsdcstring
estimatedTotalUsdcstring
currency'USDC'
isEstimatetrue
generatedAtstring date-time
notesstring[]