Endpoints
Complete HTTP REST API specification for triggering events, querying channels, and managing connections.
REST API Endpoints
Socketo provides a Pusher-compatible HTTP REST API for triggering server-to-client events, querying channel occupancy, and managing connected users.
Base URLs
- Socketo Cloud:
https://api.socketo.dev - Socketo Local CLI:
http://localhost:8787 - Self-Hosted:
https://<your-worker-domain>
Authentication
All REST endpoints under /apps/:id/* require Pusher Channels HMAC-SHA256 authentication passed as URL query parameters.
Required Query Parameters
| Parameter | Type | Description |
|---|---|---|
auth_key | string | Your public application key. |
auth_timestamp | number | Unix timestamp in seconds (valid within ±600 seconds of server time). |
auth_version | string | Must be exactly "1.0". |
body_md5 | string | Hex MD5 digest of the request body (required for POST, PUT, PATCH). |
auth_signature | string | HMAC-SHA256 hash of METHOD\nPATH\nQUERY_STRING signed with app_secret. |
Official Pusher server SDKs handle signature generation automatically. See Auth & Signatures to sign requests manually.
1. Trigger Event
Publish an event to one or more channels (up to 100 channels).
POST /apps/:id/eventsRequest Body
{
"name": "new-message",
"channels": ["chat-room-1", "chat-room-2"],
"data": "{\"text\":\"Hello world!\",\"author\":\"Alice\"}",
"socket_id": "1234.5678",
"info": "user_count"
}| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Event name. |
data | string | Yes | Event payload as a serialized JSON string (max 10 KiB). |
channels | string[] | Yes* | Array of target channel names (1–100 channels). Provide either channels or channel. |
channel | string | Yes* | Single target channel name. Provide either channels or channel. |
socket_id | string | No | Exclude a specific connection from receiving the broadcast. |
info | string | No | Comma-separated metadata to return: user_count (presence channels only) or subscription_count (non-presence). |
Response (200 OK)
{}When info attribute is included in the request body:
{
"channels": {
"presence-room-1": {
"user_count": 4
}
}
}2. Batch Trigger Events
Publish up to 10 distinct events in a single network request.
POST /apps/:id/batch_eventsRequest Body
{
"batch": [
{
"channel": "orders",
"name": "order-created",
"data": "{\"order_id\":\"ord_101\"}"
},
{
"channel": "presence-lobby",
"name": "announcement",
"data": "{\"msg\":\"Server restart in 5m\"}",
"info": "user_count"
}
]
}| Field | Type | Required | Description |
|---|---|---|---|
batch | object[] | Yes | Array of 1 to 10 event objects. |
batch[].channel | string | Yes | Target channel name. |
batch[].name | string | Yes | Event name. |
batch[].data | string | Yes | Serialized JSON data payload (max 10 KiB). |
batch[].socket_id | string | No | Excluded socket ID. |
batch[].info | string | No | Optional metadata attributes (user_count, subscription_count). |
Response (200 OK)
{
"batch": [
{},
{ "user_count": 12 }
]
}3. Get Active Sockets Count
Retrieve the total count of active WebSocket connections for your application.
GET /apps/:id/socketsResponse (200 OK)
{
"sockets": 142
}4. List Occupied Channels
Retrieve a list of currently active channels that have at least one subscriber.
GET /apps/:id/channelsQuery Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
filter_by_prefix | string | No | Filter channels starting with a prefix (e.g. presence- or private-). |
info | string | No | Additional metadata attributes (user_count). Requires filter_by_prefix=presence-. |
Response (200 OK)
{
"channels": {
"presence-room-1": { "user_count": 3 },
"presence-room-2": { "user_count": 1 },
"public-feed": {}
}
}5. Get Channel Info
Retrieve occupancy and subscriber metadata for a single channel.
GET /apps/:id/channels/:channel_nameQuery Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
info | string | No | Comma-separated attributes: user_count (presence channels only) or subscription_count (non-presence channels). |
Response (200 OK)
{
"occupied": true,
"user_count": 5
}If the channel currently has no active subscribers:
{
"occupied": false
}6. Get Presence Channel Users
Retrieve a list of all user IDs currently online in a specific presence channel.
GET /apps/:id/channels/:channel_name/usersNote: Only valid for channels prefixed with
presence-.
Response (200 OK)
{
"users": [
{ "id": "user_101" },
{ "id": "user_102" },
{ "id": "user_103" }
]
}7. Terminate User Connections
Forcefully disconnect and terminate all active WebSocket connections belonging to a specific user_id.
POST /apps/:id/users/:user_id/terminate_connectionsResponse (200 OK)
{}Terminated connections receive a WebSocket close frame with code 4200.
8. Send Event to User
Send an event directly to all active WebSocket connections belonging to an authenticated user_id.
Socketo delivers the event with wire channel #server-to-user-<user_id>, which automatically triggers callbacks registered via pusher.user.bind(eventName, callback) in the official pusher-js SDK.
You can also trigger user events using the official Pusher backend SDK method
pusher.sendToUser(userId, name, data).
POST /apps/:id/users/:user_id/eventsRequest Body
{
"name": "notification",
"data": {
"title": "New Alert",
"message": "You have a new update."
}
}Response (200 OK)
{}Error Status Codes
| HTTP Code | Description |
|---|---|
400 Bad Request | Missing required fields, invalid JSON, or invalid info attribute query. |
401 Unauthorized | Invalid HMAC signature, missing auth query parameters, or timestamp expired (> 600s). |
403 Forbidden | Application is disabled or suspended. |
404 Not Found | Application ID not found or non-existent endpoint. |
429 Too Many Requests | Edge rate limit exceeded. |