Skip to content

WebSocket API

Subscribe to live webhook events for an endpoint with one long-lived connection. You need an API key created in the web app.

Connection URL

wss://api.hooknexus.com/ws/:endpointId?apikey=<your_api_key>
  • Replace :endpointId with your endpoint’s ID (UUID from the dashboard).
  • Replace <your_api_key> with the secret you copied when the key was created (URL-encode it if it contains special characters).

The key must belong to the same account as the endpoint, and your plan must allow API keys and WebSocket usage.


Server message types

Messages are JSON with a type field and a numeric timestamp (milliseconds).

TypePurpose
connectedSent right after the connection opens; may include a small payload (for example a connection id).
new_requestFired when a webhook hits your /h/:endpointId URL; payload contains the captured request (method, path, headers, query, body, etc.).
errorDescribes a connection or processing error.
pongReply to a client ping.

Client ping / pong

Send a JSON text frame:

{ "type": "ping" }

The server responds with:

{ "type": "pong", "timestamp": 1711180800123 }

Examples

const endpointId = 'YOUR_ENDPOINT_ID';
const apiKey = 'YOUR_API_KEY';
const ws = new WebSocket(
`wss://api.hooknexus.com/ws/${endpointId}?apikey=${encodeURIComponent(apiKey)}`
);
ws.addEventListener('open', () => {
console.log('connected');
});
ws.addEventListener('message', (ev) => {
const msg = JSON.parse(ev.data);
if (msg.type === 'new_request') {
console.log('Webhook:', msg.payload?.method, msg.payload?.body);
}
});

Example new_request envelope

{
"type": "new_request",
"timestamp": 1711180800123,
"payload": {
"id": "log-uuid",
"method": "POST",
"path": "/h/your-endpoint-id",
"headers": { "content-type": "application/json" },
"query": {},
"body": "{}",
"contentType": "application/json",
"ip": "203.0.113.10",
"size": 2,
"createdAt": "2026-03-23T12:00:00.000Z"
}
}