Skip to main content

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

  1. Connect: Establish WebSocket connection with campaign ID and token
  2. Receive Acknowledgment: Server confirms connection
  3. Get Initial Data: Receive current progress state
  4. Stream Updates: Receive real-time progress updates
  5. 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 to request_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

Campaign Status Values

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

Authentication Errors

If authentication fails, the connection is immediately closed with code 1008:

Best Practices

  1. Always authenticate: Include valid API key in query parameter
  2. Implement ping/pong: Send pings every 30 seconds to keep connection alive
  3. Handle reconnection: Implement exponential backoff for reconnection
  4. Process all message types: Handle connection_ack, initial_progress, progress_update
  5. Monitor connection state: Track open/close events for UI feedback
  6. 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.