Agents & API

Auth & agent key endpoints

Wallet sign-in with EIP-191, session info and logout, and agent key management.

Last updated 2 min readv1.0

Sessions are signed, httpOnly cookies. Wallet sign-in proves control of an address with a gasless personal_sign; no transaction is sent and no funds move.

Wallet sign-in from a browser (EIP-1193)TypeScript
const [address] = await window.ethereum.request({ method: "eth_requestAccounts" });
const { message } = await fetch("/api/auth/nonce").then((r) => r.json());
const signature = await window.ethereum.request({ method: "personal_sign", params: [message, address] });
const session = await fetch("/api/auth/verify", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ message, signature }),
}).then((r) => r.json());

#GET/api/auth/nonce

Public

Start wallet sign-in. Returns a one-time message (valid for 5 minutes) for the wallet to sign with personal_sign (EIP-191). Signing is gasless and sends no transaction.

Returns{ message }
RequestShell
curl https://$HOST/api/auth/nonce
Response · 200JSON
{ "message": "elysium.example wants you to sign in with your wallet.\n\nSign in to Elysium Morning on Elysium (chain 99901). This request does not trigger a transaction or cost gas.\n\nNonce: f1c09a…\nIssued At: 2026-12-03T11:58:12.000Z" }
Errors
  • 429rate_limitedToo many requests for this key or session; see Retry-After

#POST/api/auth/verify

Public

Finish wallet sign-in by sending the exact message and its signature. The server recovers the address (secp256k1), consumes the nonce and sets the session cookie em_session (httpOnly, signed, 7 days).

FieldTypeDescription
messagestringThe message returned by GET /api/auth/nonce, unchanged
signature0x…65-byte personal_sign signature of message
ReturnsSessionInfo
RequestShell
curl -X POST https://$HOST/api/auth/verify -c cookies.txt -H "Content-Type: application/json" -d @verify.json
Request bodyJSON
{ "message": "…", "signature": "0x5be1…1c" }
Response · 200JSON
{ "authenticated": true, "kind": "wallet", "address": "0x9a3f…c41b", "name": "0x9a3f…c41b", "accountId": "0x9a3f…c41b", "account": { "…": "…" }, "mode": "live" }
Errors
  • 401bad_signatureSignature does not match the message
  • 401nonce_expiredRequest a new nonce
  • 429rate_limitedToo many requests for this key or session; see Retry-After

#GET/api/auth/session

Public

The current session, or authenticated: false. Only wallet sessions exist in live mode.

ReturnsSessionInfo
RequestShell
curl https://$HOST/api/auth/session -b cookies.txt
Response · 200JSON
{ "authenticated": false, "kind": null, "address": null, "name": null, "accountId": null, "account": null, "mode": "live" }

#POST/api/auth/logout

Session

Clear the session cookie.

Returns{ ok }
RequestShell
curl -X POST https://$HOST/api/auth/logout -b cookies.txt
Response · 200JSON
{ "ok": true }

#GET/api/agents

Wallet session

List your agent keys (never the secrets).

ReturnsAgentKey[]
RequestShell
curl https://$HOST/api/agents -b cookies.txt
Response · 200JSON
[ { "id": "key_3m1", "owner": "0x9a3f…c41b", "label": "monitor-bot", "prefix": "em_k3M1q", "scopes": ["mutate"], "ratePerHour": 120,
    "strategyIds": ["0x5c2e…8f2c"], "createdAt": 1796640200000, "lastUsedAt": 1796646712000, "calls": 37, "revoked": false } ]
Errors
  • 401unauthenticatedNo session cookie or agent key

#POST/api/agents

Wallet session (agent keys cannot create keys)

Create an API key for a bot. The secret is returned once; store it in a secret manager. In live mode a key authenticates read-only calls (GET /api/account, GET /api/portfolio); it cannot move funds or mutate. On-chain agent authority is granted separately with ForgeFactory.setAgent from your wallet. At most 10 active keys per account.

FieldTypeDescription
labelstringHuman-readable name
scopesAgentScope[]Any of propose, bid, mutate (recorded on the key; the API does not execute these actions in live mode)
ratePerHournumberHourly call budget for this key
strategyIdsstring[]Strategy allow-list recorded on the key; empty = all strategies you own
Returns{ key: AgentKey, secret }
RequestShell
curl -X POST https://$HOST/api/agents -b cookies.txt -H "Content-Type: application/json" \
  -d '{ "label": "monitor-bot", "scopes": ["mutate"], "ratePerHour": 120, "strategyIds": ["0x5c2e…8f2c"] }'
Request bodyJSON
{ "label": "monitor-bot", "scopes": ["mutate"], "ratePerHour": 120, "strategyIds": ["0x5c2e…8f2c"] }
Response · 200JSON
{ "key": { "id": "key_3m1", "label": "monitor-bot", "prefix": "em_k3M1q", "scopes": ["mutate"], "…": "…" },
  "secret": "em_k3M1q…(shown once)" }
Errors
  • 401unauthenticatedNo session cookie or agent key
  • 400bad_requestUnknown scope, or rate outside the allowed range
  • 409bad_requestAlready 10 active keys; revoke one first

#DELETE/api/agents/:id

Wallet session

Revoke a key immediately.

Returns{ ok }
RequestShell
curl -X DELETE https://$HOST/api/agents/key_3m1 -b cookies.txt
Response · 200JSON
{ "ok": true }
Errors
  • 401unauthenticatedNo session cookie or agent key
  • 404not_foundUnknown key
Something unclear or wrong on this page? Report it.Updated Dec 1, 2026 · v1.0