REST API

Endpoints of the Verora API - health, SIWE authentication, agent metadata hosting, and indexed agents, queries, and staking data.

The Verora API indexes contract events into Postgres and serves them over a read-only REST API, hosts agent metadata, and handles Sign-In with Ethereum. It never moves funds: every state change is a transaction you sign against the contracts.

When SWAGGER_ENABLED=true, interactive OpenAPI docs are served at /api/docs. Locally that is http://localhost:4100/api/docs.

Conventions#

TopicBehavior
FormatJSON in and out. Amounts in wei are decimal strings, timestamps are ISO 8601 strings unless noted.
IDsAgent and query IDs are 0x-prefixed 32-byte hex, addresses 0x-prefixed 20-byte hex. They are normalized to lowercase. Malformed IDs return 400.
Paginationpage (1 to 10,000, default 1) and limit (1 to 100, default 20). Responses are { data, page, limit, total }.
ValidationUnknown query or body fields are rejected with 400.
AuthenticationOnly POST /metadata requires a session: Authorization: Bearer <token>.
Rate limits120 requests per minute per client by default, stricter where noted. / and /health are not limited.
CORSOnly origins in CORS_ORIGINS, methods GET and POST.
Body sizeJSON bodies up to 1.1 MB (enough for a metadata upload with both images). Larger bodies return 413.

Health#

MethodPathDescription
GET/Service banner: { "service": "Verora API" }.
GET/healthDatabase, RPC, and indexer health. Returns 503 when unhealthy.
GET /health
{
  "status": "healthy",
  "timestamp": "2026-10-12T09:30:00.000Z",
  "checks": {
    "database": true,
    "rpc": true,
    "indexer": { "lastIndexedBlock": "1234", "safeHead": "1234", "lagBlocks": 0, "lastError": null }
  }
}

status is unhealthy if the database or RPC is down, degraded if the indexer is more than 100 blocks behind, hasn't reported yet, or its last run failed, and healthy otherwise.

Authentication#

Sign-In with Ethereum (EIP-4361). Nonces are single-use and stored in the database. Signatures are verified through the chain client, which also supports smart contract wallets (ERC-1271 and ERC-6492).

MethodPathRate limitDescription
GET/auth/nonce20 per minuteReturns { "nonce": string }, valid for 10 minutes.
POST/auth/verify10 per minuteBody { "message": string, "signature": "0x..." }. Returns { "token", "address", "expiresIn" }.

The message is rejected (401) unless its domain is in SIWE_DOMAINS (when configured), its chain ID matches the API's chain, it was issued within the last 10 minutes, it isn't expired or not yet valid, the nonce is unused, and the signature is valid. Sessions last one hour (expiresIn: 3600).

Metadata#

MethodPathAuthDescription
POST/metadataSession, 10 per minuteStores agent metadata. Returns 201 with { "id", "uri" }.
GET/metadata/:id-The hosted metadata document. id is 64 hex characters without 0x. Cached as immutable.
GET/assets/:id-A hosted image, served with its detected content type. Cached as immutable.
NameTypeDefaultDescription
name*string-1 to 64 characters.
description*string-1 to 1000 characters.
publicKeystring-Base64 X25519 public key (44 characters) for encrypted queries.
websitestring-https URL, up to 256 characters.
iconstring-Base64 data URL of a PNG, JPEG, GIF, or WebP image, at most 256 KB.
bannerstring-Base64 data URL of a PNG, JPEG, GIF, or WebP image, at most 512 KB.

Image types are detected from the file's magic bytes, not the data URL's declared type, so SVG and other formats are rejected. Documents and images are content-addressed by SHA-256, so uploading the same content twice returns the same URI. The returned uri is <PUBLIC_BASE_URL>/metadata/<id>, and images are referenced as <PUBLIC_BASE_URL>/assets/<id>.

Agents#

MethodPathDescription
GET/agentsPaginated agent list.
GET/agents/:idOne agent. 404 if not indexed.

Query parameters for GET /agents:

