/margin/:userPlinth margin number for a wallet. Returns collateral, required margin, buying power, paused state.
curl -H "X-PAYMENT: $X402_TOKEN" \
https://codex.useatrium.me/margin/0xYourWalletCodex API
Codex worker · checking…Codex is the read-side API surface for Atrium. Eight endpoints expose margin, positions, risk decomposition, venue health, agent performance, research backtests, proof-of-reserves attestations, and option Greeks. Every response is HMAC-signed via X-Codex-Key-Id; every request pays in USDC via x402.
Get an x402 payment token from your wallet, send it as the X-PAYMENT header. Codex verifies on-chain settlement before serving the response.
# 1. Generate an x402 token via your wallet's x402 SDK
X402_TOKEN=$(./gen-x402.sh 0.001 0x...codex-address)
# 2. Call any Codex endpoint with the token
curl -H "X-PAYMENT: $X402_TOKEN" \
https://codex.useatrium.me/margin/0xYourWallet
# Response:
# {
# "marginUsd": "12378422.00",
# "requiredMarginUsd": "4759843.21",
# "buyingPowerUsd": "7618578.79",
# "paused": false,
# "source": "plinth",
# "asOfBlock": 270918668
# }
# Headers: X-Codex-Key-Id: 1
# X-Codex-Signature: 0xabc...Calls the local testnet read route that backs this endpoint, so it needs no x402 payment. Production Codex requires the X-PAYMENT header shown in the curl example for each endpoint.
X-Codex-Signature is the SHA256 HMAC of the response body; X-Codex-Key-Id is the rotation index so clients verify with the correct key.X-Idempotency-Key (any UUID) for safe retries on non-pure reads. Cached for 24h.Retry-After header./margin/:userPlinth margin number for a wallet. Returns collateral, required margin, buying power, paused state.
curl -H "X-PAYMENT: $X402_TOKEN" \
https://codex.useatrium.me/margin/0xYourWallet/positions/:userOpen positions across every Portico-whitelisted venue. Includes notional, entry, mark (when oracle live), unrealised PnL.
curl -H "X-PAYMENT: $X402_TOKEN" \
https://codex.useatrium.me/positions/0xYourWallet/risk/:userPer-venue risk decomposition. Maps each venue to its share of total required margin + haircut applied.
curl -H "X-PAYMENT: $X402_TOKEN" \
https://codex.useatrium.me/risk/0xYourWallet/venuesLive venue health table. Per-venue: deployed address, paused state, last oracle ts, notional cap remaining this block.
curl -H "X-PAYMENT: $X402_TOKEN" https://codex.useatrium.me/venues
/agents/:id/perfAgent performance snapshot. 7/30/90 day PnL, total actions, failure rate, deboost tier, mandate count.
curl -H "X-PAYMENT: $X402_TOKEN" https://codex.useatrium.me/agents/augur/perf
/backtest/:strategyReplay a published ResearchAttestation backtest. Returns IPFS notebook URL + delta bps + trade count.
curl -H "X-PAYMENT: $X402_TOKEN" https://codex.useatrium.me/backtest/mean-reversion-v1
/attestation/:walletLantern proof-of-reserves Merkle proof for a wallet. Returns latest root + the inclusion path.
curl -H "X-PAYMENT: $X402_TOKEN" \
https://codex.useatrium.me/attestation/0xYourWallet/options/:symbolStoa Black-Scholes Greeks for a tokenized option. Strike + expiry inferred from symbol.
curl -H "X-PAYMENT: $X402_TOKEN" https://codex.useatrium.me/options/rTSLA-DEC25-180C
import { x402Sign } from '@x402/core';
import { createWalletClient, http } from 'viem';
import { arbitrumSepolia } from 'viem/chains';
const wallet = createWalletClient({ chain: arbitrumSepolia, transport: http() });
const token = await x402Sign(wallet, { amountUsd: 0.001, recipient: CODEX_ADDR });
const res = await fetch('https://codex.useatrium.me/margin/' + userAddr, {
headers: { 'X-PAYMENT': token },
});
const data = await res.json();from x402 import sign as x402_sign
import httpx
token = x402_sign(amount_usd=0.001, recipient=CODEX_ADDR, signer=wallet)
r = httpx.get(
f'https://codex.useatrium.me/margin/{user_addr}',
headers={'X-PAYMENT': token},
)
data = r.json()402 missing or insufficient x402 payment; body has price quote429 rate-limited; body has retry-after503 upstream subgraph or RPC unavailable; honest pending404 user / agent / strategy not found