> ## Documentation Index
> Fetch the complete documentation index at: https://docs.darvas.app/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> These docs cover the Darvas financial data API, its MCP server, data API and Darvas Pro+ webhooks, and Pine Script custom indicators for Darvas charts.
> https://docs.darvas.app/llms.txt lists every indexed page with a summary, and https://docs.darvas.app/llms-full.txt holds them in one file. Add .md to any page URL to read that page as Markdown. The lookup lists of tickers, types and series are named at https://docs.darvas.app/ai-agents.
> The docs MCP server https://docs.darvas.app/mcp searches and reads these docs. It needs no key.
> Call the REST API at https://api.darvas.app/v1. Send the API key, which starts with dvk_, in the X-API-KEY header or as Authorization: Bearer. The OpenAPI 3.1 spec of all 168 operations is https://docs.darvas.app/openapi.yaml.
> Name a company by ticker or cik. A share class takes a dot or a dash, so BRK.B and BRK-B name the same shares. Dates are YYYY-MM-DD.
> A list answer holds one page. Request its next_page_url as it is until the answer has none. limit counts rows across all pages.
> Errors are JSON with a stable error code and a message: 400 VALIDATION_ERROR, 401 UNAUTHORIZED, 403 PLAN_REQUIRED, 404 NOT_FOUND, 429 RATE_LIMITED or QUOTA_EXCEEDED, 500 INTERNAL_ERROR and 503 UNAVAILABLE. On a 429, wait the seconds in Retry-After. 1 credit = 1 successful call: a 2xx answer with data costs one credit however many rows it holds (at most 1,000 a page), and empty answers, errors and FINRA /short-volume cost 0 credits.
> The Financial Data MCP server is https://api.darvas.app/mcp (Streamable HTTP, protocol 2025-11-25, the same API key in X-API-KEY or as a Bearer token). tools/list answers 8 flagship tools plus search_data_tools and call_data_tool by default; ?mode=full lists all 164 tools and ?toolsets=sec,crypto,macro lists domains. Every tool is callable by name, takes response_format (json, compact or tsv) and fields, and a list answer's cursor value goes in the cursor argument. The darvas://catalog/* resources cost 0 credits. Setup for each client is at https://docs.darvas.app/mcp-server.
> The data API covers SEC filers and their filings, statements, XBRL facts, debt maturities, ownership and earnings, US stock prices, technicals and FINRA short volume, macro series and a global economic calendar.
> Its crypto data covers prices, indices, order books, order flow, volume profiles, derivatives, options, liquidations, spot ETF flows and a screener across 9 exchanges. It also covers DeFi protocols, stablecoins, yields and DEX pairs, and Polymarket, Kalshi and OKX prediction markets. https://docs.darvas.app/market-coverage gives the history and update time of each dataset.
> https://docs.darvas.app/ai-agents names the endpoint and the MCP tool that answer each kind of question about these datasets.
> Custom indicators for Darvas charts are Pine Script v5 or v6 indicator() or strategy() scripts. Darvas rewrites Pine v1 to v4 to v5 and runs no other indicator language. Start at https://docs.darvas.app/pine-script/introduction.
> https://docs.darvas.app/pine-script/support lists the Pine Script that Darvas runs. https://docs.darvas.app/pine-script/request-security covers request.security() and request.financial(), and https://docs.darvas.app/pine-script/limits lists the run limits.
> Darvas Pro+ webhooks send a signed POST for alarm fires and pauses, scheduled answers, economic calendar alerts, ETF flow updates, ended connections and the data API events. https://docs.darvas.app/pro/webhooks lists every event, its object and how to verify the Darvas-Signature header.

# Financial Data Webhooks & HMAC Verification

> Get HMAC-SHA256 signed HTTPS webhooks when new SEC filings, earnings, statements, insider forms or macro releases arrive, then fetch the rows with your key.

A webhook destination is an HTTPS URL that receives an event each time Darvas stores new data of the types you choose. Darvas sends the event as soon as it stores the data, usually within a second.

## Create a destination

```bash theme={null}
curl -X POST "https://api.darvas.app/v1/webhooks" \
  -H "X-API-KEY: $DARVAS_API_KEY" -H "Content-Type: application/json" \
  -d '{"url": "https://hooks.example.com/darvas", "events": ["earnings.created", "insider_trades.created"]}'
```

