Events API
Subscribe to real-time Server-Sent Events (SSE) for processing progress, status changes, and batch updates. Events are delivered as a persistent HTTP stream using the text/event-stream content type.
Event Format
Each event follows the standard SSE format with an event: field indicating the type and a data: field containing a JSON payload. Events are separated by double newlines.
Authentication is passed via the token query parameter since the browser EventSource API does not support custom headers. Use your API key as the token value.
Reconnection
If the connection drops, the browser's EventSource API automatically reconnects. The server sends a retry: field to control the reconnection interval (default: 3 seconds). Missed events during disconnection are not replayed — poll the REST API for current state after reconnecting.
Endpoints
Opens a persistent SSE connection that streams all events related to a specific deal, including document processing progress, status changes, and scoring updates.
| Name | Type | Required | Description |
|---|---|---|---|
| deal_id | integer | Required | The deal ID to subscribe to |
| token | string | Required | API key passed as a query parameter for authentication |
Event types
| Name | Type | Required | Description |
|---|---|---|---|
| processing.started | event | Optional | Document processing has begun for a statement |
| processing.progress | event | Optional | Processing stage update with percentage progress |
| processing.completed | event | Optional | Processing finished successfully with final health score |
| processing.failed | event | Optional | Processing encountered an unrecoverable error |
| deal.status_changed | event | Optional | Deal status transitioned (e.g., processing to under_review) |
event: processing.started
data: {"deal_id": 42, "statement_id": 101, "stage": "extracting_text", "progress": 0}
event: processing.progress
data: {"deal_id": 42, "statement_id": 101, "stage": "parsing_with_llm", "progress": 40}
event: processing.progress
data: {"deal_id": 42, "statement_id": 101, "stage": "screening", "progress": 70}
event: processing.completed
data: {"deal_id": 42, "statement_id": 101, "stage": "completed", "progress": 100, "health_score": 72.5}
event: deal.status_changed
data: {"deal_id": 42, "old_status": "processing", "new_status": "under_review"}Opens a persistent SSE connection that streams all events across the entire organization. Useful for dashboards, activity feeds, and monitoring tools that need a global view.
| Name | Type | Required | Description |
|---|---|---|---|
| token | string | Required | API key passed as a query parameter for authentication |
event: deal.created
data: {"deal_id": 43, "business_name": "Bolt Logistics Inc", "created_by": "user@company.com"}
event: processing.completed
data: {"deal_id": 42, "statement_id": 101, "health_score": 72.5}
event: deal.decision
data: {"deal_id": 42, "decision": "approved", "decided_by": "underwriter@company.com"}Opens a persistent SSE connection for tracking the progress of a bulk ingest batch. Emits events as individual documents within the batch are processed, and a final completion event when all documents are done.
| Name | Type | Required | Description |
|---|---|---|---|
| batch_id | string | Required | The batch ID returned from the bulk ingest endpoint |
| token | string | Required | API key passed as a query parameter for authentication |
event: batch.document_processed
data: {"batch_id": "batch_abc123", "document_id": 201, "status": "completed", "progress": "3/5"}
event: batch.document_failed
data: {"batch_id": "batch_abc123", "document_id": 202, "error": "Unsupported file format"}
event: batch.completed
data: {"batch_id": "batch_abc123", "total": 5, "succeeded": 4, "failed": 1}Client Examples
JavaScript (EventSource)
The browser-native EventSource API handles connection management and automatic reconnection.
const eventSource = new EventSource(
'https://api.banklyze.com/v1/events/deals/42?token=sk_live_abc123'
);
eventSource.addEventListener('processing.progress', (event) => {
const data = JSON.parse(event.data);
console.log(`Stage: ${data.stage}, Progress: ${data.progress}%`);
});
eventSource.addEventListener('processing.completed', (event) => {
const data = JSON.parse(event.data);
console.log(`Done! Health score: ${data.health_score}`);
eventSource.close();
});
eventSource.onerror = (event) => {
console.error('SSE connection error, will auto-reconnect...');
};Python (sseclient)
Use the sseclient-py package with requests for streaming from Python.
import sseclient
import requests
url = "https://api.banklyze.com/v1/events/deals/42"
headers = {"Accept": "text/event-stream"}
params = {"token": "sk_live_abc123"}
response = requests.get(url, headers=headers, params=params, stream=True)
client = sseclient.SSEClient(response)
for event in client.events():
print(f"Event: {event.event}")
print(f"Data: {event.data}")
if event.event == "processing.completed":
breakcURL
Use the -N flag to disable buffering and see events in real time.
curl -N "https://api.banklyze.com/v1/events/deals/42?token=sk_live_abc123"SSE connections count toward your rate limit while open. Close the connection when you no longer need updates to free up capacity.