# WritersLogic Spend Ledger

> WritersLogic Spend Ledger is a paid API for AI agents from agents.writerslogic.com, paid per call via x402, $0.005/call, status unknown (last checked 2026-11-18).

Manages a shared budget ledger for a task tree with atomic reserve, commit, and release operations in integer minor currency units

## Facts

- Endpoint: POST https://agents.writerslogic.com/api/v1/spend-ledger?utm_source=zero.xyz
- Price: $0.005/call
- Payment: x402
- Status: unknown
- Last checked: 2026-11-18
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/writerslogic-spend-ledger-8f7c8cd4
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_NioOEyepVdgtLvReEqLkS

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability writerslogic-spend-ledger-8f7c8cd4 -d '<json body>'
```

Example prompt: Open a new spend ledger called 'task:research-42' with a total budget of 50000 minor units of USD, then reserve 5000 units for the next subtask with a 10-minute hold.

## When to prefer this

Use this endpoint when multiple AI agents or workers share a single finite budget and you need atomic, race-condition-free spend control — specifically when two parallel workers must not both claim the last available funds. Prefer this over a simple counter or snapshot approach when you need three-phase reserve/commit/release semantics, idempotent retries via requestId, and automatic expiry of stale holds.

## Known failure modes

- Insufficient remaining budget causes reserve to fail — returns an error indicating how much is available
- Expired reservation ID on commit or release returns not-found or expired error
- Duplicate requestId with different input is rejected with a conflict error
- Invalid ledger name pattern returns a 400 validation error
- TTL exceeds 86400 seconds returns a validation error
- Unknown operation enum value returns a 400 bad request
- Ledger not found when committing or releasing returns a 404 error

## How this service works

Pay-per-call agents settled in USDC on Base via x402. Every response carries a signed provenance envelope.

## Output

Returns the current state of the ledger operation: for 'open', the new ledger details and total budget; for 'reserve', a reservation ID and confirmation that funds are held; for 'commit', the amount recorded as spent; for 'release', confirmation that the hold is freed; for 'status', remaining budget, active holds, and total committed spend.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "op": {
   "enum": [
    "open",
    "reserve",
    "commit",
    "release",
    "status"
   ],
   "type": "string"
  },
  "ledger": {
   "type": "string",
   "pattern": "^[A-Za-z0-9_.:/@+-]{1,200}$",
   "description": "Ledger name, e.g. task:research-42."
  },
  "currency": {
   "type": "string",
   "pattern": "^[A-Z0-9]{2,12}$",
   "description": "open: currency or token code, e.g. USD or USDC."
  },
  "tenantId": {
   "type": "string",
   "pattern": "^[A-Za-z0-9_.-]{1,64}$",
   "description": "Required for API-key callers (namespaced as key:<tenantId>; keep it unguessable). Ignored when a wallet paid: the payer address is the tenant."
  },
  "requestId": {
   "type": "string",
   "pattern": "^[A-Za-z0-9_.:-]{1,128}$",
   "description": "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)."
  },
  "ttlSeconds": {
   "type": "integer",
   "maximum": 86400,
   "minimum": 1,
   "description": "reserve: hold lifetime; default 600."
  },
  "amountMinor": {
   "type": "integer",
   "maximum": 1000000000000000,
   "minimum": 0,
   "description": "reserve: amount to hold. commit: amount actually spent (at most the hold)."
  },
  "budgetMinor": {
   "type": "integer",
   "maximum": 1000000000000000,
   "minimum": 0,
   "description": "open: total budget in minor units."
  },
  "reservationId": {
   "type": "string",
   "pattern": "^[A-Za-z0-9_.:-]{1,128}$"
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json"
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/writerslogic-spend-ledger-8f7c8cd4/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from agents.writerslogic.com](https://www.zero.xyz/host/agents.writerslogic.com/llms.txt)
