Technical Documentation

Everything you need to integrate WebSocks into your application. Real-time webhook delivery via SSE and WebSocket.

Quick Start

1. Create Your Account

Sign up with your email. No password required - we'll send you a magic link.

2. Get Your Webhook URL

After logging in, copy your unique webhook endpoint from the dashboard.

POST https://websocks.io/api/in/YOUR_UNIQUE_SLUG

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

POST/api/in/:slug

Receive webhook events from third-party services.

Request

Headers:

Content-Type: application/json

Body: Any valid JSON payload

Response Codes

200Success - Webhook received and forwarded
400Bad Request - Invalid JSON payload
402Payment Required - Monthly quota exceeded
404Not Found - Invalid webhook slug
500Server Error - Internal processing error
GET/api/events/stream

Server-Sent Events stream for real-time webhook delivery.

Query Parameters

token (required): Your API token from the dashboard

Example

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();
};
WSwss://ws.websocks.io

WebSocket endpoint for bidirectional real-time communication.

Query Parameters

token (required): Your API token from the dashboard

Browser 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 ws

Python

Use sseclient-py or websocket-client

pip install sseclient-py
pip install websocket-client

Go

Use gorilla/websocket or SSE libraries

go get github.com/gorilla/websocket
    Documentation - WebSocks | WebSocks