Spend ledger with reservations: one budget for a tree of agents
A budget shared by a task tree, in integer minor units. reserve() atomically holds an amount if the remaining budget covers it (expired holds are freed automatically); commit() records what was actually spent, up to the hold; release() frees a hold. These are real reservations, not a snapshot: two workers cannot both reserve the last dollar. It records spending; it does not move money.
What you get
Keeps a swarm of paying sub-agents inside one budget for $0.005 per reservation.
Call it
Send the JSON body below to https://agents.writerslogic.com/api/v1/spend-ledger. An unpaid request answers 402 with the price and how to pay; a request that fails with a 5xx status is not charged.
curl -i -X POST https://agents.writerslogic.com/api/v1/spend-ledger \
-H 'content-type: application/json' \
-d '{"op":"reserve","ledger":"task:research-42","reservationId":"subagent-3-call-1","amountMinor":250,"requestId":"sa3-r1"}'
Input
| Field | Type | Required | Description |
|---|---|---|---|
op | string; one of "open", "reserve", "commit", "release", "status" | yes | |
ledger | string | yes | Ledger name, e.g. task:research-42. |
currency | string | no | open: currency or token code, e.g. USD or USDC. |
budgetMinor | integer; 0..1000000000000000 | no | open: total budget in minor units. |
reservationId | string | no | |
amountMinor | integer; 0..1000000000000000 | no | reserve: amount to hold. commit: amount actually spent (at most the hold). |
ttlSeconds | integer; 1..86400 | no | reserve: hold lifetime; default 600. |
tenantId | string | no | Required for API-key callers (namespaced as key:<tenantId>; keep it unguessable). Ignored when a wallet paid: the payer address is the tenant. |
requestId | string | no | Caller-chosen id for this mutation. A retry with the same id and same input returns the stored response (24 h) instead of applying twice; the same id with different input is rejected. Send one on every mutation you may retry: without it a retry is applied again (fleet-memory record appends a duplicate; a repeated spend-ledger commit or release answers NO_HOLD because the first call already took effect). |
Example request body
{
"op": "reserve",
"ledger": "task:research-42",
"reservationId": "subagent-3-call-1",
"amountMinor": 250,
"requestId": "sa3-r1"
}
Result
The response is { "data": ..., "_provenance": ... }. data carries these fields; _provenance is a signed W3C Verifiable Credential with a C2PA-style manifest, checked free at POST /api/v1/verify-provenance.
| Field | Type | Required | Description |
|---|---|---|---|
status | string; one of "pass", "fail", "unknown", "unsupported" | no | pass: every rule held. fail: a rule was violated (see witnesses). unknown: the input lacks the evidence to decide. unsupported: outside what this engine covers. Missing evidence is never a pass. |
op | string | no | |
currency | one of | no | |
budgetMinor | one of | no | |
committedMinor | one of | no | |
reservedMinor | one of | no | Sum of live holds. |
availableMinor | one of | no | |
reservation | one of | no | |
witnesses | array<object> | no | |
versions | object | no | Every semantic dependency of this answer (engine, tables and their as-of dates, tokenizer, calendar, rounding profile). |
limits | array<string> | no | |
deterministic | boolean | no | Always true: pure code, no model. |
Pay and connect
Available through: x402 (USDC on Base), MCP. MCP clients reach it through the agent-coordination-kit package.
Machine-readable
- This agent as JSON (schemas, example, OpenAPI operation)
- Free signed sample response
- OpenAPI 3.1 · Catalog · Index of every agent