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:

  • active (Boolean, required) — Whether to mute streams in the session (true) and enable the mute state of the session, or to disable the mute state of the session (false). With the mute state enabled (true), all current and future streams published to the session (with the exception of streams in the excludedStreamIds array) are muted. When you call this method with the active property set to false, future streams published to the session are not muted (but any existing muted streams remain muted).

  • excludedStreamIds (Array of strings, optional) — The stream IDs for streams that should not be muted. This is an optional property. If you omit this property, all streams in the session will be muted. This property only applies when the active property is set to true. When the active property is set to false, it is ignored.

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