Skip to main content

Post event

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

How to use

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

curl --request POST \
--url https://api.superviz.com/realtime/CHANNEL_NAME/publish \
--header "client_id: ${YOUR CLIENT_ID}" \
--header "secret: ${YOUR SECRET}" \
--header 'Content-Type: application/json' \
--data '{
"name": "event.name",
"data": {
"hello": "world!"
}
}'

HTTP Request

POST /realtime/{channel}/publish

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

NameDescription
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
client_idRequired. You need to use the Client ID to authenticate in this repository. You can retrieve your Client ID under the Dashboard > Developer > Keys.
secretRequired. You need to use the Secret Key to authenticate in this repository. You can create a new API Secret under our Dashboard > Developer > Keys.

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.