> A bolsix.io page, as Markdown. Index of every page: https://bolsix.io/llms.txt
> Connecting Bolsix to an agent? Follow https://bolsix.io/agent-quickstart.md
> Source: https://bolsix.io/docs/webhooks

Integrations

# Webhooks

Instead of polling for new filings, register a URL and Bolsix POSTs a signed event to it within minutes of ingesting a filing or a dividend declaration.

## Events

`filing.created`: a new CVM filing (fato relevante, results, shareholder notice, dividend notice, calendar and more) for a company you follow. Bolsix reads CVM's IPE file daily at 08:00 UTC, so filings arrive in a morning batch.

`results.published`: a company filed its results (category `resultado`: financial statements, earnings releases), the filings behind `GET /v1/stocks/calendar`. Same body and timing as its `filing.created`, for endpoints that want only results. The figures reach `GET /v1/stocks/statements` after the weekly fundamentals run (Sundays), so they can lag the event by up to a week.

`dividend.declared`: a new dividend, JCP or return of capital for a ticker you follow, as B3 lists it (its daily list is read at 11:00 UTC). `amount` is gross, per share of its data com; a JCP is withheld at source when paid (15% before 2026, 17.5% from 2026-01-01). B3 sometimes adds a payment date later; that isn't a new event, so read it from `GET /v1/stocks/dividends`.

## Subscribe

`POST /v1/webhooks` with an https `url`, the `events`, and which companies: `symbols` (a list of tickers), `watchlist: true` (this API key's watchlist, as it is when each filing arrives), or neither for every company. The response carries the endpoint's `secret`, shown only once: keep it to verify deliveries. A webhook belongs to the API key that created it and is deleted with it; a key holds at most 5 (409 `webhook_limit_exceeded`).

```
curl -X POST https://api.bolsix.io/v1/webhooks \
  -H "Authorization: Bearer bx_live_..." \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com/bolsix", "events": ["filing.created"], "watchlist": true}'
```

* `GET /v1/webhooks`: this key's webhooks and their status.
* `DELETE /v1/webhooks/{webhook_id}`: delete one and its delivery log.
* `GET /v1/webhooks/{webhook_id}/deliveries`: the delivery log, newest first, kept for 30 days.
* `POST /v1/webhooks/{webhook_id}/test`: send a `webhook.test` event now and see the result.

Managing webhooks counts against the request quota like any call; deliveries do not.

## Payload

Deliveries follow [Standard Webhooks](https://www.standardwebhooks.com). The body carries `type`, `timestamp` and `data`, enough to act without a follow-up call. `timestamp` is when Bolsix ingested the filing or distribution; a filing's `symbols` lists the company's active tickers and `doc_url` opens the document on CVM's site.

### `filing.created`

```
{
  "type": "filing.created",
  "timestamp": "2026-09-20T08:04:11Z",
  "data": {
    "symbols": ["PETR3", "PETR4"],
    "cvm_code": "9512",
    "company_name": "PETRÓLEO BRASILEIRO S.A. - PETROBRAS",
    "category": "comunicado",
    "category_raw": "Comunicado ao Mercado",
    "type": "Outros Comunicados Não Considerados Fatos Relevantes",
    "especie": null,
    "subject": "Petrobras recebe nova parcela de Subvenção Econômica à Gasolina",
    "reference_date": "2026-09-19",
    "filed_at": "2026-09-19",
    "protocol": "009512IPE190920260185210248-55",
    "version": 1,
    "doc_url": "https://www.rad.cvm.gov.br/ENET/frmDownloadDocumento.aspx?Tela=ext&descTipo=IPE&CodigoInstituicao=1&numProtocolo=1569746&numSequencia=1094452&numVersao=1"
  }
}
```

### `dividend.declared`

Illustrative example: the values are made up.

```
{
  "type": "dividend.declared",
  "timestamp": "2026-10-03T11:02:37Z",
  "data": {
    "symbol": "PETR4",
    "event_type": "jcp",
    "amount": 0.1234,
    "amount_basis": "gross",
    "com_date": "2026-10-15",
    "payment_date": "2026-11-28",
    "approved_on": "2026-10-02",
    "installment": 1,
    "isin": "BRPETRACNPR6",
    "label": "JRS CAP PROPRIO",
    "source": "b3"
  }
}
```

## Verify the signature

Every delivery has three headers. `webhook-id` is the delivery's id, the same on every retry: use it to ignore a delivery you have already processed. `webhook-timestamp` is Unix seconds. `webhook-signature` is `v1,` followed by the base64 HMAC-SHA256 of `{webhook-id}.{webhook-timestamp}.{raw body}`, keyed by the base64-decoded part of your `whsec_` secret. Verify it over the raw body, before parsing the JSON. The Standard Webhooks libraries do this for you.

```
import base64, hashlib, hmac, time

def verify(secret: str, headers, body: bytes, tolerance: int = 300) -> bool:
    msg_id = headers["webhook-id"]
    timestamp = headers["webhook-timestamp"]
    if abs(time.time() - int(timestamp)) > tolerance:
        return False  # too old or too new: a replay
    key = base64.b64decode(secret.removeprefix("whsec_"))
    signed = f"{msg_id}.{timestamp}.".encode() + body
    expected = base64.b64encode(hmac.new(key, signed, hashlib.sha256).digest()).decode()
    return any(hmac.compare_digest(expected, sig.removeprefix("v1,"))
               for sig in headers["webhook-signature"].split())
```

```
import { createHmac, timingSafeEqual } from "node:crypto";

export function verify(secret, headers, rawBody, tolerance = 300) {
  const id = headers["webhook-id"];
  const timestamp = headers["webhook-timestamp"];
  if (Math.abs(Date.now() / 1000 - Number(timestamp)) > tolerance) return false;
  const key = Buffer.from(secret.replace(/^whsec_/, ""), "base64");
  const expected = createHmac("sha256", key).update(`${id}.${timestamp}.${rawBody}`).digest();
  return headers["webhook-signature"].split(" ").some((sig) => {
    const given = Buffer.from(sig.replace(/^v1,/, ""), "base64");
    return given.length === expected.length && timingSafeEqual(given, expected);
  });
}
```

## Retries and disabling

Answer with any 2xx within 10 seconds; the response body is ignored and redirects are not followed. Anything else is retried after 5 seconds, 5 minutes, 30 minutes, 2, 5, 10 and 10 hours, about a day in all, and then marked failed. An endpoint is disabled when a delivery fails all its attempts and the endpoint accepted nothing else that day, or at once when it answers `410 Gone`. The endpoint's `disabled_reason` says which. A disabled webhook receives nothing. Fix the receiver and send a test: a delivered test turns it back on, and filings from the last two days that it missed are then delivered.

## Where deliveries can go

The URL must be https on port 443 or 8443 and resolve only to public internet addresses; private, loopback, link-local and reserved addresses are refused, both when the webhook is created and at each delivery. Deliveries come from Bolsix's servers with the User-Agent `Bolsix-Webhooks/1.0`.
