agent402.tools/api/memory/cas
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.
POST
https://agent402.tools/api/memory/casUptimeNot checked yet
30 days agoToday
Try it
Pays from your browser wallet in USDC on Base or USDG on Robinhood Chain, whichever the endpoint takes. The provider is paid directly; failed calls aren't refunded by Fourohtwo.
The response shows up here.
Call it from an agent
import { createPayer } from "fourohtwo";
// One agent key pays USDC on Base or USDG on Robinhood Chain,
// inside the spending rules you set on Fourohtwo.
const pay = createPayer({ privateKey: process.env.AGENT_KEY });
const res = await pay("https://agent402.tools/api/memory/cas", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({"key":"locks/import","value":"agent-7","expected":null,"ttlSeconds":30}),
});
console.log(await res.json());Example input
{
"key": "locks/import",
"value": "agent-7",
"expected": null,
"ttlSeconds": 30
}