ParameterValues
statusactive, suspended, slashed
ownerOwner address
capabilityExact capability tag, 1 to 64 characters
searchCase-insensitive search in agent names, 1 to 64 characters
sortreputation (default), stake, newest
Agent
{
  "id": "0x...",
  "owner": "0x...",
  "endpoint": "https://agent.example.com/query",
  "capabilities": ["price_feed"],
  "metadataUri": "https://api.veroraprotocol.com/metadata/...",
  "metadata": { "name": "Price Oracle", "description": "Crypto prices", "publicKey": "...", "image": "https://..." },
  "status": "active",
  "adminSuspended": false,
  "registeredAt": "2026-10-12T09:30:00.000Z",
  "reputation": 10000,
  "totalQueries": 12,
  "successfulQueries": 12,
  "failedQueries": 0,
  "totalStake": "1000000000000000000",
  "stakerCount": 1,
  "healthStatus": "healthy",
  "healthCheckedAt": "2026-10-12T09:29:10.000Z"
}

metadata is the sanitized document (or null until resolved or if it can't be resolved), reputation is in basis points, and healthStatus is unknown, healthy, or unhealthy.

Queries#

MethodPathDescription
GET/queriesPaginated query list, newest first.
GET/queries/statsNetwork statistics.
GET/queries/:idOne query with its responses and oracle dispatches. 404 if not indexed.

Query parameters for GET /queries: requester (address), agentId (assigned agent), and status (pending, in_progress, completed, failed).

Query detail
{
  "id": "0x...",
  "requester": "0x...",
  "queryType": "plaintext",
  "queryData": "0x...",
  "status": "completed",
  "cancelled": false,
  "payment": "10000000000000000",
  "deadline": "2026-10-12T09:40:00.000Z",
  "assignedAgents": ["0x...", "0x..."],
  "aggregatedResult": "0x...",
  "createdAt": "2026-10-12T09:30:00.000Z",
  "finalizedAt": "2026-10-12T09:30:12.000Z",
  "txHash": "0x...",
  "responses": [{ "agentId": "0x...", "responseData": "0x...", "submittedAt": "...", "txHash": "0x..." }],
  "dispatches": [{ "agentId": "0x...", "status": "relayed", "attempts": 1, "lastError": null }]
}

The list endpoint returns the same fields without responses and dispatches. Dispatch status is pending, relayed, or failed.

GET /queries/stats
{
  "totalQueries": 3,
  "completedQueries": 2,
  "failedQueries": 1,
  "openQueries": 0,
  "totalVolume": "17000000000000000",
  "activeAgents": 3,
  "totalAgents": 3
}

openQueries counts pending and in_progress queries; totalVolume is the sum of all query payments in wei.

Staking#

MethodPathDescription
GET/staking/stats{ totalStaked, stakingPositions, rewardsDistributed30d, apy } across the network.
GET/staking/agents/:agentId{ agentId, totalStaked, stakerCount, rewardsDistributed30d, apy } for one agent.
GET/staking/positions/:addressLive positions of a staker, 30 per minute.

stakingPositions is the sum of staker counts across agents. apy is the trailing 30-day rewards annualized against the current stake, as a percentage with two decimals. Positions are read live from the StakingPool for every agent the address ever staked on, and only positions with shares, unbonding stake, or pending rewards are returned:

Stake position
{
  "agentId": "0x...",
  "amount": "1000000000000000000",
  "shares": "1000000000000000000",
  "pendingRewards": "500000000000000",
  "unbondingAmount": "0",
  "withdrawableAmount": "0",
  "nextUnlockTime": 0
}

Errors#

Every error has the same shape:

json
{
  "statusCode": 404,
  "message": "Agent not found",
  "error": "Not Found",
  "timestamp": "2026-10-12T09:30:00.000Z",
  "path": "/agents/0x..."
}

message is a string, or an array of validation messages. Only messages written for clients are exposed; anything unexpected is logged server-side and returned as a generic 500. Common statuses: 400 (validation), 401 (auth), 404 (not found), 413 (body too large), 429 (rate limited), 503 (unhealthy).