Connections
Active connections, user management, and room broadcasting API
Connections API
Manage active WebSocket connections, users, and room operations.
Authentication Required: All connection management endpoints require authentication via Bearer token. These are administrative operations.
Get Active Connections
Authentication RequiredList all active WebSocket connections in the system. Rate-limited to 30 requests per minute.
Endpoint: GET /api/connections/active
curl -X GET "$BASE_URL/api/connections/active" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
interface Connection {
id: string
clientId: string
userId: string
roomId: string
presenterName: string
isHost: boolean
joinedAt: string
connectionStatus: 'connected' | 'disconnected'
}
const connections: Connection[] = await $fetch('/api/connections/active', {
headers: { Authorization: `Bearer ${token}` }
})
import requests
response = requests.get(
"$BASE_URL/api/connections/active",
headers={"Authorization": f"Bearer {token}"}
)
connections = response.json()
req, _ := http.NewRequest("GET",
"$BASE_URL/api/connections/active", nil)
req.Header.Set("Authorization", "Bearer "+token)
resp, _ := http.DefaultClient.Do(req)
<?php
$response = file_get_contents(
'$BASE_URL/api/connections/active',
false,
stream_context_create([
'http' => ['header' => "Authorization: Bearer $token"]
])
);
$connections = json_decode($response, true);
use reqwest::Client;
let client = Client::new();
let response = client
.get("$BASE_URL/api/connections/active")
.header("Authorization", format!("Bearer {}", token))
.send()
.await?;
Response:
[
{
"id": "client_550e8400",
"clientId": "client_550e8400",
"userId": "user_123",
"roomId": "ABC123",
"presenterName": "John Doe",
"isHost": true,
"joinedAt": "2024-01-15T10:30:00Z",
"connectionStatus": "connected"
}
]
Kick User
Authentication RequiredForcefully disconnect a user from the system. Rate-limited to 20 requests per minute.
Endpoint: POST /api/connections/{id}/kick
| Parameter | Type | Required | Description |
|---|---|---|---|
id | path | Yes | Client ID to disconnect |
curl -X POST "$BASE_URL/api/connections/client_550e8400/kick" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
const result = await $fetch('/api/connections/client_550e8400/kick', {
method: 'POST',
headers: { Authorization: `Bearer ${token}` }
})
import requests
response = requests.post(
"$BASE_URL/api/connections/client_550e8400/kick",
headers={"Authorization": f"Bearer {token}"}
)
req, _ := http.NewRequest("POST",
"$BASE_URL/api/connections/client_550e8400/kick", nil)
req.Header.Set("Authorization", "Bearer "+token)
resp, _ := http.DefaultClient.Do(req)
<?php
$response = file_get_contents(
'$BASE_URL/api/connections/client_550e8400/kick',
false,
stream_context_create([
'http' => [
'method' => 'POST',
'header' => "Authorization: Bearer $token"
]
])
);
let response = client
.post("$BASE_URL/api/connections/client_550e8400/kick")
.header("Authorization", format!("Bearer {}", token))
.send()
.await?;
Response:
{
"success": true,
"message": "Client disconnected"
}
Broadcast to Room
Authentication RequiredSend a message to all clients in a room. Rate-limited to 30 requests per minute.
Endpoint: POST /api/connections/rooms/{roomId}/broadcast
| Parameter | Type | Required | Description |
|---|---|---|---|
roomId | path | Yes | Room ID to broadcast to |
message | body | Yes | Message content |
curl -X POST "$BASE_URL/api/connections/rooms/ABC123/broadcast" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"message":"Session ending in 5 minutes"}'
await $fetch('/api/connections/rooms/ABC123/broadcast', {
method: 'POST',
headers: { Authorization: `Bearer ${token}` },
body: { message: 'Session ending in 5 minutes' }
})
import requests
response = requests.post(
"$BASE_URL/api/connections/rooms/ABC123/broadcast",
headers={"Authorization": f"Bearer {token}"},
json={"message": "Session ending in 5 minutes"}
)
payload := map[string]string{"message": "Session ending in 5 minutes"}
body, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST",
"$BASE_URL/api/connections/rooms/ABC123/broadcast",
bytes.NewBuffer(body))
req.Header.Set("Authorization", "Bearer "+token)
req.Header.Set("Content-Type", "application/json")
resp, _ := http.DefaultClient.Do(req)
<?php
$response = file_get_contents(
'$BASE_URL/api/connections/rooms/ABC123/broadcast',
false,
stream_context_create([
'http' => [
'method' => 'POST',
'header' => "Content-Type: application/json\r\n" .
"Authorization: Bearer $token",
'content' => json_encode(['message' => 'Session ending in 5 minutes'])
]
])
);
let response = client
.post("$BASE_URL/api/connections/rooms/ABC123/broadcast")
.header("Authorization", format!("Bearer {}", token))
.json(&json!({"message": "Session ending in 5 minutes"}))
.send()
.await?;
Response:
{
"success": true,
"message": "Message broadcast to 5 clients"
}
Close Room
Authentication RequiredClose a room and disconnect all clients. Rate-limited to 10 requests per minute.
Endpoint: POST /api/connections/rooms/{roomId}/close
| Parameter | Type | Required | Description |
|---|---|---|---|
roomId | path | Yes | Room ID to close |
curl -X POST "$BASE_URL/api/connections/rooms/ABC123/close" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
await $fetch('/api/connections/rooms/ABC123/close', {
method: 'POST',
headers: { Authorization: `Bearer ${token}` }
})
import requests
response = requests.post(
"$BASE_URL/api/connections/rooms/ABC123/close",
headers={"Authorization": f"Bearer {token}"}
)
req, _ := http.NewRequest("POST",
"$BASE_URL/api/connections/rooms/ABC123/close", nil)
req.Header.Set("Authorization", "Bearer "+token)
resp, _ := http.DefaultClient.Do(req)
<?php
$response = file_get_contents(
'$BASE_URL/api/connections/rooms/ABC123/close',
false,
stream_context_create([
'http' => [
'method' => 'POST',
'header' => "Authorization: Bearer $token"
]
])
);
let response = client
.post("$BASE_URL/api/connections/rooms/ABC123/close")
.header("Authorization", format!("Bearer {}", token))
.send()
.await?;
Response:
{
"success": true,
"message": "Room ABC123 closed, 5 clients disconnected"
}
Rate Limits
| Endpoint | Requests/Minute | Block Duration |
|---|---|---|
/api/connections/active | 30 | 1-10 minutes |
/api/connections/{id}/kick | 20 | 2-30 minutes |
/api/connections/rooms/{roomId}/broadcast | 30 | 1-10 minutes |
/api/connections/rooms/{roomId}/close | 10 | 3-60 minutes |
Repeated rate limit violations result in progressively longer block durations.