Rivisk

Integrate

REST API

Every endpoint, the credential it takes, its parameters and its response. JSON in, JSON out, under a single versioned prefix.

Basics#

Base URLhttps://<your-api>/api/v1 — locally http://localhost:4000/api/v1
FormatJSON request and response bodies
AuthAuthorization: Bearer <api key or access token> — see Authentication
AddressesStacks principals, validated including the c32 checksum. A mistyped address is a 400, not a queued job
InteractiveSwagger UI at https://<your-api>/docs

Portfolios and risk#

GET/portfolios/:address#No credential

The latest indexed portfolio: positions, assets and valuation.

200
{  "address": "SP10GK6MG2GM7BCVYV7XBHK1JVJDHFDMNBENNBRC3",  "status": "completed",  "lastIndexedAt": "2026-09-20T14:04:14.000Z",  "sourceBlock": "9032803",  "totalValueUsd": "122815.95",  "valuationCoverageBps": 4444,  "byProtocol": { "zest-v2": "121381.09", "native-stacks": "1434.87" },  "byAsset": { "sBTC": "299879.39", "USDC": "-177064.01" },  "positions": [    {      "id": "…",      "type": "borrowing",      "protocol": { "id": "zest-v2", "name": "Zest Protocol V2", "type": "lending" },      "valueUsd": "121381.08",      "blockHeight": "9032803",      "exact": true,      "assets": [        { "assetId": "sBTC", "symbol": "sBTC", "role": "collateral", "amountAtomic": "370352796", "decimals": 8, "valueUsd": "298445.09" },        { "assetId": "USDC", "symbol": "USDC", "role": "debt", "amountAtomic": "177115550075", "decimals": 6, "valueUsd": "177064.00" }      ]    }  ]}

A wallet that has never been indexed returns 200 with "status": "not-indexed", an empty positions array and a refresh link. amountAtomic is an integer string in the asset's smallest unit; divide by 10^decimals.

GET/portfolios/:address/risk#No credential

The latest deterministic risk snapshot.

200
{  "address": "SP10GK6MG2GM7BCVYV7XBHK1JVJDHFDMNBENNBRC3",  "status": "completed",  "riskLevel": "critical",  "riskScoreBps": 9979,  "healthFactorE4": 11798,  "liquidationDistanceBps": 1524,  "protocolConcentrationBps": 9970,  "assetConcentrationBps": 6288,  "liquidityScoreBps": 30,  "capitalAccessibilityBps": 30,  "reportHash": "a5ebf8bc…08d7",  "methodologyVersion": "rivisk-v1.2",  "sourceBlock": "9032803",  "onchain": null}

404 if the wallet has not been indexed. healthFactorE4 and liquidationDistanceBps are null when there is no debt. See A wallet with no debt. onchain carries the attestation txId once the snapshot has been broadcast. Its snapshotId stays null until the transaction is mined and Chainhook confirms it.

POST/portfolios/:address/refresh#No credential

Queues a fresh on-chain read and returns immediately; it does not wait for indexing. Rate limited to 10 requests per minute per client IP; over the limit returns 429 with a Retry-After header.

202
{  "accepted": true,  "address": "SP10GK6MG2GM7BCVYV7XBHK1JVJDHFDMNBENNBRC3",  "correlationId": "87bb1734-994e-412c-8782-4acd98814715",  "statusUrl": "/api/v1/portfolios/SP10GK6MG2GM7BCVYV7XBHK1JVJDHFDMNBENNBRC3"}

Stress testing#

GET/simulations/presets#No credential
idShock
btc-minus-10BTC and sBTC −10%
btc-minus-20BTC and sBTC −20%
btc-minus-30BTC and sBTC −30%
stx-minus-20STX −20%
POST/simulations#No credential

Runs a scenario against the latest persisted snapshot. Stateless: nothing is written.

