Real-time Updates

Connect to HookWatch via WebSocket to receive webhook events in real-time. Perfect for live dashboards, instant notifications, and debugging.

Connecting

Connect to the WebSocket endpoint with your access token as a query parameter.

WebSocket URL

wss://ws.hookwatch.dev/v1/ws?token=YOUR_ACCESS_TOKEN

Example

JavaScript

Message Types

Subscribe

Subscribe to receive events from specific endpoints.

Client → Server

Unsubscribe

Stop receiving events from specific endpoints.

Client → Server

Event

Received when a new webhook arrives at a subscribed endpoint.

Server → Client

Status Update

Received when a webhook event's delivery status changes.

Server → Client

Connection Lifecycle

1

Connect

Establish a WebSocket connection with your access token. The server validates your token and establishes the connection.

2

Subscribe

Send a subscribe message with the endpoint IDs you want to monitor. You can subscribe to multiple endpoints in a single message.

3

Receive Events

The server pushes events and status updates as they occur. Process these messages to update your UI or trigger actions.

4

Keep Alive

The server sends periodic ping messages. Your client should respond with pong to keep the connection alive. Most WebSocket libraries handle this automatically.

Best Practices

Reconnection

Implement automatic reconnection with exponential backoff. Network issues are common, and your app should handle disconnections gracefully.

Token Refresh

Access tokens expire after 15 minutes. Refresh your token before it expires and reconnect with the new token to avoid interruptions.

Rate Limiting

Don't open multiple connections for the same user. Use a single connection and subscribe to multiple endpoints as needed.

Error Handling

Close CodeReasonAction
1000Normal closureConnection closed cleanly, reconnect if needed
4001UnauthorizedInvalid or expired token, refresh and reconnect
4002Invalid messageCheck message format and retry
4029Rate limitedToo many connections, wait and retry

Related