Suggestions

close search

Add Messaging, Voice, and Authentication to your apps with Vonage Communications APIs

Visit the Vonage API Developer Portal

Moderation — REST

Forcing a client endpoint to disconnect from a session

In addition to moderating connected client endpoints from the OpenTok.js SDK, app servers may issue an HTTP DELETE from the server side to force a connected client to disconnect from a session.

Your application server can disconnect a client from an OpenTok session by sending an HTTP DELETE request to the resource for that client's connection:

SESSION_ID=SOME_SESSION_ID
CONNECTION_ID=SOME_CONNECTION_ID
API_KEY=123456
API_SECRET=ABCDEF1234567890
curl -v \
-X DELETE \
-H "X-OPENTOK-AUTH:JSON_WEB_TOKEN" \
https://api.opentok.com/v2/project/${API_KEY}/session/${SESSION_ID}/connection/${CONNECTION_ID}

For more information, see the OpenTok REST API documentation.

Forcing streams in a session to mute published audio

You can use the OpenTok REST API to force a publisher of a specific stream to mute its published audio:

SESSION_ID=SOME_SESSION_ID
STREAM_ID=SOME_STREAM_ID
API_KEY=123456
API_SECRET=ABCDEF1234567890
JWT=jwt_token
curl -v \
-X POST \
-H "X-OPENTOK-AUTH:JSON_WEB_TOKEN" \
https://api.opentok.com/v2/project/${API_KEY}/session/${SESSION_ID}/stream/${STREAM_ID}/mute

You can use the OpenTok REST API to force all streams (except for an optional list of streams) in a session to mute published audio:

SESSION_ID=SOME_SESSION_ID
DATA='{"excludedStreamIds": ["excludedStreamId1", "excludedStreamId2"], "active": true}'
API_KEY=123456
API_SECRET=ABCDEF1234567890
curl -v \
-H "Content-Type: application/json" \
-X POST \
-H "X-OPENTOK-AUTH:JSON_WEB_TOKEN" \
https://api.opentok.com/v2/project/${API_KEY}/session/${SESSION_ID}/mute

The JSON data includes the following properties:

To disable the mute state of the session (to disable future streams from being muted), call the method again with the active property set to false:

SESSION_ID=SOME_SESSION_ID
DATA='{"active": false}'
API_KEY=123456
API_SECRET=ABCDEF1234567890
curl -v \
-H "Content-Type: application/json" \
-X POST \
-H "X-OPENTOK-AUTH:JSON_WEB_TOKEN" \
https://api.opentok.com/v2/project/${API_KEY}/session/${SESSION_ID}/mute