API Reference
Complete API documentation for MikroRoom’s HTTP REST endpoints and WebSocket signaling protocol.
Base URL
Section titled “Base URL”- Development:
http://localhost:3000 - Production:
https://yourdomain.com
HTTP Endpoints
Section titled “HTTP Endpoints”Health Check
Section titled “Health Check”Check server health and statistics.
GET /healthResponse (200 OK):
{ "status": "ok", "totalRooms": 5, "totalParticipants": 12, "peakParticipants": 24, "uptime": 3600000, "version": "1.0.0"}Fields:
status- Server status ("ok")totalRooms- Current active roomstotalParticipants- Current connected participantspeakParticipants- Peak participants since server startuptime- Server uptime in millisecondsversion- MikroRoom version
Configuration
Section titled “Configuration”Get ICE server configuration for WebRTC.
GET /configResponse (200 OK):
{ "iceServers": [ { "urls": "stun:stun.cloudflare.com:3478" }, { "urls": "turn:turn.yourdomain.com:3478", "username": "mikroroom", "credential": "password" } ]}Fields:
iceServers- Array of STUN/TURN server configurations
Create Room
Section titled “Create Room”Pre-create a room with optional password.
POST /api/roomsContent-Type: application/json
{ "roomId": "ABC123", "password": "secret", "maxParticipants": 8}Request Body (all fields optional):
roomId- Custom room ID (6 alphanumeric characters)password- Room password for entrymaxParticipants- Maximum participants (default: 8)
Response (201 Created):
{ "roomId": "ABC123", "creatorToken": "550e8400-e29b-41d4-a716-446655440000"}Fields:
roomId- The created room IDcreatorToken- Token for creator privileges (bypass waiting room, become host)
Error Responses:
429 Too Many Requests (rate limit exceeded):
{ "error": "Too many requests. Please try again later."}429 Too Many Requests (room limit reached):
{ "error": "Cannot create room. Limit reached or room ID already exists."}400 Bad Request (invalid request):
{ "error": "Invalid request body"}WebSocket API
Section titled “WebSocket API”Connect to WebSocket endpoint for signaling.
Connection
Section titled “Connection”const ws = new WebSocket('wss://yourdomain.com/ws');Endpoint: /ws
Message Format
Section titled “Message Format”All messages are JSON with this base structure:
{ "type": "message-type", "roomId": "ABC123", "participantId": "participant-uuid", "timestamp": 1234567890}Client → Server Messages
Section titled “Client → Server Messages”Messages sent from client to server.
Join Room
Section titled “Join Room”Join or create a meeting room.
{ "type": "join", "roomId": "ABC123", "participantId": "", "name": "John Doe", "password": "secret", "isHost": false, "creatorToken": "550e8400-e29b-41d4-a716-446655440000", "timestamp": 1234567890}Fields:
name- Participant’s display namepassword- Room password (if required)isHost- True if creating new roomcreatorToken- Creator token from/api/rooms(optional)
Response: Server sends participant-joined message.
Leave Room
Section titled “Leave Room”Leave the current room.
{ "type": "leave", "roomId": "ABC123", "participantId": "your-uuid", "timestamp": 1234567890}WebRTC Offer
Section titled “WebRTC Offer”Send WebRTC offer to peer.
{ "type": "offer", "roomId": "ABC123", "participantId": "your-uuid", "targetId": "peer-uuid", "sdp": "v=0\r\no=- ...", "timestamp": 1234567890}Fields:
targetId- Recipient participant IDsdp- WebRTC SDP offer
WebRTC Answer
Section titled “WebRTC Answer”Send WebRTC answer to peer.
{ "type": "answer", "roomId": "ABC123", "participantId": "your-uuid", "targetId": "peer-uuid", "sdp": "v=0\r\no=- ...", "timestamp": 1234567890}Fields:
targetId- Recipient participant IDsdp- WebRTC SDP answer
ICE Candidate
Section titled “ICE Candidate”Send ICE candidate to peer.
{ "type": "ice-candidate", "roomId": "ABC123", "participantId": "your-uuid", "targetId": "peer-uuid", "candidate": { "candidate": "candidate:...", "sdpMid": "0", "sdpMLineIndex": 0 }, "timestamp": 1234567890}Fields:
targetId- Recipient participant IDcandidate- ICE candidate object
Chat Message
Section titled “Chat Message”Send text message to room.
{ "type": "chat", "roomId": "ABC123", "participantId": "your-uuid", "text": "Hello everyone!", "replyTo": "message-id", "timestamp": 1234567890}Fields:
text- Message textreplyTo- ID of message being replied to (optional)
Update Participant State
Section titled “Update Participant State”Update own audio/video state.
{ "type": "participant-updated", "roomId": "ABC123", "participantId": "your-uuid", "isMuted": true, "isVideoOff": false, "isHandRaised": false, "timestamp": 1234567890}Fields:
isMuted- Audio muted stateisVideoOff- Video disabled stateisHandRaised- Hand raised state
Raise Hand
Section titled “Raise Hand”Raise hand for attention.
{ "type": "raise-hand", "roomId": "ABC123", "participantId": "your-uuid", "timestamp": 1234567890}Lower Hand
Section titled “Lower Hand”Lower raised hand.
{ "type": "lower-hand", "roomId": "ABC123", "participantId": "your-uuid", "timestamp": 1234567890}Moderator Actions
Section titled “Moderator Actions”Perform moderator actions (requires moderator privilege).
{ "type": "moderator-action", "roomId": "ABC123", "participantId": "your-uuid", "targetId": "target-uuid", "action": "mute", "timestamp": 1234567890}Actions:
mute- Mute participantunmute- Unmute participantkick- Remove participant from roommake-moderator- Grant moderator privileges
Lock Room
Section titled “Lock Room”Lock room to require moderator approval (moderator only).
{ "type": "room-locked", "roomId": "ABC123", "participantId": "your-uuid", "timestamp": 1234567890}Unlock Room
Section titled “Unlock Room”Unlock room (moderator only).
{ "type": "room-unlocked", "roomId": "ABC123", "participantId": "your-uuid", "timestamp": 1234567890}Admit User
Section titled “Admit User”Admit user from waiting room (moderator only).
{ "type": "admit-user", "roomId": "ABC123", "participantId": "your-uuid", "targetId": "waiting-user-uuid", "timestamp": 1234567890}Reject User
Section titled “Reject User”Reject user from waiting room (moderator only).
{ "type": "reject-user", "roomId": "ABC123", "participantId": "your-uuid", "targetId": "waiting-user-uuid", "reason": "Room is full", "timestamp": 1234567890}Server → Client Messages
Section titled “Server → Client Messages”Messages sent from server to client.
Participant Joined
Section titled “Participant Joined”New participant joined the room.
{ "type": "participant-joined", "roomId": "ABC123", "participantId": "new-participant-uuid", "name": "Jane Doe", "isModerator": false, "isMuted": false, "isVideoOff": false, "timestamp": 1234567890}Fields:
participantId- New participant’s IDname- Participant’s display nameisModerator- Moderator statusisMuted- Audio stateisVideoOff- Video state
Participant Left
Section titled “Participant Left”Participant left the room.
{ "type": "participant-left", "roomId": "ABC123", "participantId": "departed-uuid", "timestamp": 1234567890}Participant Updated
Section titled “Participant Updated”Participant’s state changed.
{ "type": "participant-updated", "roomId": "ABC123", "participantId": "participant-uuid", "isMuted": true, "isVideoOff": false, "isHandRaised": false, "timestamp": 1234567890}Waiting Room
Section titled “Waiting Room”User is in waiting room or new user waiting.
{ "type": "waiting-room", "roomId": "ABC123", "participantId": "waiting-uuid", "name": "Waiting User", "timestamp": 1234567890}Server error message.
{ "type": "error", "roomId": "", "participantId": "", "message": "Room is full", "code": "ROOM_FULL", "timestamp": 1234567890}Error Codes:
ROOM_FULL- Room has reached max participantsINVALID_PASSWORD- Incorrect room passwordROOM_NOT_FOUND- Meeting doesn’t existUNAUTHORIZED- Action requires moderator privileges
Rate Limiting
Section titled “Rate Limiting”Rate limits per IP address:
- WebSocket connections: 10 per minute
- Room creation: 10 per minute
Response on limit exceeded:
- WebSocket: Connection closed
- HTTP: 429 status code
MikroRoom allows cross-origin requests:
Access-Control-Allow-Origin: *Access-Control-Allow-Methods: GET, POST, OPTIONSAccess-Control-Allow-Headers: Content-TypeFor production, configure specific origins in reverse proxy.
Security Headers
Section titled “Security Headers”MikroRoom includes security headers:
X-Content-Type-Options: nosniffX-Frame-Options: DENYX-XSS-Protection: 1; mode=blockReferrer-Policy: strict-origin-when-cross-originExample Client Implementation
Section titled “Example Client Implementation”JavaScript/TypeScript
Section titled “JavaScript/TypeScript”// Connect to WebSocketconst ws = new WebSocket('wss://yourdomain.com/ws');
// Join roomws.send(JSON.stringify({ type: 'join', roomId: 'ABC123', participantId: '', name: 'John Doe', timestamp: Date.now()}));
// Handle messagesws.onmessage = (event) => { const message = JSON.parse(event.data);
switch (message.type) { case 'participant-joined': console.log(`${message.name} joined`); break; case 'chat': console.log(`${message.participantId}: ${message.text}`); break; case 'error': console.error(message.message); break; }};
// Send chatws.send(JSON.stringify({ type: 'chat', roomId: 'ABC123', participantId: 'your-uuid', text: 'Hello!', timestamp: Date.now()}));Next Steps
Section titled “Next Steps”- CLI & Server Options - Configuration reference
- Configuration Guide - Setup instructions