Skip to main content

API Reference

The TgoRTC server comes with built-in Swagger API documentation. This document provides detailed API interface specifications based on swagger.json.

Access Swagger UI

By default, you can directly access the Swagger UI through your browser after deployment: http://<SERVER_IP>:8080/swagger/index.html


1. Room Management API

Create Room

POST /api/v1/rooms

Creates a new audio/video room.

Request Parameters

Request Body (JSON):

ParameterTypeRequiredDescriptionExample
creatorstringYesRoom creator ID"user_001"
device_typestringYesDevice type (e.g. app, web, pc)"app"
room_idstringNoRoom ID (auto-generated if empty)"room_abc123"
rtc_typeintegerNoCall type (0: Audio, 1: Video)1
invite_onintegerNoEnable invitations (0: No, 1: Yes)1
max_participantsintegerNoMax participants (default 2)2
uidsstring[]NoList of invited user IDs["user_002"]
{
"creator": "user_001",
"device_type": "app",
"rtc_type": 1,
"invite_on": 1,
"max_participants": 2,
"uids": ["user_002"]
}

Invite Participants

POST /api/v1/rooms/{room_id}/invite

Invite other users to an existing room.

Request Parameters

Path Parameters:

  • room_id (string) - Required, Room ID

Request Body (JSON):

ParameterTypeRequiredDescription
uidsstring[]YesList of user IDs to invite
{
"uids": ["user_003"]
}

Join Room

POST /api/v1/rooms/{room_id}/join

Join a specific room. Returns the Token needed for connection upon success.

Request Parameters

Path Parameters:

  • room_id (string) - Required, Room ID

Request Body (JSON):

ParameterTypeRequiredDescription
uidstringYesUser ID
device_typestringNoDevice type
{
"uid": "user_002",
"device_type": "web"
}

Leave Room

POST /api/v1/rooms/{room_id}/leave

Participant proactively leaves the room.

Request Parameters

Path Parameters:

  • room_id (string) - Required, Room ID

Request Body (JSON):

ParameterTypeRequiredDescription
uidstringYesUser ID
{
"uid": "user_002"
}

Sync Active Rooms

GET /api/v1/rooms/sync

Synchronize the list of active rooms that a specific user has been invited to or joined. Commonly used for restoring room states during client reconnection or initialization.

Request Parameters (Query)
ParameterTypeRequiredDescriptionExample
uidstringYesUser IDuser_001
device_typestringYesDevice typeapp
GET /api/v1/rooms/sync?uid=user_001&device_type=app

2. Business Webhook Callbacks

POST /tgortc/webhook

The TgoRTC server will send event notifications to the Webhook URL configured by your business system. You need to implement this endpoint in your application to receive room and participant status changes.

Webhook Request Structure

The request format received by the business system is as follows:

  • Query Parameters:
    • event_type (string): Event type
    • event_id (string): Unique event ID (for deduplication)
  • Body: JSON event data

Event Types (event_type)

CategoryEvent TypeDescription
Roomroom.startedRoom started (first participant joined)
room.finishedRoom finished (all left or timeout)
Participantparticipant.invitedImportant: Participant invited. The business system should push an incoming call notification to the invitee upon receiving this event.
participant.joinedParticipant successfully joined
participant.leftParticipant left normally
participant.rejectedParticipant rejected the call
participant.missedParticipant missed the call (timeout)
participant.cancelledCaller actively cancelled the invitation

Request Body Data Examples

Applicable to room.started and room.finished.

{
"room_id": "room_abc123",
"creator": "user_001",
"rtc_type": 1,
"invite_on": 0,
"status": 1,
"max_participants": 2,
"duration": 300, // Contains actual call duration (seconds) only in finished events
"uids": ["user_001", "user_002"],
"created_at": 1704096500,
"updated_at": 1704096600
}

3. Internal Management API (Webhook)

These APIs are mainly used for internal system operation and maintenance:

  • POST /api/v1/webhooks/livekit - Receive low-level LiveKit event callbacks
  • GET /api/v1/webhooks/logs/stats - Get Webhook processing stats
  • POST /api/v1/webhooks/logs/cleanup - Clean up historical logs
Request Parameters

Request Body (JSON):

ParameterTypeRequiredDescription
retention_daysintegerYesNumber of days to retain
{
"retention_days": 7
}

Error Codes

When an API request fails, it uniformly follows this JSON error response format:

{
"code": 400,
"message": "Parameter error"
}