Technical Documentation
Everything you need to integrate WebSocks into your application. Real-time webhook delivery via SSE and WebSocket.
Quick Start
2. Get Your Webhook URL
After logging in, copy your unique webhook endpoint from the dashboard.
3. Send Webhooks
POST any JSON payload to your webhook URL. We'll forward it in real-time.
curl -X POST https://websocks.io/api/in/YOUR_SLUG \
-H "Content-Type: application/json" \
-d '{"event": "user.signup", "email": "test@example.com"}'4. Receive Events
Connect to our SSE or WebSocket endpoint to receive webhooks in real-time.
const ws = new WebSocket('wss://ws.websocks.io?token=YOUR_TOKEN');
ws.onmessage = (event) => {
const webhook = JSON.parse(event.data);
console.log('Received:', webhook);
};Architecture
How It Works
1. Webhook Ingestion: Third-party services POST webhooks to your unique URL endpoint.
2. Authentication: We validate the slug and check your usage quota against your subscription tier.
3. Real-Time Broadcast: Events are immediately broadcast via Server-Sent Events (SSE) to connected clients.
4. WebSocket Support: Connect via standard WebSocket protocol for bidirectional communication.
Event Flow Diagram
Third-Party Service
│
│ POST /api/in/:slug
▼
┌──────────────────┐
│ Webhook Endpoint │──── Validate slug & quota
└──────────────────┘
│
▼
┌──────────────────┐
│ Event Broker │──── Broadcast to all connected clients
└──────────────────┘
│
├──────────► SSE Clients (EventSource API)
│
└──────────► WebSocket Clients (ws:// protocol)API Reference
/api/in/:slugReceive webhook events from third-party services.
Request
Headers:
Content-Type: application/jsonBody: Any valid JSON payload
Response Codes
200Success - Webhook received and forwarded400Bad Request - Invalid JSON payload402Payment Required - Monthly quota exceeded404Not Found - Invalid webhook slug500Server Error - Internal processing error/api/events/streamServer-Sent Events stream for real-time webhook delivery.
Query Parameters
token (required): Your API token from the dashboardExample
const eventSource = new EventSource(
'https://websocks.io/api/events/stream?token=YOUR_TOKEN'
);
eventSource.onopen = () => {
console.log('Connected to WebSocks SSE');
};
eventSource.onmessage = (event) => {
const data = JSON.parse(event.data);
if (data.type === 'webhook') {
console.log('Webhook received:', data.payload);
}
};
eventSource.onerror = (error) => {
console.error('SSE error:', error);
eventSource.close();
};wss://ws.websocks.ioWebSocket endpoint for bidirectional real-time communication.
Query Parameters
token (required): Your API token from the dashboardBrowser Example
const ws = new WebSocket('wss://ws.websocks.io?token=YOUR_TOKEN');
ws.onopen = () => {
console.log('Connected to WebSocks WebSocket');
};
ws.onmessage = (event) => {
const webhook = JSON.parse(event.data);
console.log('Webhook received:', webhook);
};
ws.onerror = (error) => {
console.error('WebSocket error:', error);
};
ws.onclose = () => {
console.log('Disconnected from WebSocks');
};Node.js Example
const WebSocket = require('ws');
const ws = new WebSocket('wss://ws.websocks.io?token=YOUR_TOKEN');
ws.on('open', () => {
console.log('Connected to WebSocks WebSocket');
});
ws.on('message', (data) => {
const webhook = JSON.parse(data);
console.log('Webhook received:', webhook);
});
ws.on('error', (error) => {
console.error('WebSocket error:', error);
});
ws.on('close', () => {
console.log('Disconnected from WebSocks');
});Billing & Security
Usage-Based Pricing
Free Tier: 1,000 webhook requests per month
Pro Tier: $0.0001 per request (pay only for what you use)
Billing: Monthly invoices generated automatically based on actual usage
Limits: Adjustable requests/month limits to prevent suprise bills
Security & Isolation
Unique Slugs: Each user gets a unique webhook endpoint
API Tokens: Secure tokens for SSE/WebSocket authentication
User Isolation: All events are scoped per user - no cross-user data access
Quota Enforcement: Requests blocked when monthly limit exceeded
WebSocket Support
Real-Time Bidirectional Communication
WebSocks provides a WebSocket endpoint for real-time, bidirectional communication. Connect using standard WebSocket clients in any language.
Connection Flow
1. Client Connection: Your application connects to wss://ws.websocks.io?token=YOUR_TOKEN
2. Authentication: Your API token is validated and linked to your account
3. Real-Time Events: Webhooks are instantly pushed to your WebSocket connection
4. Automatic Reconnection: Implement reconnection logic for robust production deployments
Benefits
Low Latency
Events delivered in milliseconds
Secure Connection
TLS encryption for all data
Standard Protocol
Works with any WebSocket client library
Global Edge Network
Fast connections worldwide
Language SDKs
JavaScript/Node.js
Use native EventSource or WebSocket APIs
npm install --save eventsource
npm install --save wsPython
Use sseclient-py or websocket-client
pip install sseclient-py
pip install websocket-clientGo
Use gorilla/websocket or SSE libraries
go get github.com/gorilla/websocket