Skip to main content

Entity Budgets

An entity budget caps the monthly credit spend of a single app or dataset, independent of any per-actor usage profile cap. Budgets reset at the start of each calendar month.

Budget fields

FieldTypeDescription
entityIdUUIDThe app or dataset ID
entityTypestringapp or dataset
monthlyBudgetinteger | nullMonthly cap in credits. null = no cap
creditsUsednumberCredits consumed in the current period
periodStartdateStart of the current monthly period
budgetRemainingnumber | nullmonthlyBudget - creditsUsed (≥ 0), or null when uncapped
budgetPercentnumberPercent of budget consumed (0–100)
isOverBudgetbooleantrue once creditsUsed >= monthlyBudget

GET /api/usage-budgets/{entityType}/{entityId}

Get the budget for an app or dataset. A budget row is created on first access if one does not yet exist (with monthlyBudget: null).

Authentication: Required (session)

Pre-blocks: permission.tenant.superuser

Path Parameters:

ParameterTypeDescription
entityTypestringapp or dataset
entityIdUUIDThe entity's ID

Response:

{
"id": "bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb",
"entityId": "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa",
"entityType": "app",
"monthlyBudget": 2000,
"creditsUsed": 450.25,
"periodStart": "2026-05-01T00:00:00Z",
"hasBudget": true,
"budgetRemaining": 1549.75,
"budgetPercent": 22.5,
"isOverBudget": false,
"createdAt": "2026-05-01T00:00:00Z",
"updatedAt": "2026-05-23T12:00:00Z"
}

The hasBudget, budgetRemaining, budgetPercent, and isOverBudget fields are computed getters serialized alongside the stored columns.


PUT /api/usage-budgets/{entityType}/{entityId}

Set or clear the monthly budget for an app or dataset.

Authentication: Required (session)

Pre-blocks: permission.usage.write

Request Body:

FieldTypeRequiredDescription
monthlyBudgetinteger | nullNoMonthly cap in credits, or null to remove the cap. Omitting the field is accepted as a no-op.

Example Request:

{ "monthlyBudget": 2000 }

Response:

Returns the updated budget object (same shape as GET).