Skip to main content
Create your account and provision keys at the API Key Dashboard.
Finvera supports two authentication models. Pick the one that matches where your code runs: The base URL for all requests is https://api.finvera.news.

Client-side: publishable keys + session tokens

Publishable keys are safe to ship in client bundles, but on their own they cannot call data endpoints. A client first exchanges its pk_ for a session token at the Finvera edge, then uses that session token as a bearer credential on every subsequent call. Each session is bound to:
  • the publishable key it was minted for,
  • the browser Origin that minted it (must match the key’s allowlist), and
  • the caller’s network prefix (IPv4 /24 or IPv6 /48).
A leaked session token therefore cannot be replayed from a different site or a different network, and any session can be revoked instantly by revoking its parent pk_.

Flow at a glance

1. Solve a Turnstile challenge

The mint endpoint is protected by Cloudflare Turnstile. Render the widget on the page that will mint the session and pass the resulting token along with the mint request.
Required widget configuration:
  • data-action must equal mint_session. Tokens issued for any other action are rejected.
  • data-cdata should be the lowercase hex SHA-256 of your publishable key. This binds the challenge to the specific pk_ so a token harvested under one key on the same site cannot be reused with another. (Only enforced on interactive widgets; invisible widgets may omit it.)
  • The widget’s hostname must match the Origin of the mint request — Turnstile is bound to the page that served it.
The widget invokes your callback with a single-use token. Send that token to /v1/session immediately.

2. Mint a session token

Response (200):
  • token — opaque JWT to send on subsequent requests.
  • expires_in — seconds until this token expires (default 15 min).
  • refresh_window_seconds — the maximum lifetime of a session chain. Once this much time has passed since the original mint, you must mint a fresh session from pk_ again.

3. Call API endpoints with the session token

Every other Finvera endpoint accepts the session token as a standard bearer credential:
The request must come from the same Origin and the same network prefix the session was minted on. Sending a pk_ directly to a data endpoint (without first exchanging it) returns 401 session_required.

4. Sliding refresh (zero-effort token rotation)

When a request is served past the halfway point of the session’s TTL — and the session chain is still within refresh_window_seconds — the edge mints a fresh token and returns it on the response:
These headers are exposed via CORS (Access-Control-Expose-Headers), so browsers can read them. Clients should:
  1. Inspect every response for x-session-token.
  2. If present, replace the in-memory token with it (and update expires_at).
  3. When the refresh window is exhausted, restart from step 1 — solve Turnstile and call /v1/session again.

Error responses

/v1/session returns JSON {"error":"<reason>"} with these status codes: Data-plane endpoints (with Authorization: Bearer) add:

Browser implementation (JavaScript / TypeScript)

A few practical notes:
  • Keep the session token in memory only. Never persist it to localStorage — its short TTL plus origin/network binding is the protection.
  • The Origin header is set automatically by the browser; don’t try to override it.
  • If you get session_network_mismatch you’ve roamed networks (e.g. Wi-Fi → cellular). Mint a fresh session.

Server-to-server: secret keys

For backend services, batch jobs, or any code running outside a browser, use a secret key (sk_… or finvera_…). Secret keys do not go through the session flow — they are sent directly on every request and validated at the origin.
Treat secret keys like any other credential:
  • Store them in your secret manager (Vault, AWS Secrets Manager, Doppler, …), never in source control.
  • Rotate them from the dashboard if you suspect exposure — revocation propagates to the edge within ~70 seconds.
  • Do not ship secret keys to browsers, mobile apps, or any user-controlled environment. Use a publishable key there instead.

Choosing between pk_ and sk_

If you need both — a public web app and a backend that calls Finvera — provision one of each from the dashboard.