{"slug":"agent402-tools-api-memory-cas-ffff65","title":"Atomically write (or release) a key only if its current value equals `expected`","host":"agent402.tools","method":"POST","resource":"https://agent402.tools/api/memory/cas","category":"market","description":"Atomically write (or release) a key only if its current value equals `expected` - the coordination primitive for distributed locks and optimistic concurrency across agents. Acquire a lock: expected=null + a value + ttlSeconds. Release it: expected=<your token> with no value (deletes on match). Updat","price_listed":0.001,"price_asked":null,"state":"effects","state_label":"Not tested: has real-world effects","checks_7d":0,"answered_7d":0,"latency_ms_median":null,"reported_calls_30d":7,"reported_payers_30d":3,"networks":["eip155:10","eip155:1329","eip155:137","eip155:143","eip155:42161","eip155:42220","eip155:43114","eip155:4663","eip155:8453"],"badge":"unverified","paid_checks_7d":0,"paid_ok_7d":0,"example_input":{"body":{"expected":null,"key":"locks/import","ttlSeconds":30,"value":"agent-7"},"bodyType":"json","method":"POST","type":"http"},"output_schema":{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{"input":{"additionalProperties":false,"properties":{"body":{"properties":{"expected":{"description":"Required current value to match (null or omitted = key absent/expired)"},"key":{"description":"Key to conditionally write","type":"string"},"owner":{"description":"Optional 0x namespace (requires a readwrite grant)","type":"string"},"ttlSeconds":{"description":"Optional TTL for the written value (lease for locks)","type":"number"},"value":{"description":"New value to set on match; omit to DELETE on match (lock release)"}},"required":["key"]},"bodyType":{"enum":["json","form-data","text"],"type":"string"},"method":{"enum":["POST"],"type":"string"},"type":{"const":"http","type":"string"}},"required":["type","method","bodyType","body"],"type":"object"},"output":{"properties":{"example":{"properties":{"expiresAt":{"type":"integer"},"key":{"type":"string"},"owner":{"type":"string"},"swapped":{"type":"boolean"},"value":{"type":"string"}},"required":["key","swapped","value","owner","expiresAt"],"type":"object"},"type":{"type":"string"}},"required":["type"],"type":"object"}},"required":["input"],"type":"object"},"history":[],"description_full":"Atomically write (or release) a key only if its current value equals `expected` - the coordination primitive for distributed locks and optimistic concurrency across agents. Acquire a lock: expected=null + a value + ttlSeconds. Release it: expected=<your token> with no value (deletes on match). Update safely: expected=<old>, value=<new>. Returns whether it swapped and the current value.","last_updated":"2026-09-06T00:15:43.607Z","schemes":["exact"]}