# Universal events

<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

Universal events are required for all RTMS implementations. They handle the connection handshake protocol, keep-alive operations, session and stream state management, and media data delivery.

> Use these events with the product-specific events for your implementation. For Meetings, Webinars, or Video SDK, see [Session events](/docs/rtms/event-reference/session-events/). For Contact Center, see [Contact Center events](/docs/rtms/event-reference/contact-center-events/).

## Message transmission channels

RTMS events are transmitted through two connection types established during the handshake process.

| Signaling connection                                                                                                                                                                                                                                                                                                                                                                               | Media connection                                                                                                |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
| `SIGNALING_HAND_SHAKE_REQ``SIGNALING_HAND_SHAKE_RESP``DATA_HAND_SHAKE_REQ``DATA_HAND_SHAKE_RESP``EVENT_SUBSCRIPTION``EVENT_UPDATE``CLIENT_READY_ACK``STREAM_STATE_UPDATE``SESSION_STATE_UPDATE``SESSION_STATE_REQ``SESSION_STATE_RESP``KEEP_ALIVE_REQ``KEEP_ALIVE_RESP``STREAM_STATE_REQ``STREAM_STATE_RESP``STREAM_CLOSE_REQ``STREAM_CLOSE_RESP``VIDEO_SUBSCRIPTION_REQ``VIDEO_SUBSCRIPTION_RESP` | `KEEP_ALIVE_RESP``MEDIA_DATA_AUDIO``MEDIA_DATA_VIDEO``MEDIA_DATA_SHARE``MEDIA_DATA_TRANSCRIPT``MEDIA_DATA_CHAT` |

> The examples on this page use meeting-specific values (such as `meeting_uuid` and `meeting.rtms_started`), but the message structure is the same across all RTMS-supported products.

## Signaling handshake request

<span className="pill_signaling">Sent to the signaling connection</span>

Send a signed handshake request to the `server_urls` provided in the `meeting.rtms_started` event, also known as the signaling connection. Use your app credentials with the session details to generate the signature. For more information, see [App establishes signaling connection](/docs/rtms/event-reference/).

> Use `meeting.rtms_started` and `meeting.rtms_stopped` events in the [Webhook reference](/docs/api/rtms/events) to get initial session details like the `meeting_uuid` and `rtms_stream_id`.

```json
{
    "msg_type": 1,
    "protocol_version": 1,
    "sequence": 1,
    "meeting_uuid": "xxxxxxxxxx",
    "rtms_stream_id": "xxxxxxxxxx",
    "signature": "xxxxxxxxxx",
    "buffer_data": false
}
```