addressstringrequired
An indexed Stacks address.
namestring
A label, echoed back.
shocksarrayrequired
At least one. Each is { symbol?, assetId?, changeBps }, where changeBps is an integer from -10000 (−100%) to 100000 (+1000%).
request
{ "address": "SP10GK6MG2GM7BCVYV7XBHK1JVJDHFDMNBENNBRC3", "name": "BTC -20%", "shocks": [{ "symbol": "sBTC", "changeBps": -2000 }] }

The response has before and after risk summaries, per-position results with liquidatableBefore / liquidatableAfter, and any warnings.

Alerts#

GET/alerts/:address#No credential

Active and paused rules for the address (archived ones are omitted) with their five most recent events, plus the last 20 on-chain policy breaches.

POST/alerts/:address#API key or session

Creates a rule. The credential's account must control the address, or the response is 403. Rules fire on the snapshot where the metric crosses into breach, not on every snapshot while it stays there.

metricstringrequired
riskScoreBps, healthFactorE4, liquidationDistanceBps, protocolConcentrationBps, assetConcentrationBps, liquidityScoreBps or capitalAccessibilityBps.
operatorstringrequired
lt, lte, gt or gte.
thresholdstringrequired
A non-negative decimal string in the metric's own units. To fire below a health factor of 1.30, send "13000", not "1.3".
channelstringrequired
Only in_app. Email delivery follows the account's notification setting.
PATCH/alerts/:id#API key or session
statusstringrequired
ACTIVE, PAUSED or ARCHIVED. 403 if the rule belongs to another account.

On-chain policy#

GET/policies/:address#No credential

The wallet-owned policy read from the risk-policy contract. Wallets set their own policy on chain; the API only reads it.

200
{  "address": "SP10GK6MG2GM7BCVYV7XBHK1JVJDHFDMNBENNBRC3",  "configured": true,  "contract": "ST2F3J1PK46D6XVRBB9SQ66PY89P8G0EBDW5E05M7.risk-policy",  "policy": {    "maxRiskScoreBps": 7000, "minHealthFactorE4": 13000,    "maxProtocolConcentrationBps": 5000, "minLiquidityScoreBps": 4000,    "enabled": true, "updatedAt": 454753  }}

policy is null when the wallet has not set one. configured is false when the instance has no RISK_POLICY_CONTRACT.

Webhooks#

GET/webhooks#API key or session

Your endpoints, each with its recent delivery records.

POST/webhooks#API key or session
urlstringrequired
Absolute https URL. Plain http is accepted only for localhost.
eventsstring[]required
At least one of portfolio.updated, risk.updated, alert.triggered, policy.breached.

The response includes the signing secret (whsec_…). It is returned once and never again. Verifying deliveries is covered on Webhooks.

PATCH/webhooks/:id#API key or session
enabledbooleanrequired
Pause or resume delivery.
DELETE/webhooks/:id#API key or session

Authentication and account#

POST/auth/challenge#No credential
addressstringrequired
The address signing in.

Returns { address, message, nonce, expiresIn: 300 }. Sign message exactly.

POST/auth/verify#No credential
addressstringrequired
Must match the address the public key hashes to.
publicKeystringrequired
Compressed secp256k1 public key, hex.
signaturestringrequired
RSV signature over the challenge, hex.

Returns { userId, address, accessToken, refreshToken, expiresIn }.

POST/auth/refresh#No credential
refreshTokenstringrequired
A refresh token from verify or a previous refresh.
GET/auth/me#Wallet session only

The account, its notification settings and every wallet linked to it.

PATCH/auth/me#Wallet session only
emailstring
Notification address. Changing it resets verification. 409 if another account already uses it.
notifyByEmailboolean
Whether alerts are also emailed.

API keys#

GET/api-keys#Wallet session only

Returns { keys: [{ id, name, prefix, lastUsedAt, createdAt }] }, never the secret.

POST/api-keys#Wallet session only
namestringrequired
A label for your own reference.
liveboolean
true for rv_live_, otherwise rv_test_.

The token in the response is shown once.

DELETE/api-keys/:id#Wallet session only

Health#

GET/health#No credential

Liveness: { status: "ok", service: "rivisk-api", timestamp }.

GET/health/ready#No credential

Readiness: { status: "ready" }.