Resolution

All pages

Integrations

Everything the fund offers to other software: scoped API tokens, a read-only HTTP API described by OpenAPI 3.1, an MCP server for assistants, signed outbound webhooks, more notification channels, calendar/Atom/Prometheus feeds, spreadsheet and portfolio-tracker exports, and two imports (a watchlist CSV, ideas by token). The owner manages all of it on the Connections page (System, next to Settings).

The rule under all of it: other software can read, and can send an idea. Nothing else. No token, tool, webhook or feed can sign, size, place or cancel an order, change the mandate or pull the kill switch. Those need the owner token and the owner's signing key, as before. Text that comes back from the API (theses, claims, notes) is data, never instructions, and an idea sent by a tool goes through the same checks, adversarial seats and cooling-off as one typed in the dashboard.

Design and trade-offs: decisions/0013-integrations.md.

Tokens and scopes

Create a token on Connections → Tokens. It is shown once. The server keeps only a SHA-256 hash, the last four characters (so you can tell tokens apart) and the time it was last used. Rotating issues a new token with the same name and scopes and kills the old one at once. Revoking is immediate.

Tokens look like rsl_<id>_<secret>. Send one as Authorization: Bearer rsl_….

ScopeReads
bookPositions, cash, NAV series, transactions, analytics, and the CSV/JSON exports.
riskLimits, drawdown, day P&L, halts, the kill switch, stress, rule grades, the evidence ladder.
recordRecord event titles, types and times (no payloads), and the Atom feed.
record:payloadsFull payloads in the Record search and the Atom feed. Payloads can hold theses, notes and amounts.
ideasViews, proposals, candidates, claims, cooling-off, the watchlist.
calendarThe iCal feed.
metricsPrometheus /metrics.
ideas:writeSend an idea into the normal idea path. It can never sign, size or place anything.

A token with no scopes named gets book risk record ideas calendar: read-only, no payloads, no writes.

