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 URL | https://<your-api>/api/v1 — locally http://localhost:4000/api/v1 |
| Format | JSON request and response bodies |
| Auth | Authorization: Bearer <api key or access token> — see Authentication |
| Addresses | Stacks principals, validated including the c32 checksum. A mistyped address is a 400, not a queued job |
| Interactive | Swagger UI at https://<your-api>/docs |
Portfolios and risk#
The latest indexed portfolio: positions, assets and valuation.
{ "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.
The latest deterministic risk snapshot.
{ "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.
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.
{ "accepted": true, "address": "SP10GK6MG2GM7BCVYV7XBHK1JVJDHFDMNBENNBRC3", "correlationId": "87bb1734-994e-412c-8782-4acd98814715", "statusUrl": "/api/v1/portfolios/SP10GK6MG2GM7BCVYV7XBHK1JVJDHFDMNBENNBRC3"}Stress testing#
id | Shock |
|---|---|
btc-minus-10 | BTC and sBTC −10% |
btc-minus-20 | BTC and sBTC −20% |
btc-minus-30 | BTC and sBTC −30% |
stx-minus-20 | STX −20% |
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 }, wherechangeBpsis an integer from-10000(−100%) to100000(+1000%).
{ "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#
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.
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.
metricstringrequiredriskScoreBps,healthFactorE4,liquidationDistanceBps,protocolConcentrationBps,assetConcentrationBps,liquidityScoreBpsorcapitalAccessibilityBps.operatorstringrequiredlt,lte,gtorgte.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.
statusstringrequiredACTIVE,PAUSEDorARCHIVED.403if the rule belongs to another account.
On-chain policy#
The wallet-owned policy read from the risk-policy contract. Wallets set their own policy on chain; the API only reads it.
{ "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#
Your endpoints, each with its recent delivery records.
urlstringrequired- Absolute
httpsURL. Plainhttpis accepted only forlocalhost. 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.
enabledbooleanrequired- Pause or resume delivery.
Authentication and account#
addressstringrequired- The address signing in.
Returns { address, message, nonce, expiresIn: 300 }. Sign message exactly.
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 }.
refreshTokenstringrequired- A refresh token from verify or a previous refresh.
The account, its notification settings and every wallet linked to it.
emailstring- Notification address. Changing it resets verification.
409if another account already uses it. notifyByEmailboolean- Whether alerts are also emailed.
API keys#
Returns { keys: [{ id, name, prefix, lastUsedAt, createdAt }] }, never the secret.
namestringrequired- A label for your own reference.
livebooleantrueforrv_live_, otherwiserv_test_.
The token in the response is shown once.
Health#
Liveness: { status: "ok", service: "rivisk-api", timestamp }.
Readiness: { status: "ready" }.

