BanklyzeBanklyze/Developer Docs
Sign In

Real-Time Events

Subscribe to real-time pipeline progress via Server-Sent Events (SSE). As each stage of the analysis pipeline completes, Banklyze pushes a typed event to all active subscribers for that deal. This lets you build live progress indicators, trigger downstream actions immediately on completion, and avoid polling the deal endpoint.

The SSE stream is a persistent HTTP connection. Each event has a named event: type and a JSON data: payload. The stream closes automatically once all pending pipeline stages for the deal have completed, or after a 10-minute idle timeout.

Open a Server-Sent Events stream for a deal. Events are emitted as each pipeline stage finishes processing. If multiple documents are being processed simultaneously, events will be interleaved. Use the document_id query parameter to filter to a single document.

Because the browser EventSource API does not support custom headers, pass your API key as the token query parameter instead of the X-API-Key header when connecting from a browser.

Path Parameters

NameTypeRequiredDescription
deal_idintegerRequiredThe unique deal ID to subscribe to

Query Parameters

NameTypeRequiredDescription
document_idintegerOptionalFilter the event stream to a single document. When omitted, events from all documents attached to the deal are delivered.
tokenstringOptionalAPI key passed as a query parameter. Use this as an alternative to the X-API-Key header when connecting from a browser via EventSource, which does not support custom request headers.

Event Types

NameTypeRequiredDescription
extraction_completeeventOptionalText extracted from the document and document type classified. Payload includes page_count and document_type.
parse_completeeventOptionalLLM parsing complete — transactions are now available. Payload includes transaction_count and months_covered.
metrics_completeeventOptionalADB, monthly deposits, and NSF metrics computed. Payload includes avg_daily_balance, avg_monthly_deposits, and nsf_count.
screening_completeeventOptionalTransaction screening complete. Payload includes total_flags and a buckets breakdown by screening category.
scoring_completeeventOptionalHealth score and MCA composite score calculated. Payload includes health_score and health_grade.
deal_updatedeventOptionalDeal-level aggregation recalculated after all documents processed. Payload includes the updated deal status and aggregate metrics.

Example — curl

curl
curl -N -X GET "https://api.banklyze.com/v1/events/deals/42?token=your_api_key_here" \
  -H "Accept: text/event-stream"

Response — SSE stream

text/event-stream
event: extraction_complete
data: {"deal_id": 42, "document_id": 15, "document_type": "bank_statement", "page_count": 12, "timestamp": "2026-03-04T10:01:00Z"}

event: parse_complete
data: {"deal_id": 42, "document_id": 15, "transaction_count": 243, "months_covered": 3, "timestamp": "2026-03-04T10:01:08Z"}

event: metrics_complete
data: {"deal_id": 42, "document_id": 15, "avg_daily_balance": 34500.00, "avg_monthly_deposits": 125430.00, "nsf_count": 2, "timestamp": "2026-03-04T10:01:09Z"}

event: screening_complete
data: {"deal_id": 42, "document_id": 15, "total_flags": 2, "buckets": {"large_unusual_deposit": 1, "repeat_charge": 1}, "timestamp": "2026-03-04T10:01:10Z"}

event: scoring_complete
data: {"deal_id": 42, "document_id": 15, "health_score": 72.5, "health_grade": "B", "timestamp": "2026-03-04T10:01:11Z"}

event: deal_updated
data: {"deal_id": 42, "status": "ready", "health_score": 72.5, "health_grade": "B", "avg_monthly_deposits": 125430.00, "timestamp": "2026-03-04T10:01:12Z"}

Example — JavaScript EventSource

JavaScript
const es = new EventSource("https://api.banklyze.com/v1/events/deals/42?token=your_api_key_here");

es.addEventListener("extraction_complete", (e) => {
  const data = JSON.parse(e.data);
  console.log(`Document ${data.document_id} text extracted (${data.page_count} pages)`);
});

es.addEventListener("parse_complete", (e) => {
  const data = JSON.parse(e.data);
  console.log(`Parsed ${data.transaction_count} transactions over ${data.months_covered} months`);
});

es.addEventListener("metrics_complete", (e) => {
  const data = JSON.parse(e.data);
  console.log(`ADB: $${data.avg_daily_balance.toLocaleString()}, AMD: $${data.avg_monthly_deposits.toLocaleString()}`);
});

es.addEventListener("screening_complete", (e) => {
  const data = JSON.parse(e.data);
  console.log(`Screening complete — ${data.total_flags} flags found`);
});

es.addEventListener("scoring_complete", (e) => {
  const data = JSON.parse(e.data);
  console.log(`Document ${data.document_id} scored`);
});

es.addEventListener("deal_updated", (e) => {
  const data = JSON.parse(e.data);
  console.log(`Deal ${data.deal_id} is now ${data.status} with grade ${data.health_grade}`);
  es.close();
});

es.onerror = (err) => {
  console.error("SSE connection error", err);
  es.close();
};