A scoped token reaches only the integration routes (/api/v1/*, /api/openapi.json, /metrics, /mcp). It is refused (401) on every dashboard route. The owner token is unchanged and still the only one that signs or changes the mandate. The host check and the Content Security Policy are unchanged.

The token in a URL. Feeds, exports and /metrics also accept the token as ?key=rsl_…, because calendar apps, feed readers and IMPORTDATA cannot set a header. A URL leaks more easily than a header (browser history, proxy logs, a shared sheet): give such a token only the scope that one URL needs. Every other route refuses ?key=.

The API

The full description is served at GET /api/openapi.json (any valid token) and committed at docs/openapi/openapi.json. Both are generated from the route table in src/integrations/routes.ts; regenerate the file with npm run openapi. A test fails when they drift.

Method and pathScopeWhat
GET /api/v1/statusanySet up, paper or live, kill switch, halts, health, Record head.
GET /api/v1/bookbookNAV, cash, exposure, each position with value, P&L and weight.
GET /api/v1/navbookOne row per struck session.
GET /api/v1/transactionsbookEvery booked fill with gross, fee and amount in the base currency.
GET /api/v1/analyticsbookReturns, ratios, drawdowns, trade statistics.
GET /api/v1/riskriskDrawdown and day P&L against limits, halts, rule grades, stress, ladder.
GET /api/v1/record?q=&type=&since=&limit=recordSearch the Record, newest first.
GET /api/v1/ideasideasViews, proposals, candidates, refused and cooling ideas.
GET /api/v1/claimsideasClaims on file with status and source reliability.
GET /api/v1/watchlistideasThe watchlist. A list, not a signal.
POST /api/v1/ideas[?async=1]ideas:writeSend an idea.
GET /api/v1/ideas/{ticket}ideas:writeThe outcome of an async=1 idea.
GET /api/v1/export/*.csv, ghostfolio.jsonbookExports, below.
GET /api/v1/feeds/calendar.icscalendariCal feed.
GET /api/v1/feeds/record.atomrecordAtom feed.
GET /metricsmetricsPrometheus text format.

Every figure comes from the fund's server code. Quote it; do not recompute it. Errors are {"error": "…", "code": "…"} with 400, 401, 403, 404, 405 or 429.

Sending an idea

curl -X POST "$RESOLUTION_URL/api/v1/ideas" \
  -H "Authorization: Bearer $TOKEN" -H "content-type: application/json" \
  -d '{"instrument":"ASML.AS","direction":"long","thesis":"Lithography demand outlasts the cycle.","horizon_days":60,"falsifier":"price < 540"}'

Also accepted, for tools that name things differently: symbol/ticker, side (buy/sell), text/body. The instrument must be in the investable universe (404 otherwise). The text is kept verbatim as a thesis to test; the seats treat it as data. Each token may send INTEGRATIONS_IDEAS_PER_DAY ideas a day (default 10, at most 100; 429 after that), counted after validation and before any research is spent. Research can take minutes: ?async=1 answers 202 with a ticket at once, and GET /api/v1/ideas/{ticket} reports researching, done (with the outcome) or failed. Tickets live in memory and are gone after a restart. Whatever the outcome, a proposal still waits for the owner's signature in the dashboard.

Exports

URLFor
/api/v1/export/positions.csvSpreadsheets: one row per position.
/api/v1/export/transactions.csvSpreadsheets: one row per fill.
/api/v1/export/nav.csvSpreadsheets: the NAV series.
/api/v1/export/portfolio-performance.csvPortfolio Performance: File → Import → CSV → Portfolio Transactions.
/api/v1/export/ghostfolio.jsonGhostfolio: Portfolio → Activities → Import.
/api/v1/export/ledger.beancountBeancount and Fava: the book as a double-entry ledger.

CSV options: sep=semicolon gives ; separators and a decimal comma, for Dutch and most EU Excel installs; bom=0 leaves out the UTF-8 byte-order mark (Excel wants it; Google Sheets does not). Text cells that start with =, +, - or @ are neutralised so a spreadsheet never runs them as formulas.

Stable spreadsheet URLs. The URLs do not change, so a sheet can refresh them:

Google Sheets:  =IMPORTDATA("https://fund.example/api/v1/export/positions.csv?key=rsl_…&bom=0")
Excel:          Data → From Web → https://fund.example/api/v1/export/positions.csv?key=rsl_…&sep=semicolon

Google fetches from its own servers, so the fund must be reachable from the internet at that host, and the host must be in the server's allowed hosts. Use a token with only book.

Beancount and Fava. The book is also available as a Beancount ledger: from the API above, from GET /api/export/beancount for the owner, or from the shell with npm run export:beancount -- --data ./data --out ledger.beancount. Open it in Fava, run separately and unmodified, with fava ledger.beancount, for balance sheets, an income statement and ad-hoc queries.

The ledger is written from the Record, not booked: every change of the book becomes one balanced transaction, so its balances are the book's balances. Assets:Cash is the fund's cash in the base currency and Assets:Positions:<SYMBOL> holds each name's units; Income:Realized and Expenses:Fees sum to the fund's realized P&L and fees. What to know:

  • Holdings carry no Beancount cost lots. The fund books average cost, and Beancount's lot matching would give a different realized P&L, so realized P&L is the fund's own figure.
  • Cash is one account in the base currency, as in the book: a fill in dollars is converted at its fx when booked.
  • Prices are the fill prices, plus today's marks when it comes from the server. The shell command does not fetch marks.
  • The example book is written with the ! flag and #example, against Equity:Example-Book.
  • Dividends and withholding from imports are owner-attested broker history, not part of the book. They are written with the ! flag and #attested under Assets:Broker:<broker>:<currency>, and never touch Assets:Cash.
  • The tests check the ledger with their own small parser: every transaction balances, and cash, units, fees and realized P&L equal the book. Beancount itself is not a dependency and is not run in the tests.

Feeds

  • Calendar — /api/v1/feeds/calendar.ics?key=rsl_… (scope calendar). Scheduled rituals, sessions, cooling-off ends and hypothesis look dates. Subscribe by URL in Apple Calendar, Google Calendar or Outlook.
  • Atom — /api/v1/feeds/record.atom?key=rsl_… (scope record). The newest Record events. Titles only; the payload is included only when the token also holds record:payloads. all=1 includes the machinery events; limit is 1 to 200.
  • Prometheus — /metrics (scope metrics, as a bearer token or ?key=). Status, NAV (resolution_nav, in the base currency), drawdown, rule states, job and breaker health, webhook delivery counts (resolution_webhook_deliveries{endpoint,ok}) and model spend (resolution_model_spend_usd).
# prometheus.yml
scrape_configs:
  - job_name: resolution
    metrics_path: /metrics
    authorization: { type: Bearer, credentials: rsl_… }
    static_configs: [{ targets: ['fund.internal:4747'] }]

Outbound webhooks

Connections → Webhooks → Add. Choose the event types (* for all, a prefix like fill.*, or exact types), and whether payloads are included (off by default: without them the receiver gets type, title and time only). The signing secret is shown once.

Each matching Record event is POSTed as JSON:

{ "id": "wh_ab12.evt_…", "sent_at": "2026-09-25T09:00:01Z",
  "event": { "seq": 812, "id": "evt_…", "type": "fill.recorded", "title": "A fill was booked",
             "at": "2026-09-25T09:00:00Z", "producer": "gateway", "correlation_id": "…", "payload": { } } }

Headers: X-Resolution-Event (the type), X-Resolution-Delivery (stable per endpoint and event: de-duplicate on it), the three Standard Webhooks headers webhook-id (the same value as X-Resolution-Delivery), webhook-timestamp (unix seconds) and webhook-signature: v1,<base64>, and the older X-Resolution-Signature: t=<unix seconds>,v1=<hex>. Both signatures are sent on every delivery while receivers move over; new receivers should check the Standard Webhooks one, which any of that project's libraries verifies.

Retries. Any answer other than 2xx, a timeout (10 s) or a refused connection is retried by the jobs runner with exponential backoff: six attempts over about five minutes (10 s, 20 s, 40 s, 80 s, 160 s). Redirects are not followed. Deliveries to one endpoint go out in Record order. A delivery that uses up its attempts is dead-lettered: it shows in Operations as a dead webhook job and is never sent again. Every attempt is in the endpoint's delivery log (status, time, error), which is kept out of the Record. Test sends one signed delivery of type webhook.test ("Nothing happened in the fund"), without retries and without touching the Record, so you can check the receiver. Pause stops deliveries without losing the configuration.

Verifying the Standard Webhooks signature

webhook-signature is v1, followed by the base64 HMAC-SHA256 of "<webhook-id>.<webhook-timestamp>.<raw body>". The key is the base64-decoded part of the secret after whsec_. The header may carry several space-separated signatures; accept the delivery if one matches. Reject a timestamp more than five minutes from your clock.

// Node
import { createHmac, timingSafeEqual } from 'node:crypto';
export function verifyStandard(secret, rawBody, h, now = Math.floor(Date.now() / 1000)) {
  const id = h['webhook-id'], ts = h['webhook-timestamp'], sigs = h['webhook-signature'];
  if (!id || !ts || !sigs || Math.abs(now - Number(ts)) > 300) return false;
  const key = Buffer.from(secret.replace(/^whsec_/, ''), 'base64');
  const want = createHmac('sha256', key).update(`${id}.${ts}.${rawBody}`).digest();
  return sigs.split(' ').some((s) => {
    const [v, b64] = s.split(',');
    const got = Buffer.from(b64 ?? '', 'base64');
    return v === 'v1' && got.length === want.length && timingSafeEqual(got, want);
  });
}

Secrets made since Standard Webhooks support are whsec_ plus standard base64. A secret made before then is whsec_ plus URL-safe base64; Node decodes both alphabets, but a strict library may not. Either rotate the secret (Connections → Webhooks → Rotate) or convert it for the library: replace - with + and _ with /, and pad with = to a multiple of four characters.

Verifying the X-Resolution-Signature

The signature is HMAC-SHA256 of "<t>.<raw body>" with the secret, hex-encoded. Reject anything older than five minutes.

// Node
import { createHmac, timingSafeEqual } from 'node:crypto';
export function verify(secret, rawBody, header, now = Math.floor(Date.now() / 1000)) {
  const m = /^t=(\d+),v1=([0-9a-f]{64})$/.exec(header ?? '');
  if (!m || Math.abs(now - Number(m[1])) > 300) return false;
  const want = createHmac('sha256', secret).update(`${m[1]}.${rawBody}`).digest();
  return timingSafeEqual(want, Buffer.from(m[2], 'hex'));
}
# Python
import hmac, hashlib, re, time
def verify(secret: str, raw_body: bytes, header: str) -> bool:
    m = re.fullmatch(r"t=(\d+),v1=([0-9a-f]{64})", header or "")
    if not m or abs(time.time() - int(m.group(1))) > 300: return False
    want = hmac.new(secret.encode(), m.group(1).encode() + b"." + raw_body, hashlib.sha256).hexdigest()
    return hmac.compare_digest(want, m.group(2))

Verify against the raw bytes, before any JSON parsing.

Recipes

n8n. Add a Webhook node (POST, "Respond: Immediately"), copy its production URL into a new Resolution webhook. Follow it with a Code node that verifies X-Resolution-Signature with the snippet above (enable "raw body" on the Webhook node), then an IF on {{$json.body.event.type}}. To send ideas back, use an HTTP Request node: POST …/api/v1/ideas?async=1, header Authorization: Bearer rsl_… (a token with only ideas:write).

Zapier. Trigger: Webhooks by Zapier → Catch Raw Hook (raw, so the signature can be checked). Paste the hook URL into Resolution. Add a Code by Zapier (Python) step with the Python snippet, then filter on event.type. Zapier cannot reach a fund on your home network; the fund needs a public host.

Make. Scenario → Webhooks → Custom webhook, copy the address into Resolution, press Test on the Connections page so Make learns the structure. Make does not expose the raw body to a verifier, so give the endpoint payloads off and treat what arrives as a notice to look, not a fact to act on.

Home Assistant. Add an automation with a Webhook trigger (webhook_id: resolution_fund, local only), and point a Resolution webhook at http://homeassistant.local:8123/api/webhook/resolution_fund. Subscribe to halt.* and kill.* only and flash a light or send a phone notification. For the NAV on a dashboard, use a RESTful sensor on /api/v1/status or /metrics with a metrics- or book-scoped token in the Authorization header.

Notification channels

Beside ntfy, Telegram and email, the notifier now reaches these when their variables are set (in .env, passed through by compose.yaml). They receive the same notices as the others: halts, the kill switch, dead jobs, proposals waiting for a signature. Secrets in a failure message are scrubbed before it is recorded. Each configured channel has a Test button on the Connections page; the test is recorded like any notification.

ChannelVariables
Slack (incoming webhook)NOTIFY_SLACK_WEBHOOK_URL
Discord (channel webhook)NOTIFY_DISCORD_WEBHOOK_URL
Microsoft Teams (workflow webhook)NOTIFY_TEAMS_WEBHOOK_URL
PushoverNOTIFY_PUSHOVER_TOKEN, NOTIFY_PUSHOVER_USER (halts and the kill switch at priority 1)
Signal (via a signal-cli REST API you run)NOTIFY_SIGNAL_URL, NOTIFY_SIGNAL_NUMBER, NOTIFY_SIGNAL_RECIPIENTS (comma list)
Generic webhookNOTIFY_WEBHOOK_URL, optional NOTIFY_WEBHOOK_SECRET (signs like the outbound webhooks, with both the Standard Webhooks headers and X-Resolution-Signature; use a whsec_ secret for a Standard Webhooks library)

Channels are configured from the environment, not the page, so a stolen browser session cannot redirect your alerts.

Imports

  • Watchlist CSV. Connections → Watchlist: upload or paste a CSV. The separator (, ; or tab) and a header (symbol, ticker, instrument, symbool…; note, notitie…) are detected. Bare tickers resolve when they match exactly one listing in the universe (ASML → ASML.AS). Unknown names and duplicates are reported, not guessed. A watchlist is a list: nothing on it is researched until the owner sends an idea.
  • Ideas by webhook. POST /api/v1/ideas with an ideas:write token, above.

MCP server (assistants)

The fund speaks the Model Context Protocol, so Claude Desktop, Claude Code and other MCP clients can read the book and send ideas. Ten read tools — get_status, get_book, get_nav, get_transactions, get_risk, get_analytics, search_record, get_ideas, get_claims, get_watchlist — and one write, send_idea. An assistant sees only the tools its token's scopes allow. No tool signs, sizes, places or changes anything.

stdio (npm run mcp) runs a small bridge that calls the fund's HTTP API with a scoped token. It holds no state.

// Claude Desktop: claude_desktop_config.json
{ "mcpServers": { "resolution": {
    "command": "node", "args": ["/path/to/resolution/src/mcp/stdio.ts"],
    "env": { "RESOLUTION_URL": "http://127.0.0.1:4747", "RESOLUTION_API_TOKEN": "rsl_…" } } } }
# Claude Code, stdio
claude mcp add resolution -e RESOLUTION_URL=http://127.0.0.1:4747 -e RESOLUTION_API_TOKEN=rsl_… \
  -- node /path/to/resolution/src/mcp/stdio.ts

# Claude Code, streamable HTTP (no local bridge)
claude mcp add --transport http resolution http://127.0.0.1:4747/mcp --header "Authorization: Bearer rsl_…"

Streamable HTTP is POST /mcp with a scoped token; answers are plain JSON (no server-initiated streams). Cross-origin requests are refused, so a web page elsewhere cannot drive it.

Give an assistant a token without ideas:write unless you want it to send ideas, and never the owner token.

Connecting with OAuth instead of a pasted token

An MCP client that speaks OAuth 2.1 can connect with nothing but the URL:

claude mcp add --transport http resolution https://fund.example/mcp
  1. The client calls /mcp without a token. The 401 carries WWW-Authenticate: Bearer resource_metadata="…/.well-known/oauth-protected-resource/mcp" (RFC 9728). That document names the fund itself as the authorization server, and /.well-known/oauth-authorization-server (RFC 8414) lists the endpoints under /mcp/oauth/.
  2. The client registers itself (POST /mcp/oauth/register, RFC 7591). Only public clients are accepted: no client secret is issued. Redirect URIs must be https, or http on localhost, 127.0.0.1 or [::1].
  3. The client sends you to /mcp/oauth/authorize with a PKCE challenge. Only S256 is accepted; plain is refused. The fund redirects to the web app (Connections, while you are signed in), which shows the client's name, where the code will be sent, and the scopes it asked for. You can untick scopes before you approve. Deny sends the client access_denied.
  4. The client exchanges the code (single use, valid 60 seconds) and its PKCE verifier at /mcp/oauth/token. It gets an access token rso_… valid 10 minutes and a refresh token rsr_… valid 30 days.
  5. Each refresh returns a new pair and retires the old one. A refresh cannot widen the scopes. If a retired refresh token is presented again, the fund assumes it leaked and revokes the whole grant.

Scopes are the same as for rsl_ tokens, and an OAuth access token reaches exactly what an rsl_ token with those scopes reaches, including /api/v1/*. It never reaches the owner's API. Grants are listed under Connections → Assistants, where you can revoke one; POST /mcp/oauth/revoke (RFC 7009) lets a client revoke its own. Static rsl_ tokens keep working unchanged.

Limits, stated plainly:

  • Access tokens, authorization codes and pending consent requests are kept in memory. A restart ends every access token and every consent in flight; clients recover by refreshing, since refresh tokens are stored (hashed) in the database.
  • Only public clients with PKCE are supported. There is no client-credentials grant and no confidential client.
  • Consent needs the web app. A client on a machine that cannot reach the fund's web page cannot complete the flow; give it an rsl_ token instead.
  • The issuer is derived from the request's Host (and X-Forwarded-Proto: https behind a proxy). Behind a proxy that rewrites the host, set the proxy to pass it through.

Environment variables added

VariableDefaultMeaning
NOTIFY_SLACK_WEBHOOK_URL, NOTIFY_DISCORD_WEBHOOK_URL, NOTIFY_TEAMS_WEBHOOK_URLunsetChannels, above.
NOTIFY_PUSHOVER_TOKEN, NOTIFY_PUSHOVER_USERunsetPushover.
NOTIFY_SIGNAL_URL, NOTIFY_SIGNAL_NUMBER, NOTIFY_SIGNAL_RECIPIENTSunsetSignal.
NOTIFY_WEBHOOK_URL, NOTIFY_WEBHOOK_SECRETunsetGeneric webhook channel.
INTEGRATIONS_IDEAS_PER_DAY10Ideas a day accepted by token (1 to 100).
RESOLUTION_URL, RESOLUTION_API_TOKENhttp://127.0.0.1:4747, unsetFor npm run mcp only.

Where things are kept

Tokens (hash, hint, scopes, last use), webhook endpoints, the delivery log and the watchlist live in the fund's database, beside the jobs table. OAuth clients and grants (oauth_clients, oauth_grants) live there too; a grant stores only hashes of its refresh tokens. Webhook signing secrets must be usable to sign, so they cannot be hashed: they are sealed with AES-256-GCM under a key in <data dir>/integrations.key (mode 0600), and the browser only ever sees a fingerprint. Webhook URLs are shown masked, since many are secrets themselves. Creating, rotating and revoking write nothing to the Record; they are settings, not fund history.