{"uid":"cap_kq8UZotS8uGi4bG0LKXsJ","slug":"writerslogic-distributed-lease-fencing-token-api-1fd6c62e","name":"WritersLogic Distributed Lease / Fencing Token API","description":"Pay-per-call agents settled in USDC on Base via x402. Every response carries a signed provenance envelope.","url":"https://agents.writerslogic.com/api/v1/lease?utm_source=zero.xyz","method":"POST","headers":{},"bodySchema":{"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."}}},"responseSchema":{"type":"json"},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.005","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.005/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.005","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.005","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_JFm2vXjUvTojxd8JomYin","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.005","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Coordinates multi-agent task ownership via named resource leases with monotonically increasing fencing tokens to prevent stale writes from expired holders.","exampleAgentPrompt":"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.","exampleUseCases":[{"title":"Exclusive job processing in agent fleet","prompt":"Before my agent starts processing order 'order:ORD-5521', acquire a 120-second lease on it for worker 'fulfillment-agent-3' so no other agent in the fleet picks it up at the same time."},{"title":"Renewing a long-running deployment lock","prompt":"My agent 'deploy-bot-1' is still working on 'deploy:prod' and needs to extend the lease — renew it for another 60 seconds using fencing token 42 so it doesn't expire mid-deployment."},{"title":"Releasing a resource after task completion","prompt":"Agent 'scraper-worker-2' just finished processing 'crawl:site-abc' — release the lease using fencing token 17 so the next agent in queue can pick it up."}],"resultDescription":"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.","failureModes":["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"],"whenToPreferThis":"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.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-11-18T18:40:17.625Z","isFirstParty":false,"canonicalSlug":"writerslogic-distributed-lease-fencing-token-api-1fd6c62e"}