Memory write
POST /api/memoryPersistent key-value memory for agents, scoped to the paying wallet. Your x402 payment IS your authentication: the wallet that pays owns the namespace. No signup, no API keys. Body: {"key":"…","value":any JSON,"ttlSeconds":3600?} to write (optional TTL), or {"key":"…","delete":true} to remove. Add "owner":"0x…" to write into another wallet's namespace you've been granted. Values up to 64KB.
Input
| Field | Type | Description |
|---|---|---|
key * | string | Key to write (max 256 chars) |
value | any | Any JSON value (max 64KB serialized) |
ttlSeconds | number | Optional: auto-expire the key after N seconds |
owner | string | Optional 0x namespace to write into (requires a readwrite grant) |
delete | boolean | Set true to delete the key instead |
Example output
{
"key": "research/task-42",
"bytes": 42,
"updated": 1760000000000,
"expiresAt": 1760086400,
"owner": "0x…",
"persistent": true
}
Try it - see the 402 challenge (free)
curl -i -X POST https://agent402.tools/api/memory \
-H "Content-Type: application/json" \
-d '{"key":"research/task-42","value":{"status":"done","findings":["…"]},"ttlSeconds":86400}'
The response is HTTP 402 Payment Required with exact payment requirements. Any x402 v2 client pays automatically and retries:
Paid call (JavaScript agent)
import { wrapFetchWithPayment } from "@x402/fetch";
import { x402Client } from "@x402/core/client";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";
const client = new x402Client();
registerExactEvmScheme(client, { signer: privateKeyToAccount(KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);
const res = await payFetch("https://agent402.tools/api/memory", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"key": "research/task-42",
"value": {
"status": "done",
"findings": [
"…"
]
},
"ttlSeconds": 86400
}),
});
Related tools
Memory read
GET /api/memoryRead from a wallet-scoped namespace. ?key=… returns the stored value; omit key to list keys. Reads your own namespace by…
Memory counter
POST /api/memory/incrAtomically increment (or decrement) a numeric key and return the new value - a coordination primitive for counters, lock…
Memory compare-and-set
POST /api/memory/casAtomically write (or release) a key only if its current value equals `expected` - the coordination primitive for distrib…