Integrate
Authentication
Public reads need nothing. Account-scoped actions take an API key for server-to-server calls, or a wallet-signature session when a person is signing in.
What each credential can do#
| Credential | Portfolios, risk, simulations, policies, alert lists | Create and change alerts and webhooks | API keys and profile |
|---|---|---|---|
| None | ✓ | — | — |
API key rv_live_… / rv_test_… | ✓ | ✓ | — |
| Wallet session | ✓ | ✓ | ✓ |
Both credentials are sent the same way, as a bearer token:
Authorization: Bearer rv_live_3f9a…Ownership#
Alerts belong to an address, and writing one requires that the credential's account controls that address, meaning it has signed in with it. A wallet row existing because someone scanned the address proves nothing, so an unclaimed address cannot be claimed through the alerts API. Writing to an address you do not control returns 403.
Wallet sessions#
Rivisk never sees a private key. The wallet signs a one-time challenge and the API checks that the signature came from the public key that hashes to the claimed address.
Request a challenge
tsconst { message } = await rivisk.auth.challenge(address);The message expires after 300 seconds and authenticates exactly one sign-in; it is deleted the moment it is used.
Sign it in the wallet
tsimport { request } from '@stacks/connect'; const { signature, publicKey } = await request('stx_signMessage', { message });It is a message signature, not a transaction: it moves no funds and costs nothing.
Exchange it for tokens
tsconst session = await rivisk.auth.verify({ address, publicKey, signature });// { userId, address, accessToken, refreshToken, expiresIn }From here the SDK holds the session and refreshes it on its own: a
401triggers one refresh and the original request is replayed with the new token.
Token lifetimes#
| Token | Lifetime | Notes |
|---|---|---|
| Challenge | 300 seconds | Single use |
| Access token | 15 minutes | Sent as the bearer token |
| Refresh token | 30 days | Only accepted by POST /auth/refresh; rejected as an access token |
Persisting a session#
const rivisk = new RiviskClient({ baseUrl, session: JSON.parse(localStorage.getItem('rivisk_session') ?? 'null'), onSession: (session) => { if (session) localStorage.setItem('rivisk_session', JSON.stringify(session)); else localStorage.removeItem('rivisk_session'); },});onSession fires on sign-in, on every refresh, and with null when the refresh token is rejected, so storage never holds a session the server has already refused.
API keys#
Create keys from a wallet session, either on the Developers page of the dashboard or over the API:
const key = await rivisk.apiKeys.create('production backend', true); // live: truekey.token; // rv_live_… shown once, never again. Store it now.| Prefix | Use |
|---|---|
rv_live_ | Production |
rv_test_ | Development and CI |
Keys are stored only as a peppered SHA-256 hash and compared in constant time, so a database leak does not hand out working credentials. The first 16 characters are kept in clear so you can tell your keys apart in the dashboard. Revoke with rivisk.apiKeys.revoke(id); it takes effect on the next request.
const server = new RiviskClient({ baseUrl, apiKey: process.env.RIVISK_API_KEY });await server.webhooks.create('https://example.com/rivisk', ['alert.triggered']);Endpoint by endpoint, the credential each one takes is listed on REST API.

