Core concepts
Balance and spend
Read your workspace's credit balance and ledger from the API, see what each call cost, and handle a balance that cannot pay.
Three things tell you where your credits stand: the balance, the ledger of every credit in and out, and the cost reported on each answer. All of them are free to read and need the dsp.usage.read scope, except the cost on each answer, which every billed call reports.
The balance#
GEThttps://api.sproutsdata.ai/v1/credits returns the workspace's wallet:
curl "https://api.sproutsdata.ai/v1/credits" -H "X-API-Key: $SPROUTS_API_KEY"| Field | What it holds |
|---|---|
available | What can be spent now. This is the figure to check before spending. |
balance | Credits in the wallet. Negative while the workspace is in debt. |
reserved | Credits set aside for work in progress, such as agent runs that have not finished. |
debt | Credits owed after a refund or a dispute. Debt is repaid first from new credits. |
status | active, or frozen when Sprouts Data has put the workspace's credits on hold. |
has_paid | Whether the workspace has ever bought credits. Whole records in lists and exports need it. |
rate_card | The name of the price list your calls are charged by. |
stale | true when the ledger could not be reached just now: the figures are the last ones read, and may be behind. |
The ledger#
GEThttps://api.sproutsdata.ai/v1/credits/transactions lists every credit in
and out of the workspace, newest first. It is paged with a query cursor: limit
defaults to 50 and can be up to 100, and you pass next_cursor back as cursor
until it is null (see Pagination).
curl "https://api.sproutsdata.ai/v1/credits/transactions?limit=20" -H "X-API-Key: $SPROUTS_API_KEY"Each entry has an id, a kind, the signed amount in credits (positive for credits in, negative for credits spent), the balance_after it, and when it happened (created_at). A charge names the billed action; a grant of free credits names its source, such as signup or referral.
The ledger records credits. To see which call made a charge, with its request and results, use Usage history.
The cost of each call#
You don't need to call the ledger to know what a call cost. Every data answer reports it in meta:
meta.credits_charged: what this call cost, in credits.0when nothing was charged, for example an empty answer or a retry already paid for.nullfor an operation that is not metered.meta.credits_balance: what the workspace can spend after this call, excluding credits reserved for agent runs in progress.nullwhen it isn't known just now;GET /v1/creditsalways has it.
A few answers report their cost elsewhere:
| Answer | Where the cost is |
|---|---|
| A CSV export, made at once | The X-Credits-Charged response header. |
| Adding items to a list, reading a list's items | A top-level credits_charged field. |
| An agent run or an enrichment job | credits_charged on the run or job, settled when it ends. |
| A tool run | meta.credits_charged on the run. |
To know a cost before you spend it, ask for a quote with POST /v1/credits/quote. See Credits and usage.
When the balance cannot pay#
A billed call that the available balance cannot cover is refused with 402 credits.insufficient before anything runs, and nothing is charged:
{
"type": "https://dashboard.sproutsdata.ai/errors/credits-insufficient",
"title": "Not enough credits",
"status": 402,
"code": "credits.insufficient",
"detail": "This needs 7.7 credits; 2.5 are available.",
"instance": "/v1/search",
"request_id": "3f9c2a7e1b4d4c8e9a51d2e6f0b7c3a9",
"next_step": "Top up the workspace's credits in the dashboard, then retry.",
"extra": {
"available_credits": 2.5,
"required_credits": 7.7
}
}extra.required_credits and extra.available_credits tell you how far short the balance is. Either send a smaller request (a lower limit, fewer records) that fits, or have credits bought in the dashboard and send it again. Work that sets its maximum aside first (agent runs, enrichment, tool runs) is refused when that maximum does not fit, even if the final cost would have been lower.
If status is frozen, billed calls answer 402 credits.wallet_frozen instead: contact Sprouts Data support.
Buying credits explains who can add credits and how.
Watching your balance#
To avoid running out in the middle of work:
- Read
meta.credits_balancefrom each answer and alert when it falls below a threshold you choose. - Check
availablewithGET /v1/creditsbefore a large batch, and quote the batch withPOST /v1/credits/quote. - Give each integration its own key, so Usage history and the dashboard's Usage page show what each one spends.