Skip to main content

Post event

This endpoint enables you to publish an event to a specific channel in a room. This event will be broadcast to all the clients that are subscribed to the channel in the room.

How to use

You can use the following cURL to obtain a response from this endpoint:


curl --request POST \
--url https://nodeapi.superviz.com/realtime/{room}/{channel}/publish \
--header 'apiKey: {{apiKey}}' \
--data '{
"name": "EVENT_NAME",
"data": {
"hello": "world!"
}
}'

HTTP Request

POST /realtime/{room}/{channel}/publish

In the request, you will need to send in the path following field:

NameDescription
roomRequired. The ID of the room.
channelRequired. The name of the channel you want to publish the event to.

Headers

When using this endpoint, you need to provide the API Key. The following headers are required:

NameDescription
apikeyRequired. You must utilize the SuperViz Token that can be found on the developer page. By utilizing this key, we will define whether to get data from the developer or the production environment.

Request Body

The request body should contain the following fields:

NameTypeDescription
namestringRequired. The name of the event you want to publish.
dataobjectRequired. The data payload of the event you want to publish.

Example:

{
"name": "EVENT_NAME",
"data": {
...
}
}

Response

Status code 200 will indicate that the request was successful and the message was published.