The answer carries the destination and its signing secret, `whsec_...`. The secret is shown this once; keep it with your server. `GET /webhooks` lists your destinations without secrets, `DELETE /webhooks/{webhook_id}` removes one, and `POST /webhooks/{webhook_id}/test` sends it a test event with `livemode: false` within a second. You can send one test event a minute.

The account's unified plan sets how many destinations can be active: `0` on Darvas Free, `5` on Darvas Pro (`$20/mo`, or free with an active OKX affiliate account generating positive commission in the trailing 180 days), `25` on Darvas Max, and `100` on Darvas Ultra. A destination over the limit is refused with `400 LIMIT_REACHED`. The URL must use HTTPS and reach a public address: private, loopback and link-local addresses are refused when the destination is made and again at every delivery.

## Events

| Family | Event types | `data.object` |
| - | - | - |
| Earnings | `earnings.created` | The filing: `ticker`, `cik`, `accession_number`, `form_type`, `filing_date`, `report_period`, `url` |
| Financial statements | `income_statements.created`, `balance_sheets.created`, `cash_flow_statements.created`, `financial_metrics.created` | The same |
| Segments | `income_statement_segments.created`, `balance_sheet_segments.created`, `cash_flow_statement_segments.created` | The same |
| Earnings releases | `operating_kpis.created`, `forward_guidance.created`, `non_gaap_metrics.created` | The same, and `metrics`, the names read |
| Insider activity | `insider_trades.created`, `insider_ownership.created`, `insider_sale_notices.created` | The same |
| Filings | `filing_items.metadata.created` | The same, and `available_items` |
| Macro | `yield_curve.created`, `inflation.created`, `labor.created`, `gdp.created`, `interest_rates.created` | `dataset`, `date`, `series` (or `banks`) and `url` |

`url` is the API request that answers the new rows: an event tells you what changed, and you fetch the data with your key. Statement events come only for filings of the last three days, so the nightly rebuild of older statements sends nothing.

[Darvas workspace webhooks](https://docs.darvas.app/pro/webhooks.md) (included in Darvas Pro, Max, and Ultra) receive these events too, along with alarm, schedule, economic calendar, ETF flow and connection events.

## Deliveries

Each delivery is a POST of a JSON envelope:

```json theme={null}
{
  "id": "evt_5f0c3a1b9d2e4f6a7b8c9d0e1f2a3b4c",
  "type": "income_statements.created",
  "api_version": "2026-11-26",
  "livemode": true,
  "created": 1795687200,
  "data": {
    "object": {
      "ticker": "AAPL",
      "cik": 320193,
      "accession_number": "0000320193-26-000106",
      "form_type": "10-Q",
      "filing_date": "2026-11-25",
      "report_period": "2026-09-27",
      "url": "https://api.darvas.app/v1/financials/income-statements?cik=320193&period=quarterly&limit=1"
    }
  }
}
```

The headers are `Content-Type: application/json`, `User-Agent: Darvas-Webhook/1.0` and `Darvas-Signature: t=<unix seconds>,v1=<hex>`. A delivery succeeds on any 2xx answer within ten seconds; redirects are not followed. Each destination receives its events one at a time, oldest first, so a slow server delays only its own events. A failed delivery is tried again about a minute later and about ten minutes after that, then given up. A destination whose last 50 attempts failed is disabled: delete it and make a new one once your server answers. The same event can arrive twice and in any order, so use `id` to skip one you have seen.

## Verify the signature

`v1` is the HMAC-SHA256 of `{t}.{raw body}` under your secret. Compute it over the raw bytes you received, compare in constant time, and refuse a `t` more than five minutes from your clock.

```python theme={null}
import hashlib
import hmac
import time


def verify(secret: str, header: str, body: bytes) -> bool:
    parts = dict(part.split("=", 1) for part in header.split(","))
    timestamp = int(parts["t"])
    expected = hmac.new(secret.encode(), f"{timestamp}.".encode() + body, hashlib.sha256).hexdigest()
    return abs(time.time() - timestamp) <= 300 and hmac.compare_digest(expected, parts["v1"])
```

```javascript theme={null}
import { createHmac, timingSafeEqual } from "node:crypto";

export function verify(secret, header, body) {
  const parts = Object.fromEntries(header.split(",").map((part) => part.split("=")));
  const expected = createHmac("sha256", secret).update(`${parts.t}.${body}`).digest("hex");
  const fresh = Math.abs(Date.now() / 1000 - Number(parts.t)) <= 300;
  const given = Buffer.from(parts.v1 ?? "");
  return fresh && given.length === expected.length && timingSafeEqual(Buffer.from(expected), given);
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.