| Field                                                                                                                                                                                                                                     | Type                                    | Description                                                                                                                                                                                                   |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `msg_type`                                                                                                                                                                                                                                | <span class="prop-int">int</span>       | The request from the app to the RTMS server to initiate a handshake. For more information, see [RTMS_MESSAGE_TYPE](/docs/rtms/data-types/#rtms_message_type).                                                 |
| `protocol_version`                                                                                                                                                                                                                        | <span class="prop-int">int</span>       | The RTMS design version. By default, it's `1.0`.                                                                                                                                                              |
| `sequence`                                                                                                                                                                                                                                | <span class="prop-int">int</span>       | The sequence number of the message. Must start at `1`.                                                                                                                                                        |
| `meeting_uuid`                                                                                                                                                                                                                            | <span class="prop-string">string</span> | The unique identifier for the session.                                                                                                                                                                        |
| `rtms_stream_id`                                                                                                                                                                                                                          | <span class="prop-string">string</span> | The unique identifier of the RTMS stream. Multiple streams are possible for a session if streaming access stops or restarts.                                                                                  |
| `signature`                                                                                                                                                                                                                               | <span class="prop-string">string</span> | The authentication signature created using app credentials and session details.                                                                                                                               |
| `buffer_data`                                                                                                                                                                                                                             | <span class="prop-bool">bool</span>     | Optional. Default is `true`. When set to `false`, any audio data captured between the time the `rtms_started` webhook event is received and the time the signaling connection is established will be dropped. |
| > When `buffer_data` is set to `false`, only the initial buffer data is dropped. Audio data will continue to be buffered during connection interruptions, and any buffered data will be transmitted once a new connection is established. |

## Signaling handshake response

<span className="pill_signaling">Sent from the signaling connection</span>

The signaling connection will respond with a signaling handshake response that includes the URLs of the media connections.

```json
{
    "msg_type": 2,
    "protocol_version": 1,
    "sequence": 0,
    "status_code": 0,
    "reason": "",
    "media_server": {
        "server_urls": {
            "audio": "wss://127.0.0.0:443",
            "video": "wss://127.0.0.0:443",
            "transcript": "wss://127.0.0.0:443",
            "all": "wss://127.0.0.0:443"
        }
    }
}
```

| Field              | Type                                    | Description                                                                                                                                                                   |
| ------------------ | --------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `msg_type`         | <span class="prop-int">int</span>       | The response from the signaling connection to the app after a handshake attempt. For more information, see [RTMS_MESSAGE_TYPE](/docs/rtms/data-types/#rtms_message_type).     |
| `protocol_version` | <span class="prop-int">int</span>       | The RTMS design version. By default, it's `1.0`.                                                                                                                              |
| `sequence`         | <span class="prop-int">int</span>       | The sequence number of the message.                                                                                                                                           |
| `status_code`      | <span class="prop-int">int</span>       | The status code of the message. Status `0` means success. For more information, see [RTMS_STATUS_CODE](/docs/rtms/data-types/#rtms_status_code).                              |
| `reason`           | <span class="prop-string">string</span> | This is empty if successful. If failed, it will contain the reason for the failure.                                                                                           |
| `media_server`     | <span class="prop-object">object</span> | The media connection information.                                                                                                                                             |
| `server_urls`      | <span class="prop-array">object</span>  | Locations of available media connections. The response will depend on the app's available scopes. For example, if the app only supports audio, only `audio` will be included. |

## Media handshake request

<span className="pill_media">Sent to the media connection</span>

To establish a connection, send a handshake request to the media connections of the RTMS server(s) that were included in the signaling handshake and include the associated media parameters. The media connection responds with confirmed parameters of the requested media types.

Apps can request all available media streams or specify media streams by content type. If all are requested, the signaling connection responds with all media connections available according to the app's requested scopes.

If the app has scopes for audio and transcript only, a request for all media will include audio and transcript data but not video, chat, or screen share data.

To request only one media type, specify that media type in the `media_type` field. For more information, see [MEDIA_DATA_TYPE](/docs/rtms/data-types/#media_data_type). Use `"media_type": 32` for all.

Media parameters (`media_params`) are optional. If not specified, the default values will be used.

> For more information, see [Data type definitions](/docs/rtms/data-types) for options on codecs, resolutions, rates, etc.

```json
{
    "msg_type": 3,
    "protocol_version": 1,
    "sequence": 0,
    "meeting_uuid": "4xxxxxxxxxx",
    "rtms_stream_id": "xxxxxxxxxx",
    "signature": "xxxxxxxxxx",
    "media_type": 32,
    "media_params": {
        "audio": {
            "content_type": 2,
            "sample_rate": 1,
            "channel": 1,
            "codec": 1,
            "data_opt": 1,
            "send_rate": 100
        },
        "video": {
            "codec": 5,
            "resolution": 2,
            "fps": 5
        },
        "deskshare": {
            "codec": 5,
            "resolution": 3,
            "fps": 1
        },
        "transcript": {
            "content_type": 5,
            "src_language": 9,
            "enable_lid": true
        }
    }
}
```

```json
{
    "msg_type": 3,
    "protocol_version": 1,
    "sequence": 0,
    "meeting_uuid": "4nYtdqLVTVqGJ+QB62ED7Q==",
    "rtms_stream_id": "03db704592624398931a588dd78200cb",
    "signature": "kDBZVzEWgox9tWVBc7DHsjW2OnVD/6H1zN2vdmU9VY8=",
    "media_type": 1,
    "media_params": {
        "audio": {
            "content_type": 2,
            "sample_rate": 1,
            "channel": 1,
            "codec": 1,
            "data_opt": 1,
            "send_rate": 20
        }
    }
}
```

```json
{
    "msg_type": 3,
    "protocol_version": 1,
    "sequence": 0,
    "meeting_uuid": "4nYtdqLVTVqGJ+QB62ED7Q==",
    "rtms_stream_id": "03db704592624398931a588dd78200cb",
    "signature": "kDBZVzEWgox9tWVBc7DHsjW2OnVD/6H1zN2vdmU9VY8=",
    "media_type": 2,
    "media_params": {
        "video": {
            "codec": 5,
            "resolution": 2,
            "fps": 5
        }
    }
}
```

```json
{
    "msg_type": 3,
    "protocol_version": 1,
    "sequence": 0,
    "meeting_uuid": "4nYtdqLVTVqGJ+QB62ED7Q==",
    "rtms_stream_id": "03db704592624398931a588dd78200cb",
    "signature": "kDBZVzEWgox9tWVBc7DHsjW2OnVD/6H1zN2vdmU9VY8=",
    "media_type": 4,
    "media_params": {
        "deskshare": {
            "codec": 5,
            "resolution": 3,
            "fps": 1
        }
    }
}
```

```json
{
    "msg_type": 3,
    "protocol_version": 1,
    "sequence": 0,
    "meeting_uuid": "4nYtdqLVTVqGJ+QB62ED7Q==",
    "rtms_stream_id": "03db704592624398931a588dd78200cb",
    "signature": "kDBZVzEWgox9tWVBc7DHsjW2OnVD/6H1zN2vdmU9VY8=",
    "media_type": 8,
    "media_params": {
        "transcript": {
            "content_type": 5,
            "src_language": 9,
            "enable_lid": true
        }
    }
}
```

```json
{
    "msg_type": 3,
    "protocol_version": 1,
    "sequence": 0,
    "meeting_uuid": "4nYtdqLVTVqGJ+QB62ED7Q==",
    "rtms_stream_id": "03db704592624398931a588dd78200cb",
    "signature": "kDBZVzEWgox9tWVBc7DHsjW2OnVD/6H1zN2vdmU9VY8=",
    "media_type": 16
}
```

| Field                                                                                              | Type                                    | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| -------------------------------------------------------------------------------------------------- | --------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `msg_type`                                                                                         | <span class="prop-int">int</span>       | The app sends this message to the media connection to request a connection with the specified media parameters. For more information, see [RTMS_MESSAGE_TYPE](/docs/rtms/data-types/#rtms_message_type).                                                                                                                                                                                                                                                    |
| `protocol_version`                                                                                 | <span class="prop-int">int</span>       | The RTMS design version. By default, it's `1.0`.                                                                                                                                                                                                                                                                                                                                                                                                            |
| `sequence`                                                                                         | <span class="prop-int">int</span>       | The sequence number of the message.                                                                                                                                                                                                                                                                                                                                                                                                                         |
| `meeting_uuid`                                                                                     | <span class="prop-string">string</span> | The unique identifier for the session.                                                                                                                                                                                                                                                                                                                                                                                                                      |
| `rtms_stream_id`                                                                                   | <span class="prop-string">string</span> | The unique identifier of the RTMS stream. Multiple streams are possible for a session if streaming access stops or restarts.                                                                                                                                                                                                                                                                                                                                |
| `signature`                                                                                        | <span class="prop-string">string</span> | The authentication signature created using app credentials and session details.                                                                                                                                                                                                                                                                                                                                                                             |
| `media_type`                                                                                       | <span class="prop-int">int</span>       | The media type of the stream, either audio (1), video (2), screen share (4), transcript (8), chat (16), or all (32). For more information, see [MEDIA_DATA_TYPE](/docs/rtms/data-types/#media_data_type).                                                                                                                                                                                                                                                   |
| `media_params` (Optional)                                                                          | <span class="prop-int">object</span>    | The media parameters of the stream that define the media formats. Parameters are set to default if not specified and returned in the response.                                                                                                                                                                                                                                                                                                              |
| `content_type`                                                                                     | <span class="prop-int">int</span>       | The content type of the media stream, either RTP (1), raw audio (2), raw video (3), file stream (4), or text (5). For more information, see [MEDIA_CONTENT_TYPE](/docs/rtms/data-types/#media_content_type).                                                                                                                                                                                                                                                |
| `sample_rate` (audio)                                                                              | <span class="prop-int">int</span>       | The sample rate of the audio stream. For more information, see [AUDIO_SAMPLE_RATE](/docs/rtms/data-types/#audio_sample_rate).                                                                                                                                                                                                                                                                                                                               |
| `channel` (audio)                                                                                  | <span class="prop-int">int</span>       | The channel of the audio stream, either mono (1) or stereo (2). For more information, see [AUDIO_CHANNEL](/docs/rtms/data-types/#audio_channel).                                                                                                                                                                                                                                                                                                            |
| `codec` (audio)                                                                                    | <span class="prop-int">int</span>       | The codec of the audio data. Can be L16 (1), G711 (2), G722 (3), or Opus (4). For more information, see [MEDIA_PAYLOAD_TYPE](/docs/rtms/data-types/#media_payload_type).                                                                                                                                                                                                                                                                                    |
| `data_opt` (audio)                                                                                 | <span class="prop-int">int</span>       | Defines whether media is separated or merged. For example, mixed audio or separated audio streams. For more information, see [MEDIA_DATA_OPTION](/docs/rtms/data-types/#media_data_option).                                                                                                                                                                                                                                                                 |
| `send_rate` (audio)                                                                                | <span class="prop-int">int</span>       | The send rate of the audio stream in milliseconds (ms). Must be a multiple of 20, up to 1000 ms.                                                                                                                                                                                                                                                                                                                                                            |
| `codec` (video)                                                                                    | <span class="prop-int">int</span>       | The codec of the video data that is set during the handshake and doesn't change during the session. Can be JPG or PNG when `fps` {'<='} 5 and H.264 when `fps` > 5. The default is JPG with an `fps` of 5.If the handshake request sets the `fps` > 5 but doesn't specify a `codec`, the server will set the `codec` to JPG (default) and the `fps` to 5. For more information, see [MEDIA_PAYLOAD_TYPE](/docs/rtms/data-types/#media_payload_type).        |
| `codec` (screen share)                                                                             | <span class="prop-int">int</span>       | The codec of the screen share data that is set during the handshake and doesn't change during the session. Can be JPG or PNG when `fps` {'<='} 1 and H.264 when `fps` > 1. The default is JPG with an `fps` of 1.If the handshake request sets the `fps` > 1 but doesn't specify a `codec`, the server will set the `codec` to JPG (default) and the `fps` to 1. For more information, see [MEDIA_PAYLOAD_TYPE](/docs/rtms/data-types/#media_payload_type). |
| `resolution` (video)                                                                               | <span class="prop-int">int</span>       | The resolution of the video stream. Can be SD (1), HD (2), FHD (3), or QHD (4). The default is HD. For more information, see [MEDIA_RESOLUTION](/docs/rtms/data-types/#media_resolution).                                                                                                                                                                                                                                                                   |
| `resolution` (screen share)                                                                        | <span class="prop-int">int</span>       | The resolution of the screen share stream. Can be SD (1), HD (2), FHD (3), or QHD (4). The default is FHD. For more information, see [MEDIA_RESOLUTION](/docs/rtms/data-types/#media_resolution).                                                                                                                                                                                                                                                           |
| `fps` (video & screen share)                                                                       | <span class="prop-int">int</span>       | The frames per second of the video stream. Maximum of 30.                                                                                                                                                                                                                                                                                                                                                                                                   |
| `src_language`                                                                                     | <span class="prop-int">int</span>       | Optional. The language of the transcript. If not specified, English will be the default language for the first 30 seconds of transcription. If specified, RTMS will transcribe the first 30 seconds of audio based on this language setting. For more information, see [RTMS_TRANSCRIPT_LANGUAGE](/docs/rtms/data-types/#rtms_transcript_language).                                                                                                         |
| > After 30 seconds, the audio language will be automatically detected and override this parameter. |
| `enable_lid`                                                                                       | <span class="prop-bool">bool</span>     | Optional. Default is true and Language Identification is enabled. When set to false, Language Identification is disabled and transcription will rely solely on the `src_language` parameter.                                                                                                                                                                                                                                                                |

## Media handshake response

<span className="pill_media">Sent from the media connection</span>

The media connection will respond with with a media handshake response that includes information about the media connections.

```json
{
    "msg_type": 4,
    "protocol_version": 1,
    "status_code": 0,
    "reason": "",
    "sequence": 0,
    "payload_encrypted": true,
    "media_params": {
        "audio": {
            "content_type": 2,
            "sample_rate": 1,
            "channel": 1,
            "codec": 1,
            "data_opt": 1,
            "send_rate": 100
        },
        "video": {
            "content_type": 3,
            "codec": 5,
            "resolution": 2,
            "data_opt": 3,
            "fps": 5
        },
        "deskshare": {
            "content_type": 3,
            "codec": 5,
            "resolution": 3,
            "fps": 1
        },
        "transcript": {
            "content_type": 5,
            "src_language": 9,
            "enable_lid": true
        },
        "chat": {
            "content_type": 5
        }
    }
}
```

```json
{
    "msg_type": 4,
    "protocol_version": 1,
    "status_code": 0,
    "reason": "",
    "sequence": 0,
    "payload_encrypted": true,
    "media_params": {
        "audio": {
            "content_type": 2,
            "sample_rate": 1,
            "channel": 1,
            "codec": 1,
            "data_opt": 1,
            "send_rate": 100
        }
    }
}
```

```json
{
    "msg_type": 4,
    "protocol_version": 1,
    "status_code": 0,
    "reason": "",
    "sequence": 0,
    "payload_encrypted": true,
    "media_params": {
        "video": {
            "content_type": 3,
            "codec": 5,
            "resolution": 2,
            "data_opt": 3,
            "fps": 5
        }
    }
}
```

```json
{
    "msg_type": 4,
    "protocol_version": 1,
    "status_code": 0,
    "reason": "",
    "sequence": 0,
    "payload_encrypted": true,
    "media_params": {
        "deskshare": {
            "content_type": 3,
            "codec": 5,
            "resolution": 3,
            "fps": 1
        }
    }
}
```

```json
{
    "msg_type": 4,
    "protocol_version": 1,
    "status_code": 0,
    "reason": "",
    "sequence": 0,
    "payload_encrypted": true,
    "media_params": {
        "transcript": {
            "content_type": 5,
            "src_language": 9,
            "enable_lid": true
        }
    }
}
```

```json
{
    "msg_type": 4,
    "protocol_version": 1,
    "status_code": 0,
    "reason": "",
    "sequence": 0,
    "payload_encrypted": true,
    "media_params": {
        "chat": {
            "content_type": 5
        }
    }
}
```

| Field                                                                                              | Type                                    | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| -------------------------------------------------------------------------------------------------- | --------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `msg_type`                                                                                         | <span class="prop-int">int</span>       | The response from the media connection to the app after a handshake attempt. For more information, see [RTMS_MESSAGE_TYPE](/docs/rtms/data-types/#rtms_message_type).                                                                                                                                                                                                                                                                                       |
| `protocol_version`                                                                                 | <span class="prop-int">int</span>       | The RTMS design version. By default, it's `1.0`.                                                                                                                                                                                                                                                                                                                                                                                                            |
| `status_code`                                                                                      | <span class="prop-int">int</span>       | The status code of the message. Status `0` means success. For more information, see [RTMS_STATUS_CODE](/docs/rtms/data-types/#rtms_status_code).                                                                                                                                                                                                                                                                                                            |
| `reason`                                                                                           | <span class="prop-string">string</span> | This is empty if successful. If failed, it will contain the reason for the failure.                                                                                                                                                                                                                                                                                                                                                                         |
| `sequence`                                                                                         | <span class="prop-int">int</span>       | The sequence number of the message.                                                                                                                                                                                                                                                                                                                                                                                                                         |
| `payload_encryption` (Optional)                                                                    | <span class="prop-bool">bool</span>     | Default is false for any TLS connection. The encryption keys in the signaling handshake response message. If true, the payload is encrypted. If false, but the payload protocol is UPD, and the payload will still be encrypted.                                                                                                                                                                                                                            |
| `content_type`                                                                                     | <span class="prop-int">int</span>       | The content type of the media. For more information, see [MEDIA_CONTENT_TYPE](/docs/rtms/data-types/#media_content_type).                                                                                                                                                                                                                                                                                                                                   |
| `sample_rate`                                                                                      | <span class="prop-int">int</span>       | The sample rate of the audio stream. For more information, see [AUDIO_SAMPLE_RATE](/docs/rtms/data-types/#audio_sample_rate).                                                                                                                                                                                                                                                                                                                               |
| `channel`                                                                                          | <span class="prop-int">int</span>       | The channel of the audio stream, either mono (1) or stereo (2). For more information, see [AUDIO_CHANNEL](/docs/rtms/data-types/#audio_channel).                                                                                                                                                                                                                                                                                                            |
| `codec`                                                                                            | <span class="prop-int">int</span>       | The codec of the audio data. Can be L16 (1), G711 (2), G722 (3), or Opus (4). For more information, see [MEDIA_PAYLOAD_TYPE](/docs/rtms/data-types/#media_payload_type).                                                                                                                                                                                                                                                                                    |
| `data_opt`                                                                                         | <span class="prop-int">int</span>       | Defines whether media is separated or merged. For example, mixed audio or separated audio streams. For more information, see [MEDIA_DATA_OPTION](/docs/rtms/data-types/#media_data_option).                                                                                                                                                                                                                                                                 |
| `send_rate`                                                                                        | <span class="prop-int">int</span>       | The send rate of the audio stream in milliseconds (ms). Must be a multiple of 20. Can be up to 1000 ms.                                                                                                                                                                                                                                                                                                                                                     |
| `codec` (video)                                                                                    | <span class="prop-int">int</span>       | The codec of the video data that is set during the handshake and doesn't change during the session. Can be JPG or PNG when `fps` {'<='} 5 and H.264 when `fps` > 5. The default is JPG with an `fps` of 5.If the handshake request sets the `fps` > 5 but doesn't specify a `codec`, the server will set the `codec` to JPG (default) and the `fps` to 5. For more information, see [MEDIA_PAYLOAD_TYPE](/docs/rtms/data-types/#media_payload_type).        |
| `codec` (screen share)                                                                             | <span class="prop-int">int</span>       | The codec of the screen share data that is set during the handshake and doesn't change during the session. Can be JPG or PNG when `fps` {'<='} 1 and H.264 when `fps` > 1. The default is JPG with an `fps` of 1.If the handshake request sets the `fps` > 1 but doesn't specify a `codec`, the server will set the `codec` to JPG (default) and the `fps` to 1. For more information, see [MEDIA_PAYLOAD_TYPE](/docs/rtms/data-types/#media_payload_type). |
| `resolution` (video)                                                                               | <span class="prop-int">int</span>       | The resolution of the video stream. Can be SD (1), HD (2), FHD (3), or QHD (4). The default is HD. For more information, see [MEDIA_RESOLUTION](/docs/rtms/data-types/#media_resolution).                                                                                                                                                                                                                                                                   |
| `resolution` (screen share)                                                                        | <span class="prop-int">int</span>       | The resolution of the screen share stream. Can be SD (1), HD (2), FHD (3), or QHD (4). The default is FHD. For more information, see [MEDIA_RESOLUTION](/docs/rtms/data-types/#media_resolution).                                                                                                                                                                                                                                                           |
| `fps` (video & screen share)                                                                       | <span class="prop-int">int</span>       | The frames per second of the video stream. Maximum of 30.                                                                                                                                                                                                                                                                                                                                                                                                   |
| `src_language`                                                                                     | <span class="prop-int">int</span>       | Optional. The language of the transcript. If not specified, English will be the default language for the first 30 seconds of transcription. If specified, RTMS will transcribe the first 30 seconds of audio based on this language setting. For more information, see [RTMS_TRANSCRIPT_LANGUAGE](/docs/rtms/data-types/#rtms_transcript_language).                                                                                                         |
| > After 30 seconds, the audio language will be automatically detected and override this parameter. |
| `enable_lid`                                                                                       | <span class="prop-bool">bool</span>     | Optional. Default is true and Language Identification is enabled. When set to false, Language Identification is disabled and transcription will rely solely on the `src_language` parameter.                                                                                                                                                                                                                                                                |

## Client ready ACK message

<span className="pill_signaling">Sent to the signaling connection</span>

After the app receives the data handshake response from the media connection, it needs to send a client ready ack to the signaling connection to indicate that the full handshake has completed and that it is ready to receive media data.

This message should be sent after the signaling and media connections have been established.

```json
{
    "msg_type": 7,
    "rtms_stream_id": "xxxxxxxxxx"
}
```

| Field            | Type                                    | Description                                                                                                                                                                                               |
| ---------------- | --------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `msg_type`       | <span class="prop-int">int</span>       | The app sends this message to the signaling connection to acknowledge that the server is ready to receive media. For more information, see [RTMS_MESSAGE_TYPE](/docs/rtms/data-types/#rtms_message_type). |
| `rtms_stream_id` | <span class="prop-string">string</span> | The unique identifier for the RTMS stream.                                                                                                                                                                |

## Keep-alive request

<span className="pill_media">Sent from the media connection</span>

To maintain stable connections and prevent timeouts, RTMS servers send a keep-alive request to both the signaling and media connections every 10 seconds.

When three keep-alive requests are unanswered, the RTMS server takes different actions for the different connection types.

-   **Signaling connection** - The RTMS server will interrupt both the signaling and media connections, wait for one minute to allow for reconnection, and, if the connection is not restored, it will end the RTMS stream.

-   **Media connections** - The RTMS server will interrupt the media connection, wait for 65 seconds to allow for reconnection, and, if the connection is not restored, it will end the RTMS stream.

If an app doesn't receive a keep-alive request for 65 seconds, we recommend that the app reestablish the connection by resending the [signaling handshake request](/docs/rtms/event-reference/#signaling-handshake-request). For more information, see
[Working with streams](/docs/rtms/event-reference/).

The RTMS server sends the following request to confirm the app wants to maintain a connection.

```json
{
    "msg_type": 12,
    "timestamp": 1727384349123
}
```

| Field       | Type                                          | Description                                                                                                                                                                         |
| ----------- | --------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `msg_type`  | <span class="prop-int">int</span>             | The media connection sends this message to confirm the app wants to maintain a connection. For more information, see [RTMS_MESSAGE_TYPE](/docs/rtms/data-types/#rtms_message_type). |
| `timestamp` | <span class="prop-ulong">unsigned long</span> | The Unix timestamp of the request.                                                                                                                                                  |

## Keep-alive response

<span className="pill_media">Sent to the media connection</span>

To maintain the connection, an app should respond to the request with the following response. The timestamp in the response must match the request.

```json
{
    "msg_type": 13,
    "timestamp": 1727384349123
}
```

| Field       | Type                                          | Description                                                                                                                                                           |
| ----------- | --------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `msg_type`  | <span class="prop-int">int</span>             | The app sends this message to the media connection to maintain a connection. For more information, see [RTMS_MESSAGE_TYPE](/docs/rtms/data-types/#rtms_message_type). |
| `timestamp` | <span class="prop-ulong">unsigned long</span> | The Unix timestamp of the keep-alive request.                                                                                                                         |

## Subscribe to events

<span className="pill_signaling">Sent to the signaling connection</span>

Send this message to the signaling connection to get data about behavior during sessions.

> **Note**
>
> Some events are sent automatically and don't need to be subscribed to. To ensure your app works as expected, don't subscribe to these events.
>
> -   FIRST_PACKET_TIMESTAMP = 1
> -   MEDIA_CONNECTION_INTERRUPTED = 7

This message does not require a response.

```json
{
    "msg_type": 5,
    "events": [
        {
            "event_type": 2,
            "subscribe": true
        }
    ]
}
```

| Field        | Type                                | Description                                                                                                                                                                                                                     |
| ------------ | ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `msg_type`   | <span class="prop-int">int</span>   | The app sends this message to the signaling connection to subscribe or unsubscribe to in-session events from the signaling connection. For more information, see [RTMS_MESSAGE_TYPE](/docs/rtms/data-types/#rtms_message_type). |
| `event_type` | <span class="prop-int">int</span>   | The type of event to subscribe to. For more information, see [RTMS_EVENT_TYPE](/docs/rtms/data-types/#rtms_event_type).                                                                                                         |
| `subscribe`  | <span class="prop-bool">bool</span> | A boolean. `True` - subscribe to events `False` - unsubscribe from events                                                                                                                                                       |

## Audio data

<span className="pill_media">Sent from the media connection</span>

Audio data from the media connection of a participant in a session. It can be either merged audio or individual audio.

```json
{
    "msg_type": 14,
    "content": {
        "user_id": 16778240,
        "user_name": "John Smith",
        "data": "Hw1kDacNAA4sDkMOAQ5eDekMgAzXCw0L4Al4CDwHBAayBEwDmwHD/wn+rfyQ+3z6Z/k4+Ef3jvb09aj1YPUF9QL1OfVt9eH1f/YE96P3jPib+dX6Pvyr/ef+IABcAZ4CmQN3BFAF6QVxBs0G9wbjBqYGXwYFBm8FxwT/Aw4DHAIkARYA7v6o/T382/qq+YD4fPd99mz1p/Qq9KTzcfNv807zcPPQ8z70yfQ89az1SPbO9m/3Lfjf+I75M/rz+pT7KPzs/In9Fv7G/lP/q/8GAG4AtgBHAcABDQKtAkwDIgRQBYQGrgfyCEgKigvDDP4NFw/8D78QhBErEqoS/BL5EsYSfRLnEXARwhCMD1kO8ww8C5gJ5gfrBe8D3AGp/7P9IPyY+hL5t/dl9mv10fQ89NjzvvO78/HzbfTb9F71I/bw9vL3Kvlh+pX71/wr/m//owDCAbQCkwNoBPYEYQWxBZ0FZQUdBYkEBgRkA64CAgIdAT0AZf+T/tD93vz9+xf7B/o8+WX4pvcE90L2n/VM9d70pPSe9IL0nfTa9BX1cfXK9QP2S/a69hH3cPfx91P4w/hO+cr5XPr2+l/71/t9/AP9f/0R/p/+Pv/5/7IAWAH+AeMCAwQ7BaAG+wcmCZEKKQy8DT4PWhBXEVYSVBOgFM0VMxZSFhYW4BXTFUMVNBSzEtIQJg99Da0LogkXB40ESgJCAHj+ivyA+qn4KfcH9hr1JvRf89byq/Lt8kjzhvPy85P0n/X/9kn4lvni+kj84P1S/4wAuwHUAvcD9wS/BUwGaAZcBmcGTQb5BUkFQgQzAzkCVQEgALX+U/3N+4L6XfkU+Nj2o/WB9MTzOfO38g==",
        "length": 1024,
        "timestamp": 1738392033699
    }
}
```

```json
{
    "msg_type": 14,
    "content": {
        "user_name": "John Smith",
        "data": "Hw1kDacNAA4sDkMOAQ5eDekMgAzXCw0L4Al4CDwHBAayBEwDmwHD/wn+rfyQ+3z6Z/k4+Ef3jvb09aj1YPUF9QL1OfVt9eH1f/YE96P3jPib+dX6Pvyr/ef+IABcAZ4CmQN3BFAF6QVxBs0G9wbjBqYGXwYFBm8FxwT/Aw4DHAIkARYA7v6o/T382/qq+YD4fPd99mz1p/Qq9KTzcfNv807zcPPQ8z70yfQ89az1SPbO9m/3Lfjf+I75M/rz+pT7KPzs/In9Fv7G/lP/q/8GAG4AtgBHAcABDQKtAkwDIgRQBYQGrgfyCEgKigvDDP4NFw/8D78QhBErEqoS/BL5EsYSfRLnEXARwhCMD1kO8ww8C5gJ5gfrBe8D3AGp/7P9IPyY+hL5t/dl9mv10fQ89NjzvvO78/HzbfTb9F71I/bw9vL3Kvlh+pX71/wr/m//owDCAbQCkwNoBPYEYQWxBZ0FZQUdBYkEBgRkA64CAgIdAT0AZf+T/tD93vz9+xf7B/o8+WX4pvcE90L2n/VM9d70pPSe9IL0nfTa9BX1cfXK9QP2S/a69hH3cPfx91P4w/hO+cr5XPr2+l/71/t9/AP9f/0R/p/+Pv/5/7IAWAH+AeMCAwQ7BaAG+wcmCZEKKQy8DT4PWhBXEVYSVBOgFM0VMxZSFhYW4BXTFUMVNBSzEtIQJg99Da0LogkXB40ESgJCAHj+ivyA+qn4KfcH9hr1JvRf89byq/Lt8kjzhvPy85P0n/X/9kn4lvni+kj84P1S/4wAuwHUAvcD9wS/BUwGaAZcBmcGTQb5BUkFQgQzAzkCVQEgALX+U/3N+4L6XfkU+Nj2o/WB9MTzOfO38g=="
    }
}
```

```json
{
    "msg_type": 14,
    "content": {
        "channel_id": "c8b2d3ce-b0d6-4cd1-9195-fe17a4bd5b8e",
        "data": "Hw1kDacNAA4sDkMOAQ5eDekMgAzXCw0L4Al4CDwHBAayBEwDmwHD/wn+rfyQ+3z6Z/k4+Ef3jvb09aj1YPUF9QL1OfVt9eH1f/YE96P3jPib+dX6Pvyr/ef+IABcAZ4CmQN3BFAF6QVxBs0G9wbjBqYGXwYFBm8FxwT/Aw4DHAIkARYA7v6o/T382/qq+YD4fPd99mz1p/Qq9KTzcfNv807zcPPQ8z70yfQ89az1SPbO9m/3Lfjf+I75M/rz+pT7KPzs/In9Fv7G/lP/q/8GAG4AtgBHAcABDQKtAkwDIgRQBYQGrgfyCEgKigvDDP4NFw/8D78QhBErEqoS/BL5EsYSfRLnEXARwhCMD1kO8ww8C5gJ5gfrBe8D3AGp/7P9IPyY+hL5t/dl9mv10fQ89NjzvvO78/HzbfTb9F71I/bw9vL3Kvlh+pX71/wr/m//owDCAbQCkwNoBPYEYQWxBZ0FZQUdBYkEBgRkA64CAgIdAT0AZf+T/tD93vz9+xf7B/o8+WX4pvcE90L2n/VM9d70pPSe9IL0nfTa9BX1cfXK9QP2S/a69hH3cPfx91P4w/hO+cr5XPr2+l/71/t9/AP9f/0R/p/+Pv/5/7IAWAH+AeMCAwQ7BaAG+wcmCZEKKQy8DT4PWhBXEVYSVBOgFM0VMxZSFhYW4BXTFUMVNBSzEtIQJg99Da0LogkXB40ESgJCAHj+ivyA+qn4KfcH9hr1JvRf89byq/Lt8kjzhvPy85P0n/X/9kn4lvni+kj84P1S/4wAuwHUAvcD9wS/BUwGaAZcBmcGTQb5BUkFQgQzAzkCVQEgALX+U/3N+4L6XfkU+Nj2o/WB9MTzOfO38g==",
        "length": 1024,
        "timestamp": 1738392033699
    }
}
```

| Field        | Type                                          | Description                                                                                                                                                                                                                                 |
| ------------ | --------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `msg_type`   | <span class="prop-int">int</span>             | Audio data sent from the media connection. For more information, see [RTMS_MESSAGE_TYPE](/docs/rtms/data-types/#rtms_message_type).                                                                                                         |
| `user_id`    | <span class="prop-int">int</span>             | The unique identifier of the participant whose audio is included in the data.                                                                                                                                                               |
| `user_name`  | <span class="prop-string">string</span>       | The username of the participant whose audio is included in the data. If the `user_id` in the RTP header is `0`, no `user_name` will be sent.                                                                                                |
| `channel_id` | <span class="prop-string">string</span>       | For Zoom Contact Center engagements, the unique identifier of the SIP trunk channel that carries this audio. Each party in an engagement is on a separate channel, so `channel_id` identifies which side of the call this audio belongs to. |
| `data`       | <span class="prop-string">string</span>       | Audio data, base64-encoded binary.                                                                                                                                                                                                          |
| `length`     | <span class="prop-int">int</span>             | The length of the original binary data before base64 encoding.                                                                                                                                                                              |
| `timestamp`  | <span class="prop-ulong">unsigned long</span> | The Unix timestamp of the data.                                                                                                                                                                                                             |

## Video data

<span className="pill_media">Sent from the media connection</span>

Video data from the media connection of the **Active speaker** participant in a session.

```json
{
    "msg_type": 15,
    "content": {
        "user_id": 16778240,
        "user_name": "John Smith",
        "data": "Hw1kDacNAA4sDkMOAQ5eDekMgAzXCw0L4Al4CDwHBAayBEwDmwHD/wn+rfyQ+3z6Z/k4+Ef3jvb09aj1YPUF9QL1OfVt9eH1f/YE96P3jPib+dX6Pvyr/ef+IABcAZ4CmQN3BFAF6QVxBs0G9wbjBqYGXwYFBm8FxwT/Aw4DHAIkARYA7v6o/T382/qq+YD4fPd99mz1p/Qq9KTzcfNv807zcPPQ8z70yfQ89az1SPbO9m/3Lfjf+I75M/rz+pT7KPzs/In9Fv7G/lP/q/8GAG4AtgBHAcABDQKtAkwDIgRQBYQGrgfyCEgKigvDDP4NFw/8D78QhBErEqoS/BL5EsYSfRLnEXARwhCMD1kO8ww8C5gJ5gfrBe8D3AGp/7P9IPyY+hL5t/dl9mv10fQ89NjzvvO78/HzbfTb9F71I/bw9vL3Kvlh+pX71/wr/m//owDCAbQCkwNoBPYEYQWxBZ0FZQUdBYkEBgRkA64CAgIdAT0AZf+T/tD93vz9+xf7B/o8+WX4pvcE90L2n/VM9d70pPSe9IL0nfTa9BX1cfXK9QP2S/a69hH3cPfx91P4w/hO+cr5XPr2+l/71/t9/AP9f/0R/p/+Pv/5/7IAWAH+AeMCAwQ7BaAG+wcmCZEKKQy8DT4PWhBXEVYSVBOgFM0VMxZSFhYW4BXTFUMVNBSzEtIQJg99Da0LogkXB40ESgJCAHj+ivyA+qn4KfcH9hr1JvRf89byq/Lt8kjzhvPy85P0n/X/9kn4lvni+kj84P1S/4wAuwHUAvcD9wS/BUwGaAZcBmcGTQb5BUkFQgQzAzkCVQEgALX+U/3N+4L6XfkU+Nj2o/WB9MTzOfO38g==",
        "length": 1024,
        "timestamp": 1738392033699
    }
}
```

| Field       | Type                                          | Description                                                                                                                         |
| ----------- | --------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| `msg_type`  | <span class="prop-int">int</span>             | Video data sent from the media connection. For more information, see [RTMS_MESSAGE_TYPE](/docs/rtms/data-types/#rtms_message_type). |
| `user_id`   | <span class="prop-int">int</span>             | The unique identifier of the participant whose video was included in the data.                                                      |
| `user_name` | <span class="prop-string">string</span>       | The username of the participant whose video was included in the data.                                                               |
| `data`      | <span class="prop-string">string</span>       | Video data, base64-encoded binary.                                                                                                  |
| `length`    | <span class="prop-int">int</span>             | The length of the original binary data before base64 encoding.                                                                      |
| `timestamp` | <span class="prop-ulong">unsigned long</span> | The Unix timestamp of the data.                                                                                                     |

## Screen share data

<span className="pill_media">Sent from the media connection</span>

Content shared by a participant in a session sent from the media connection.

```json
{
    "msg_type": 16,
    "content": {
        "user_id": 16778240,
        "user_name": "John Smith",
        "data": "Hw1kDacNAA4sDkMOAQ5eDekMgAzXCw0L4Al4CDwHBAayBEwDmwHD/wn+rfyQ+3z6Z/k4+Ef3jvb09aj1YPUF9QL1OfVt9eH1f/YE96P3jPib+dX6Pvyr/ef+IABcAZ4CmQN3BFAF6QVxBs0G9wbjBqYGXwYFBm8FxwT/Aw4DHAIkARYA7v6o/T382/qq+YD4fPd99mz1p/Qq9KTzcfNv807zcPPQ8z70yfQ89az1SPbO9m/3Lfjf+I75M/rz+pT7KPzs/In9Fv7G/lP/q/8GAG4AtgBHAcABDQKtAkwDIgRQBYQGrgfyCEgKigvDDP4NFw/8D78QhBErEqoS/BL5EsYSfRLnEXARwhCMD1kO8ww8C5gJ5gfrBe8D3AGp/7P9IPyY+hL5t/dl9mv10fQ89NjzvvO78/HzbfTb9F71I/bw9vL3Kvlh+pX71/wr/m//owDCAbQCkwNoBPYEYQWxBZ0FZQUdBYkEBgRkA64CAgIdAT0AZf+T/tD93vz9+xf7B/o8+WX4pvcE90L2n/VM9d70pPSe9IL0nfTa9BX1cfXK9QP2S/a69hH3cPfx91P4w/hO+cr5XPr2+l/71/t9/AP9f/0R/p/+Pv/5/7IAWAH+AeMCAwQ7BaAG+wcmCZEKKQy8DT4PWhBXEVYSVBOgFM0VMxZSFhYW4BXTFUMVNBSzEtIQJg99Da0LogkXB40ESgJCAHj+ivyA+qn4KfcH9hr1JvRf89byq/Lt8kjzhvPy85P0n/X/9kn4lvni+kj84P1S/4wAuwHUAvcD9wS/BUwGaAZcBmcGTQb5BUkFQgQzAzkCVQEgALX+U/3N+4L6XfkU+Nj2o/WB9MTzOfO38g==",
        "length": 1024,
        "timestamp": 1738392033699
    }
}
```

| Field       | Type                                          | Description                                                                                                                                |
| ----------- | --------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| `msg_type`  | <span class="prop-int">int</span>             | Screen share data sent from the media connection. For more information, see [RTMS_MESSAGE_TYPE](/docs/rtms/data-types/#rtms_message_type). |
| `user_id`   | <span class="prop-int">int</span>             | The unique identifier of the participant who shared their screen.                                                                          |
| `user_name` | <span class="prop-string">string</span>       | The username of the participant who shared their screen.                                                                                   |
| `data`      | <span class="prop-string">string</span>       | Screen share video data, base64-encoded binary.                                                                                            |
| `length`    | <span class="prop-int">int</span>             | The length of the original binary data before base64 encoding.                                                                             |
| `timestamp` | <span class="prop-ulong">unsigned long</span> | The Unix timestamp of the data.                                                                                                            |

## Transcript data

<span className="pill_media">Sent from the media connection</span>

Transcript of the spoken audio in a session sent from the media connection. Messages will be sent separately for each participant who has spoken.

```json
{
    "msg_type": 17,
    "content": {
        "user_id": 19778240,
        "user_name": "John Smith",
        "start_time": 1727384100000,
        "end_time": 1727384310000,
        "timestamp": 1727384349000,
        "language": 9,
        "data": "Hi, hello world!"
    }
}
```

```json
{
    "msg_type": 17,
    "content": {
        "channel_id": "c8b2d3ce-b0d6-4cd1-9195-fe17a4bd5b8e",
        "start_time": 1738392033699,
        "end_time": 1738392036866,
        "timestamp": 1727384349000000,
        "language": 9,
        "data": "Hi, hello world!"
    }
}
```

| Field        | Type                                          | Description                                                                                                                                                                                                                                           |
| ------------ | --------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `msg_type`   | <span class="prop-int">int</span>             | Transcript data sent from the media connection. For more information, see [RTMS_MESSAGE_TYPE](/docs/rtms/data-types/#rtms_message_type).                                                                                                              |
| `user_id`    | <span class="prop-int">int</span>             | The unique identifier of the participant whose transcript is included.                                                                                                                                                                                |
| `user_name`  | <span class="prop-string">string</span>       | The username of the participant whose transcript is included.                                                                                                                                                                                         |
| `channel_id` | <span class="prop-string">string</span>       | For Zoom Contact Center engagements, the unique identifier of the SIP trunk channel that carries this transcript. Each party in an engagement is on a separate channel, so `channel_id` identifies which side of the call this transcript belongs to. |
| `start_time` | <span class="prop-ulong">unsigned long</span> | The Unix timestamp of when the transcription started.                                                                                                                                                                                                 |
| `end_time`   | <span class="prop-ulong">unsigned long</span> | The Unix timestamp of when the transcription ended.                                                                                                                                                                                                   |
| `timestamp`  | <span class="prop-ulong">unsigned long</span> | The Unix timestamp of the data.                                                                                                                                                                                                                       |
| `language`   | <span class="prop-int">int</span>             | The language of the transcript data. For more information, see [RTMS_TRANSCRIPT_LANGUAGE](/docs/rtms/data-types/#rtms_transcript_language).                                                                                                           |
| `data`       | <span class="prop-string">string</span>       | The transcript data, UTF-8 encoded string.                                                                                                                                                                                                            |

## Chat data

<span className="pill_media">Sent from the media connection</span>

Chat data sent from the media connection. Each participant's chat data is sent in a separate message.

> **Note**
>
> RTMS currently delivers public, or everyone, meeting and webinar chat only (`chat_session.type: 1`). Other chat session types are reserved for future support and aren't delivered to clients today.

```json
{
    "msg_type": 18,
    "content": {
        "timestamp": 1771635627032,
        "data": "Content of the message",
        "chat_session": {
            "type": 1
        },
        "operation_type": 1,
        "message_id": "1-{BAE4D8D3-629A-48E2-9C12-5442D81931BF}",
        "sender": {
            "user_id": 16778240,
            "user_name": "John Smith"
        },
        "files": [
            {
                "file_id": "bJtDzXMnS1ufL1SHarZnMA",
                "file_name": "test.txt",
                "file_size": 28
            }
        ],
        "delete_file_id_list": ["-i81TZFYSK2KUltQP-Y_TA"]
    }
}
```

| Field                 | Type                                           | Description                                                                                                                                                                              |
| --------------------- | ---------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `msg_type`            | <span class="prop-int">int</span>              | Chat data sent from the media connection. For more information, see [RTMS_MESSAGE_TYPE](/docs/rtms/data-types/#rtms_message_type).                                                       |
| `timestamp`           | <span class="prop-ulong">unsigned long</span>  | The Unix timestamp of the data.                                                                                                                                                          |
| `data`                | <span class="prop-string">string</span>        | The message content. A UTF-8 encoded JSON object string.                                                                                                                                 |
| `chat_session`        | <span class="prop-object">object</span>        | The chat session that the message belongs to.                                                                                                                                            |
| `chat_session.type`   | <span class="prop-int">int</span>              | The type of chat session. RTMS currently only delivers `1` (`EVERYONE`, public chat). For more information, see [RTMS_CHAT_SESSION_TYPE](/docs/rtms/data-types/#rtms_chat_session_type). |
| `operation_type`      | <span class="prop-int">int</span>              | The operation that produced this message, such as send, edit, or delete. For more information, see [RTMS_CHAT_OPERATION_TYPE](/docs/rtms/data-types/#rtms_chat_operation_type).          |
| `message_id`          | <span class="prop-string">string</span>        | The unique identifier of the message.                                                                                                                                                    |
| `sender`              | <span class="prop-object">object</span>        | The participant who sent the message.                                                                                                                                                    |
| `sender.user_id`      | <span class="prop-ulong">unsigned int32</span> | The unique identifier of the participant who sent the message.                                                                                                                           |
| `sender.user_name`    | <span class="prop-string">string</span>        | The username of the participant who sent the message.                                                                                                                                    |
| `files`               | <span class="prop-array">array</span>          | The files attached to the message.                                                                                                                                                       |
| `files[].file_id`     | <span class="prop-string">string</span>        | The unique identifier of the attached file.                                                                                                                                              |
| `files[].file_name`   | <span class="prop-string">string</span>        | The name of the attached file.                                                                                                                                                           |
| `files[].file_size`   | <span class="prop-ulong">unsigned long</span>  | The size of the attached file, in bytes.                                                                                                                                                 |
| `delete_file_id_list` | <span class="prop-array">array</span>          | Optional. The identifiers of files removed while editing a chat message. Only present when files are removed during an edit.                                                             |

## Session state updated

<span className="pill_signaling">Sent from the signaling connection</span>

The signaling connection sends session state updated events when a new session is added or the state of a session is changed. A session can stop and resume during a stream. This message does not require a response from the app.

The `STARTED` state means a brand-new session has started. Record the session information locally since the state of each session is changed separately.

```json
{
    "msg_type": 9,
    "state": 1,
    "stop_reason": 1,
    "timestamp": 1727384349123,
    "rtms_session_id": "xxxxxxxxxx"
}
```

| Field             | Type                                          | Description                                                                                                                                                                                                              |
| ----------------- | --------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `msg_type`        | <span class="prop-int">int</span>             | The signaling connection sends this message when a session has been updated. For more information, see [RTMS_MESSAGE_TYPE](/docs/rtms/data-types/#rtms_message_type).                                                    |
| `state`           | <span class="prop-int">int</span>             | The state of a session within a stream, including if a participant or host has started, paused, resumed or stopped a session. For more information, see [RTMS_SESSION_STATE](/docs/rtms/data-types/#rtms_session_state). |
| `reason`          | <span class="prop-int">int</span>             | Describes why a session status has been updated. It's only sent if session state stops. For more information, see [RTMS_STOP_REASON](/docs/rtms/data-types/#rtms_stop_reason).                                           |
| `timestamp`       | <span class="prop-ulong">unsigned long</span> | The Unix timestamp of when the session was updated.                                                                                                                                                                      |
| `rtms_session_id` | <span class="prop-string">string</span>       | The unique identifier for the RTMS session.                                                                                                                                                                              |

## Session state request

<span className="pill_signaling">Sent to the signaling connection</span>

Apps send the session state request event to the signaling connection to query the current session state. The signaling connection will respond with the current session state.

```json
{
    "msg_type": 10,
    "rtms_session_id": "xxxxxxxxxx"
}
```

| Field             | Type                                    | Description                                                                                                                                                    |
| ----------------- | --------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `msg_type`        | <span class="prop-int">int</span>       | The app sends this message to query the current state of the session. For more information, see [RTMS_MESSAGE_TYPE](/docs/rtms/data-types/#rtms_message_type). |
| `rtms_session_id` | <span class="prop-string">string</span> | The unique identifier for the RTMS session.                                                                                                                    |

## Session state response

<span className="pill_signaling">Sent from the signaling connection</span>

The signaling connection sends the session state response event in response to a session state request event.

```json
{
    "msg_type": 11,
    "rtms_session_id": "xxxxxxxxxx",
    "state": 1,
    "timestamp": 1727384349123
}
```

| Field             | Type                                          | Description                                                                                                                                                                                         |
| ----------------- | --------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `msg_type`        | <span class="prop-int">int</span>             | The signaling connection sends this field as a response to the query for the state of the current session. For more information, see [RTMS_MESSAGE_TYPE](/docs/rtms/data-types/#rtms_message_type). |
| `rtms_session_id` | <span class="prop-string">string</span>       | The unique identifier for the RTMS session.                                                                                                                                                         |
| `state`           | <span class="prop-int">int</span>             | The state of the current session. For more information, see [RTMS_SESSION_STATE](/docs/rtms/data-types/#rtms_session_state).                                                                        |
| `timestamp`       | <span class="prop-ulong">unsigned long</span> | The Unix timestamp of the request. Use this to pair requests and responses.                                                                                                                         |

## Stream state request

<span className="pill_signaling">Sent to the signaling connection</span>

Apps send the current stream state request event to the signaling server to query the current stream state. Streams can be in one of the following states: inactive, active, interrupted, terminating, terminated, paused, or resumed.

```json
{
    "msg_type": 19,
    "rtms_stream_id": "756FF58A-6332-6ECA-E4AE-21F2ABDCB485"
}
```

| Field            | Type                                    | Description                                                                                                                                                  |
| ---------------- | --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `msg_type`       | <span class="prop-int">int</span>       | The app sends this message to query the current state of the state. For more information, see [RTMS_MESSAGE_TYPE](/docs/rtms/data-types/#rtms_message_type). |
| `rtms_stream_id` | <span class="prop-string">string</span> | The unique identifier of the RTMS stream.                                                                                                                    |

## Stream state response

<span className="pill_signaling">Sent from the signaling connection</span>

The signaling connection sends the stream state response event in response to a stream state request event.

```json
{
    "msg_type": 20,
    "state": 1,
    "rtms_stream_id": "756FF58A-6332-6ECA-E4AE-21F2ABDCB485",
    "timestamp": 1694204592
}
```

| Field            | Type                                          | Description                                                                                                                                                                                          |
| ---------------- | --------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `msg_type`       | <span class="prop-int">int</span>             | The signaling connection sends this message as a response to the query for the state of the current stream. For more information, see [RTMS_MESSAGE_TYPE](/docs/rtms/data-types/#rtms_message_type). |
| `state`          | <span class="prop-int">int</span>             | The current state of the RTMS stream. For more information, see [RTMS_STREAM_STATE](/docs/rtms/data-types/#rtms_stream_state).                                                                       |
| `rtms_stream_id` | <span class="prop-string">string</span>       | The unique identifier for the RTMS stream.                                                                                                                                                           |
| `timestamp`      | <span class="prop-ulong">unsigned long</span> | The Unix timestamp of the request. Use this to pair requests and responses.                                                                                                                          |

## Stream state updated

<span className="pill_signaling">Sent from the signaling connection</span>

```json
{
    "msg_type": 8,
    "state": 1,
    "reason": 1,
    "timestamp": 1727384349123
}
```

| Field       | Type                                          | Description                                                                                                                                                                                                 |
| ----------- | --------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `msg_type`  | <span class="prop-int">int</span>             | The signaling connection sends this message when a stream has been updated. For more information, see [RTMS_MESSAGE_TYPE](/docs/rtms/data-types/#rtms_message_type).                                        |
| `state`     | <span class="prop-int">int</span>             | The state of a stream, including if a stream is active, experiencing connection issues, or needs to be terminated. For more information, see [RTMS_STREAM_STATE](/docs/rtms/data-types/#rtms_stream_state). |
| `reason`    | <span class="prop-int">int</span>             | Describes why a stream status has been updated. For more information, see [RTMS_STOP_REASON](/docs/rtms/data-types/#rtms_stop_reason).                                                                      |
| `timestamp` | <span class="prop-ulong">unsigned long</span> | The Unix timestamp of when the stream was updated.                                                                                                                                                          |

## Stream close request

<span className="pill_signaling">Sent to the signaling connection</span>

To gracefully close a stream from the app backend, send a `STREAM_CLOSE_REQ` message through the signaling connection. RTMS will respond with a `STREAM_CLOSE_RESP` message and terminate the stream.

```json
{
    "msg_type": 21,
    "rtms_stream_id": "xxxxxxxxxx"
}
```

| Field            | Type                                    | Description                                                                                                                            |
| ---------------- | --------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| `msg_type`       | <span class="prop-int">int</span>       | The request from the app to close the stream. For more information, see [RTMS_MESSAGE_TYPE](/docs/rtms/data-types/#rtms_message_type). |
| `rtms_stream_id` | <span class="prop-string">string</span> | The unique identifier of the RTMS stream to close.                                                                                     |

## Stream close response

<span className="pill_signaling">Sent from the signaling connection</span>

The signaling connection responds to a stream close request with a `STREAM_CLOSE_RESP` message confirming the result.

```json
{
    "msg_type": 22,
    "rtms_stream_id": "xxxxxxxxxx",
    "status_code": 0,
    "reason": "OK",
    "timestamp": 1727384349123
}
```

| Field            | Type                                          | Description                                                                                                                                                       |
| ---------------- | --------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `msg_type`       | <span class="prop-int">int</span>             | The response from the signaling connection after a stream close request. For more information, see [RTMS_MESSAGE_TYPE](/docs/rtms/data-types/#rtms_message_type). |
| `rtms_stream_id` | <span class="prop-string">string</span>       | The unique identifier of the RTMS stream.                                                                                                                         |
| `status_code`    | <span class="prop-int">int</span>             | The status code of the response. Status `0` means success. For more information, see [RTMS_STATUS_CODE](/docs/rtms/data-types/#rtms_status_code).                 |
| `reason`         | <span class="prop-string">string</span>       | Empty if successful. If failed, contains the reason for the failure.                                                                                              |
| `timestamp`      | <span class="prop-ulong">unsigned long</span> | The Unix timestamp of when the response was sent.                                                                                                                 |

## Video subscription request

<span className="pill_signaling">Sent to the signaling connection</span>

To use individual video subscriptions, configure `data_opt` to `4` (`VIDEO_SINGLE_INDIVIDUAL_STREAM`) when establishing the media connection, and subscribe to `PARTICIPANT_VIDEO_ON` and `PARTICIPANT_VIDEO_OFF` events using the [Subscribe to events](#subscribe-to-events) message.

To subscribe to an individual participant's video stream, send this message through the signaling connection containing the `user_id` obtained from a `PARTICIPANT_VIDEO_ON` event. The RTMS server supports subscribing to a single individual video stream at a time, a new subscription request will automatically unsubscribe from the previous individual's stream.

```json
{
    "msg_type": 28,
    "user_id": 16778240,
    "subscribe": true,
    "timestamp": 1738392033699
}
```

| Field       | Type                                           | Description                                                                                                                                                                      |
| ----------- | ---------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `msg_type`  | <span class="prop-int">int</span>              | The request from the app to subscribe or unsubscribe from an individual's video stream. For more information, see [RTMS_MESSAGE_TYPE](/docs/rtms/data-types/#rtms_message_type). |
| `user_id`   | <span class="prop-ulong">unsigned int32</span> | The unique identifier of the participant to subscribe to, obtained from a `PARTICIPANT_VIDEO_ON` event.                                                                          |
| `subscribe` | <span class="prop-bool">bool</span>            | Set to `true` to subscribe, `false` to unsubscribe.                                                                                                                              |
| `timestamp` | <span class="prop-ulong">unsigned long</span>  | The Unix timestamp of the request.                                                                                                                                               |

## Video subscription response

<span className="pill_signaling">Sent from the signaling connection</span>

The signaling connection responds to a video subscription request. If successful, the subscribed participant's video stream will begin transmitting through the video data socket connection.

```json
{
    "msg_type": 29,
    "user_id": 16778240,
    "status_code": 0,
    "reason": "OK",
    "timestamp": 1738392033699
}
```

| Field         | Type                                           | Description                                                                                                                                                             |
| ------------- | ---------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `msg_type`    | <span class="prop-int">int</span>              | The response from the signaling connection after a video subscription request. For more information, see [RTMS_MESSAGE_TYPE](/docs/rtms/data-types/#rtms_message_type). |
| `user_id`     | <span class="prop-ulong">unsigned int32</span> | The unique identifier of the participant that was subscribed or unsubscribed.                                                                                           |
| `status_code` | <span class="prop-int">int</span>              | The status code of the response. Status `0` means success. For more information, see [RTMS_STATUS_CODE](/docs/rtms/data-types/#rtms_status_code).                       |
| `reason`      | <span class="prop-string">string</span>        | Empty if successful. If failed, contains the reason for the failure.                                                                                                    |
| `timestamp`   | <span class="prop-ulong">unsigned long</span>  | The Unix timestamp of the response.                                                                                                                                     |
