Auth & agent key endpoints
Wallet sign-in with EIP-191, session info and logout, and agent key management.
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.
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
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.
{ message }curl https://$HOST/api/auth/nonce{ "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" }- 429
rate_limitedToo many requests for this key or session; seeRetry-After
#POST/api/auth/verify
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).
| Field | Type | Description |
|---|---|---|
message | string | The message returned by GET /api/auth/nonce, unchanged |
signature | 0x… | 65-byte personal_sign signature of message |
SessionInfocurl -X POST https://$HOST/api/auth/verify -c cookies.txt -H "Content-Type: application/json" -d @verify.json{ "message": "…", "signature": "0x5be1…1c" }{ "authenticated": true, "kind": "wallet", "address": "0x9a3f…c41b", "name": "0x9a3f…c41b", "accountId": "0x9a3f…c41b", "account": { "…": "…" }, "mode": "live" }- 401
bad_signatureSignature does not match the message - 401
nonce_expiredRequest a new nonce - 429
rate_limitedToo many requests for this key or session; seeRetry-After
#GET/api/auth/session
The current session, or authenticated: false. Only wallet sessions exist in live mode.
SessionInfocurl https://$HOST/api/auth/session -b cookies.txt{ "authenticated": false, "kind": null, "address": null, "name": null, "accountId": null, "account": null, "mode": "live" }#POST/api/auth/logout
Clear the session cookie.
{ ok }curl -X POST https://$HOST/api/auth/logout -b cookies.txt{ "ok": true }#GET/api/agents
List your agent keys (never the secrets).
AgentKey[]curl https://$HOST/api/agents -b cookies.txt[ { "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 } ]- 401
unauthenticatedNo session cookie or agent key
#POST/api/agents
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.
| Field | Type | Description |
|---|---|---|
label | string | Human-readable name |
scopes | AgentScope[] | Any of propose, bid, mutate (recorded on the key; the API does not execute these actions in live mode) |
ratePerHour | number | Hourly call budget for this key |
strategyIds | string[] | Strategy allow-list recorded on the key; empty = all strategies you own |
{ key: AgentKey, secret }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"] }'{ "label": "monitor-bot", "scopes": ["mutate"], "ratePerHour": 120, "strategyIds": ["0x5c2e…8f2c"] }{ "key": { "id": "key_3m1", "label": "monitor-bot", "prefix": "em_k3M1q", "scopes": ["mutate"], "…": "…" },
"secret": "em_k3M1q…(shown once)" }- 401
unauthenticatedNo session cookie or agent key - 400
bad_requestUnknown scope, or rate outside the allowed range - 409
bad_requestAlready 10 active keys; revoke one first
#DELETE/api/agents/:id
Revoke a key immediately.
{ ok }curl -X DELETE https://$HOST/api/agents/key_3m1 -b cookies.txt{ "ok": true }- 401
unauthenticatedNo session cookie or agent key - 404
not_foundUnknown key