Skip to content
OpenTrain AIOpenTrain AIOpenTrain AIDocs

Ask OpenTrain

Answers from the documentation, with sources.

What would you like to do with OpenTrain?

AI answers can be mistaken. Check the linked sources. Don’t include private account information.

Open app

DEVELOPER DOCUMENTATION

Get Contract Budget

Read a linked contract's budget: funded milestone volume, consumed work, remaining volume, and the OK / LOW / DEPLETED state.

GET/api/partner/v1/contracts/{contractId}/budget

Returns the contract’s current budget: funded milestone volume versus consumed work, and the resulting OK / LOW / DEPLETED state. Read-only and side-effect-free — polling it never emits events. Use it to reconcile after downtime or to render budget status in your UI; the usage-sync guide explains how the numbers are computed.

Requirements: contracts:read scope, and the contract’s job must be referenced by a project link on the calling token’s install.

contractIdstringpathrequired

The OpenTrain contract to read.

contractIdstring

The contract this budget describes.

paymentTypestring | null

PAY_PER_HOUR, PAY_PER_LABEL, or FIXED_PRICE. Determines the volume unit (hours, labels) — FIXED_PRICE contracts never deplete.

statestring

OK (below 80% consumed), LOW (consumedFraction ≥ 0.8), or DEPLETED (≥ 1.0). Always OK for FIXED_PRICE or when nothing is funded.

fundedVolumenumber

Total volume (hours or labels) across funded and completed milestones.

fundedAmountUsdnumber

Total USD across those milestones.

consumedobject

Raw consumption totals across all reported usage and OpenTrain first-party work: seconds, hours, labels, tasks.

consumedVolumenumber

Consumption in the contract’s volume unit — hours for PAY_PER_HOUR, labels for PAY_PER_LABEL.

remainingVolumenumber

fundedVolume - consumedVolume, floored at 0.

consumedFractionnumber

consumedVolume / fundedVolume, rounded to 4 decimals. 0 when nothing is funded.

activeMilestoneobject | null

The current funded milestone (id, name, amountUsd, volume, status), or null if none is active.

lastUsageAtstring | null

ISO 8601 timestamp of the most recent usage report or first-party work record — null if no work has been recorded.

StatuscodeMeaning
401UNAUTHORIZEDMissing, invalid, or revoked token
403FORBIDDENToken lacks contracts:read
404NOT_FOUNDContract not found, or its job is not linked by this install