active_balances
Creates, updates, deletes, gets or lists an active_balances resource.
Overview
| Name | active_balances |
| Type | Resource |
| Id | clickhouse.organizations.active_balances |
Fields
The following fields are returned by SELECT queries:
- list
| Name | Datatype | Description |
|---|---|---|
id | string (uuid) | Unique ID of the prepaid balance. |
amount_spent | number | Credits spent from this balance, in ClickHouse Credits (CHCs). (wire: amountSpent) |
expiration_date | string (date-time) | Date the balance expires. ISO-8601, based on the UTC timezone. (wire: expirationDate) |
remaining_prepaid_credits | number | Remaining credits available on this balance, in ClickHouse Credits (CHCs). (wire: remainingPrepaidCredits) |
start_date | string (date-time) | Date the balance became active. ISO-8601, based on the UTC timezone. (wire: startDate) |
total_amount | number | Total credits granted on this balance, in ClickHouse Credits (CHCs). (wire: totalAmount) |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
list | select | organization_id | limit, offset | 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. |
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.
| Name | Datatype | Description |
|---|---|---|
organization_id | string | ClickHouse 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) |
limit | integer | Maximum number of results to return. |
offset | integer | Number of results to skip before returning. |
SELECT examples
- list
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 }}'
;