Skip to main content

Broadcast to Room

Endpoint: /room/broadcastToRoom

This powerful API allows your backend server to inject messages or notifications directly into an active Plug-N-Meet session in real-time. You can use it to send system-wide announcements, deliver private messages to specific users, or trigger custom notifications from your application's logic.

This endpoint is ideal for building integrations that require server-to-client communication, such as:

  • Sending alerts based on external events.
  • Delivering automated messages or instructions to participants.
  • Creating custom, private notification systems within your application.

Request Parameters

The request must contain either a chat_msg or a notification_msg object.

FieldTypeRequiredDescription
room_idstringYesThe unique identifier of the active room to which you want to broadcast.
only_to_adminsbooleanNoIf true, the message will be sent to all participants with admin/moderator privileges.
to_user_idstringNoIf provided, the message will be sent to the specified user.
chat_msgobjectNoA chat message object to be sent.
notification_msgobjectNoA notification message object to be displayed.

Targeting Logic

The delivery of the message is determined by the only_to_admins and to_user_id fields:

  • If neither field is set, the message is sent to everyone in the room.
  • If only_to_admins is true, the message is sent to all admins.
  • If to_user_id is provided, the message is sent to that specific user.
  • If both only_to_admins and to_user_id are provided, the message is sent to all admins AND the specified user.

ChatMessage

This object represents a message that will appear in the room's chat panel.

FieldTypeRequiredDescription
messagestringYesThe content of the chat message.

NotificationMsg

This object represents a system-level notification that will pop up on the user's screen.

FieldTypeRequiredDescription
textstringYesThe text content of the notification.
typeNatsSystemNotificationTypesNoThe style of the notification. 0 = info; 1 = warning; 3 = error
with_soundbooleanNoIf true, the notification will play a sound for the recipient.

Example

Example 1: Sending a Public Chat Message to Everyone

{
"room_id": "room01",
"chat_msg": {
"message": "Hello everyone, the webinar will begin in 5 minutes."
}
}

Example 2: Sending a Private Notification to a Specific User

{
"room_id": "room01",
"to_user_id": "user-456",
"notification_msg": {
"text": "Your private document is ready for review.",
"type": 0
}
}

Example 3: Sending a Notification to All Admins and One Specific User

{
"room_id": "room01",
"only_to_admins": true,
"to_user_id": "vip-user-789",
"notification_msg": {
"text": "A VIP has just joined the waiting room.",
"type": 1,
"with_sound": true
}
}

Response

FieldTypeDescription
statusbooleanIndicates if the request was successful.
msgstringResponse message.
status_codestringResponse status code.