Skip to main content

active_balances

Creates, updates, deletes, gets or lists an active_balances resource.

Overview

Nameactive_balances
TypeResource
Idclickhouse.organizations.active_balances

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
idstring (uuid)Unique ID of the prepaid balance.
amount_spentnumberCredits spent from this balance, in ClickHouse Credits (CHCs). (wire: amountSpent)
expiration_datestring (date-time)Date the balance expires. ISO-8601, based on the UTC timezone. (wire: expirationDate)
remaining_prepaid_creditsnumberRemaining credits available on this balance, in ClickHouse Credits (CHCs). (wire: remainingPrepaidCredits)
start_datestring (date-time)Date the balance became active. ISO-8601, based on the UTC timezone. (wire: startDate)
total_amountnumberTotal credits granted on this balance, in ClickHouse Credits (CHCs). (wire: totalAmount)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
listselectorganization_idlimit, offsetThis endpoint is in beta. API contract is stable, and no breaking changes are expected in the future. <br /><br /> Returns the active prepaid credit balances for the organization, each with its own balance ID and remaining credits, along with the total remaining credits across all active balances. A balance is active when it has started, has not expired, and has credits remaining. Balances are ordered by expiration date, soonest first, and the returned page is capped at limit (default and maximum 100). When totalCount exceeds the number of returned balances, page with limit/offset to retrieve them all. totalRemainingPrepaidCredits always covers every active balance, not just the returned page.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
organization_idstringClickHouse Cloud organization ID. Resolved from the CLICKHOUSE_ORG_ID environment variable when it is set (x-stackQL-envVar); otherwise it must be supplied on every query as WHERE organization_id = <uuid>. A WHERE value always takes precedence over the environment. (x-stackQL-envVar: CLICKHOUSE_ORG_ID)
limitintegerMaximum number of results to return.
offsetintegerNumber of results to skip before returning.

SELECT examples

This endpoint is in beta. API contract is stable, and no breaking changes are expected in the future. <br /><br /> Returns the active prepaid credit balances for the organization, each with its own balance ID and remaining credits, along with the total remaining credits across all active balances. A balance is active when it has started, has not expired, and has credits remaining. Balances are ordered by expiration date, soonest first, and the returned page is capped at limit (default and maximum 100). When totalCount exceeds the number of returned balances, page with limit/offset to retrieve them all. totalRemainingPrepaidCredits always covers every active balance, not just the returned page.

SELECT
id,
amount_spent,
expiration_date,
remaining_prepaid_credits,
start_date,
total_amount
FROM clickhouse.organizations.active_balances
WHERE organization_id = '{{ organization_id }}' -- required unless CLICKHOUSE_ORG_ID is set
AND limit = '{{ limit }}'
AND offset = '{{ offset }}'
;