# WritersLogic Distributed Lease / Fencing Token API

> WritersLogic Distributed Lease / Fencing Token API 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).

Coordinates multi-agent task ownership via named resource leases with monotonically increasing fencing tokens to prevent stale writes from expired holders.

## Facts

- Endpoint: POST https://agents.writerslogic.com/api/v1/lease?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-distributed-lease-fencing-token-api-1fd6c62e
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_kq8UZotS8uGi4bG0LKXsJ

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-distributed-lease-fencing-token-api-1fd6c62e -d '<json body>'
```

Example prompt: Acquire the lease on resource 'invoice:INV-1009' for my worker 'agent-7' for 60 seconds so I can process it exclusively — give me back the fencing token and reject any writes from expired holders.

## When to prefer this

Use this endpoint when you need lightweight, time-bounded mutual exclusion across a fleet of AI agents — particularly when you need fencing tokens to prevent stale writes to downstream stores. Prefer this over application-level locking when agents are distributed and may crash or stall, since renew-failure naturally detects lost leases. It is not a full distributed-systems guarantee (e.g. no Paxos/Raft consensus) but is sufficient for agent-fleet task coordination where the downstream store can enforce fencing token ordering.

## Known failure modes

- Renew fails if the lease has expired, signaling the holder it has lost ownership
- Acquire fails if the resource is currently held by another agent and the lease is still valid
- Token mismatch: providing a stale or incorrect fencing token for renew/release is rejected
- Invalid resource name pattern causes schema validation error
- tenantId missing for API-key callers results in rejection
- requestId collision with different input returns an error (same id, different payload)
- TTL out of range (0 or >3600) is rejected by schema validation

## 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 lease state including the fencing token (a strictly increasing integer), the current holder, the resource name, and the lease expiry time. For acquire operations, a new larger token is issued; for renew, the same token is returned with extended expiry; for release, confirmation of release; for get, the current holder and token without side effects.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "op": {
   "enum": [
    "acquire",
    "renew",
    "release",
    "get"
   ],
   "type": "string"
  },
  "token": {
   "type": "integer",
   "minimum": 1,
   "description": "Fencing token from acquire; required for renew and release."
  },
  "holder": {
   "type": "string",
   "maxLength": 128,
   "minLength": 1,
   "description": "Your worker id. Required for acquire, renew and release."
  },
  "resource": {
   "type": "string",
   "pattern": "^[A-Za-z0-9_.:/@+-]{1,200}$",
   "description": "Task or resource name, e.g. invoice:INV-1009 or deploy:prod."
  },
  "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": 3600,
   "minimum": 1,
   "description": "Lease length; default 30."
  }
 }
}
```

## Response schema (JSON Schema)

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

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/writerslogic-distributed-lease-fencing-token-api-1fd6c62e/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)
