# HMAC-SHA256 Financial Disclosure Change Webhook API (SQLite Diff)

- **Canonical HTML**: https://quantdesk.fastmesh.dev/seo_geo/hmac-sha256-quant-disclosure-change-webhook-api.html
- **Target Query**: `HMAC SHA256 financial disclosure webhook API` (`how_to`)
- **Source Family**: `clinical_trials` | **MCP Tool**: `quantdesk_watch_diff` | **Pricing**: $0.025 ONLY on material change ($0 on baseline or unchanged)
- **Seed**: `42` | **Trials**: `10000` | **Receipt SHA-256**: `98f5999c0c893d00ce3dbdd44035b1d59d8f46c2365e96ce26780d80bd54e6c7`

## Direct Answer
Turn polling-only public registries (SEC EDGAR, ECB FX, ClinicalTrials.gov v2, openFDA, Polymarket/Kalshi) into event-driven HMAC-SHA256 signed webhook streams backed by canonical SHA-256 SQLite snapshot diffs.

## Canonical Snapshot Diffing & HMAC-SHA256 Signature Contract
- Snapshot Hash: current_sha256 = SHA256(canonical_json(signal.metrics)); changed = (previous_sha256 is not None) AND (current_sha256 != previous_sha256) AND materiality_gate_passed.
- Webhook Signature: X-QuantDesk-Signature = 'sha256=' + HMAC_SHA256(secret, raw_body).hexdigest() paired with X-QuantDesk-Event-Id and X-QuantDesk-Timestamp (timestamp_s).
- Billing Rule: billed_micros = 25000 if changed else 0.

## Deterministic 10,000-Trial Risk Metrics (Seed 42)
- P5 / P50 / P95 Return: -3.16% / +2.15% / +7.50%
- Mean / Std Return: +2.20% / 3.26%
- VaR 95 / CVaR 95: 3.16% / 4.40%
- VaR 99 / CVaR 99: 5.17% / 6.18%
- Max Drawdown (95th) / Ruin Probability: 4.12% / 0.00%
- Half-Kelly Cap: 25.00%
- Top Tornado Driver: `expected_return` (swing 5.05%, variance share 62.1%)

## Key Engineering Capabilities
- Persists compact canonical hashes per watch_id in local SQLite under --state-dir/--data-dir with zero client strategy retention.
- Applies source-specific materiality gates (new SEC accession, >=25 bps spread/FX delta, ClinicalTrials status/hasResults jump, new FDA approval/recall).
- Prevents alert fatigue and duplicate webhook firing on cosmetic whitespace or header changes.

## Remote `/mcp` Invocation Example
```bash
curl -fsSL -X POST "https://quantdesk.fastmesh.dev/mcp" \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": {"name": "quantdesk_watch_diff", "arguments": {"watch_id": "ecb_eurusd_daily", "source_type": "ecb_fx", "raw_payload": "<gesmes:Envelope xmlns:gesmes='http://www.gesmes.org/xml/2002-08-01' xmlns='http://www.ecb.int/vocabulary/2002-08-01/eurofxref'><Cube><Cube time='2026-12-02'><Cube currency='USD' rate='1.0982'/><Cube currency='JPY' rate='175.10'/></Cube></Cube></gesmes:Envelope>"}}}'
```

## Frequently Asked Questions
### Is the very first watch_id registration billed?
No. Establishing the initial baseline snapshot records previous state with changed=false, webhook_emitted=false, and strictly billed_micros=0.

### What headers are included to prevent webhook replay attacks?
Every emitted webhook carries X-QuantDesk-Signature (HMAC-SHA256), a unique X-QuantDesk-Event-Id for idempotent deduplication, and X-QuantDesk-Timestamp (timestamp_s) for freshness checks.

### Why not fire webhooks on every byte difference in upstream HTML/XML?
Upstream CDN headers, timestamps, and whitespace change constantly without new economic facts. Hashing normalized semantic metrics and gating on materiality thresholds eliminates false alarms.

## Compliance & Zero-Resale Policy
Agent-WallStreet-Desk is a deterministic quantitative public-disclosure extraction and Monte Carlo risk modeling engineering tool only. It is NOT investment advice under the U.S. Investment Advisers Act of 1940, NOT a broker-dealer, and provides ZERO asset management, trade execution, or custody. 100% legal public regulatory disclosures and public market data only (zero MNPI, zero paywall bypass). Strictly $0 billed on empty, unchanged, fake-200, SSRF-blocked, or HTTP 422 responses. Zero client trading strategy, portfolio holdings, or watchlist retention or resale (zero_resale_policy: true). Support: support@fastmesh.dev.
