Check or hold an amount of credit
POST https://weights.fyi/run/v1/reservations
Authorization: Bearer <token> scope: submit
Content-Type: application/json- Available since
- Not available yet: built on 2026-11-14, live with the deploy that carries it.
- Answer time
- synchronous: the answer is read from your account's records at once.
Asks whether an amount of credit can be reserved, or reserves it. With dry_run: true the call only answers: it compares the amount with your available credit and, when correlation names one of your compute plans, with what that plan's lifetime budget has left. Nothing is held or written, so a runner can ask before it starts a wave of work.
Without dry_run the amount is held until you release it with DELETE /v1/reservations. A hold sets credit aside from everything else your account does, and counts against the plan it was taken for. Later calls do not draw it down: each reserves its own usage as before. Release the hold before the work it was held for starts to spend.
Request
| Name | Where | Required | Meaning |
|---|---|---|---|
Authorization | header | yes | Bearer and a token that holds submit. |
amount_usd_micros | body | yes | The amount, a positive integer of micro-USD. |
dry_run | body | no | true to ask only. false when left out. |
correlation | body | no | An object of campaign_id, run_id and stage_id, each optional: the compute plan and stage the amount belongs to. campaign_id is the plan's id, or the campaign id its submission declared under metadata.correlation. |
reservation_id | body | no | Your own id for the hold, 1 to 128 letters, digits and . _ : -. Sending the request again with it finds the hold instead of taking a second one. |
Return value
200 OK for a dry run, with admissible and, when it is false, the reason a hold would be refused with. 201 Created with the hold when one was taken; 200 OK with the same hold when its reservation_id was sent before.
| Field | Meaning |
|---|---|
admissible | A dry run: whether a hold of this amount would be taken now. |
reason, detail | A dry run that is not admissible: credit_exhausted or compute_plan_conflict, and what it rests on. |
credit | A dry run: available_usd_micros and whether it is sufficient. |
plan | The plan the correlation resolved to, with its budget, what is committed, reserved and remaining; null when none matched. |
not_checked | A dry run: what the answer does not cover. A token's daily spend cap is one. |
reservation_id, state, amount_usd_micros, created_at | A hold: its id, held, the amount and when it was taken. |
Errors
| Status | Code | When it happens | What to do |
|---|---|---|---|
400 | invalid_json, invalid_reservation | The body is not what the call takes; field names the part. | Fix the field. |
401 | unauthorized, invalid_token, token_revoked, token_expired | No token, or one that does not work (any more). | Use a valid token. |
402 | credit_exhausted | A hold: your credit, or the plan's budget (reason), does not cover the amount. | Add credit, or reserve less. |
403 | scope_required, account_suspended | The token lacks submit, or the account is suspended. | Use a token with submit. |
409 | compute_plan_conflict | A hold: the plan has ended, or the correlation matches more than one plan. | Name one running plan. |
409 | reservation_conflict | The reservation_id holds another amount, or was released. | Use a new id. |
429 | rate_limited | The token's request rate. | Wait Retry-After. |
503 | reservation_authority_unavailable | This deployment answers dry runs only. | Send dry_run: true. |
Examples
curl -s -X POST https://weights.fyi/run/v1/reservations -H "Authorization: Bearer $WEIGHTS_API_KEY" \
-H "Content-Type: application/json" \
-d '{"amount_usd_micros": 2500000, "dry_run": true, "correlation": {"campaign_id": "rattle-w44", "run_id": "night-run-44"}}'{
"object": "reservation",
"dry_run": true,
"amount_usd_micros": 2500000,
"admissible": true,
"reason": null,
"credit": {"available_usd_micros": 18400000, "sufficient": true},
"plan": {"plan_id": "cp_night_44", "stage_id": null, "state": "executing", "runnable": true,
"budget_usd_micros": 40000000, "committed_usd_micros": 1200000, "reserved_usd_micros": 0,
"remaining_usd_micros": 38800000, "sufficient": true},
"correlation": {"campaign_id": "rattle-w44", "run_id": "night-run-44", "matched": true},
"not_checked": ["token_daily_cap"]
}History
- 2026-11-14: built, with the dry run and the hold.
See also
GET /v1/reservations, DELETE /v1/reservations, GET /v1/usage.