On This Page

Home / Cribl as Code/ Cribl API/ API Code Examples/ Billing and FinOps Examples/Get Cumulative Consumption by Contract

Get Cumulative Consumption by Contract

Use the Cribl API to get cumulative credit consumption for an Organization, grouped by contract period.

To get credit grants and credit balance totals, see Get Credit Grants and Statistics. To get per-product and Worker Group infrastructure credit consumption, see Get Monthly or Daily Credit Consumption.

For information about viewing billing and credit consumption data in Cribl, see Track Product Usage and Credit Consumption.

About Code Examples

Code examples use Bearer token authentication. Read the API authentication documentation to learn how to configure authentication. The API Credential that you use to obtain the Bearer token must have the necessary Permissions for the operations in code examples: Billing Reader, Admin, or Owner. Billing API requests return data only for the Organization associated with the API Credential.

Replace the variables in code examples with the corresponding information for your Cribl deployment.

Billing and FinOps API operations are available only on Cribl.Cloud, so this page does not include examples for on-prem deployments.

Code examples do not include all available parameters. For a complete list of parameters for specific endpoints, refer to the documentation in the API Reference.

Get Cumulative Consumption by Contract

Use GET /billing/credits/contracts-utilization to get data about credit consumption grouped by contract period. This example uses the following query parameters to get data for January through June 2026:

  • window: Granularity of points within each contract (monthly).

  • startingOn: Inclusive start of the date range, in ISO 8601 format. In this example, 2026-01-01T00:00:00.000Z includes January 1, 2026.

  • endingBefore: Exclusive end of the date range, in ISO 8601 format. In this example, 2026-07-01T00:00:00.000Z means the last day included in the results is June 30, 2026.

Cribl.Cloud

The response body contains a contracts array. Each element is one contract period and includes the following fields:

  • contractStartDate: Start of the contract period, in ISO 8601 format.

  • contractEndDate: End of the contract period, in ISO 8601 format.

  • items: Array of utilization points for that contract. With window=monthly, each item includes the following fields:

    • date: First day of the monthly aggregation window, in ISO 8601 format.

    • credits: Running total of credits consumed on the contract from contractStartDate through this date. The credits value is not the credits consumed only during the month that starts on date.

{
  "contracts": [
    {
      "contractStartDate": "2025-09-17T00:00:00.000Z",
      "contractEndDate": "2026-09-18T00:00:00.000Z",
      "items": [
        {
          "date": "2026-01-01T00:00:00.000Z",
          "credits": 148288.25
        },
        {
          "date": "2026-02-01T00:00:00.000Z",
          "credits": 193400.4502935743
        },
        {
          "date": "2026-03-01T00:00:00.000Z",
          "credits": 235680.86872625691
        },
        {
          "date": "2026-04-01T00:00:00.000Z",
          "credits": 285311.8913310697
        },
        {
          "date": "2026-05-01T00:00:00.000Z",
          "credits": 332132.2760503561
        },
        {
          "date": "2026-06-01T00:00:00.000Z",
          "credits": 376523.8607666401
        }
      ]
    }
  ]
}