WebSocket Endpoint
Endpoint:wss://api.burki.dev/ws/campaigns/{campaign_id}/progress?token={api_key}
This WebSocket endpoint provides real-time streaming of campaign progress updates. Use it to build live monitoring dashboards without polling.
Path Parameters
campaign_id(integer, required): The ID of the campaign to monitor
Authentication
Required: All connections must be authenticated using a valid API key. Pass your API key as a query parameter:Connection Process
- Connect: Establish WebSocket connection with campaign ID and token
- Receive Acknowledgment: Server confirms connection
- Get Initial Data: Receive current progress state
- Stream Updates: Receive real-time progress updates
- Handle Events: Process contact completions, failures, etc.
Server-to-Client Messages
Connection Acknowledgment
Sent immediately after connection is established:Initial Progress
Current campaign state sent after connection:Progress Update
Sent whenever progress changes (contact completed, failed, etc.):Metrics History
Response torequest_history client message:
Pong Response
Response to ping health check:Client-to-Server Messages
Ping (Health Check)
Send periodically to maintain connection:Request Update
Request current progress on demand:Request History
Request historical metrics (last N hours):Progress Fields
| Field | Type | Description |
|---|---|---|
total_contacts | integer | Total contacts in campaign |
completed | integer | Successfully contacted |
failed | integer | Failed contact attempts |
processing | integer | Currently being contacted |
pending | integer | Waiting to be contacted |
progress_percentage | float | Completion percentage |
success_rate | float | Success rate percentage |
Campaign Status Values
| Status | Description |
|---|---|
draft | Not yet started |
scheduled | Waiting for scheduled time |
running | Actively executing |
paused | Temporarily paused |
completed | All contacts processed |
cancelled | Stopped before completion |
failed | Campaign error |
Example Usage
JavaScript
Python
React Hook Example
Connection Management
Reconnection Strategy
Implement exponential backoff for reconnection:Keep-Alive
Send ping messages every 30 seconds to maintain the connection:Error Handling
Close Codes
| Code | Description |
|---|---|
| 1000 | Normal closure |
| 1001 | Going away |
| 1008 | Authentication failed |
| 4000 | Internal server error |
| 4004 | Campaign not found |
Authentication Errors
If authentication fails, the connection is immediately closed with code 1008:Best Practices
- Always authenticate: Include valid API key in query parameter
- Implement ping/pong: Send pings every 30 seconds to keep connection alive
- Handle reconnection: Implement exponential backoff for reconnection
- Process all message types: Handle connection_ack, initial_progress, progress_update
- Monitor connection state: Track open/close events for UI feedback
- Clean up on unmount: Close WebSocket when component unmounts
Multi-Campaign Monitoring
To monitor multiple campaigns, use the campaigns monitor endpoint: Endpoint:wss://api.burki.dev/ws/campaigns/monitor?token={api_key}
This provides an overview of all campaigns in your organization with the ability to subscribe to specific campaigns.