Channel event types
Updated
Understand channel event callbacks from Agora Notifications.
After you enable Agora Notifications, Agora sends channel event notification callbacks to your server using HTTPS POST requests. The data format is JSON, the character encoding is UTF-8, and the signature algorithm is HMAC/SHA1 or HMAC/SHA256.
This page describes the event types and payloads returned in channel event callbacks.
Request parameters
Request header
| Field | Description |
|---|---|
Content-Type | application/json |
Agora-Signature | The signature value generated by Agora using the customer key and the HMAC/SHA1 algorithm. Use the customer key and HMAC/SHA1 to verify the signature. |
Agora-Signature-V2 | The signature value generated by Agora using the customer key and the HMAC/SHA256 algorithm. Use the customer key and HMAC/SHA256 to verify the signature. |
Request body
| Field | Type | Description |
|---|---|---|
noticeId | String | Notification ID that identifies an event notification from the Agora service. |
productId | Number | Business ID that identifies the real-time communication service. |
eventType | Number | Event type. See Channel event types. |
notifyMs | Number | Unix timestamp in milliseconds when Agora sends the notification to your server. The value is updated when the notification is resent. |
sid | String | Session ID. |
payload | JSON Object | Event details. See Channel event types. |
Request example
{
"noticeId": "2000001428:4330:107",
"productId": 1,
"eventType": 101,
"notifyMs": 1611566412672,
"payload": {}
}Channel event types
| Type | Name | Description |
|---|---|---|
101 | channel create | Creates a channel. |
102 | channel destroy | Destroys a channel. |
103 | broadcaster join channel | In the live broadcasting profile, the host joins the channel. |
104 | broadcaster leave channel | In the live broadcasting profile, the host leaves the channel. |
105 | audience join channel | In the live broadcasting profile, an audience member joins the channel. |
106 | audience leave channel | In the live broadcasting profile, an audience member leaves the channel. |
107 | user join channel with communication mode | In the communication profile, a user joins the channel. |
108 | user leave channel with communication mode | In the communication profile, a user leaves the channel. |
111 | client role change to broadcaster | An audience member switches roles to become a host. |
112 | client role change to audience | A host switches roles to become an audience member. |
channel create
The channel is created when the first user joins. The payload contains:
| Field | Type | Description |
|---|---|---|
channelName | String | The channel name. |
ts | Number | Unix timestamp in seconds when the event occurred. |
{
"channelName": "test_webhook",
"ts": 1560396834
}channel destroy
The channel is destroyed when the last user leaves. The payload contains:
| Field | Type | Description |
|---|---|---|
channelName | String | The channel name. |
ts | Number | Unix timestamp in seconds when the event occurred. |
lastUid | Number | The ID of the last user to leave the channel. If multiple users leave at the same time, Agora Notifications may return several lastUid values. |
{
"channelName": "test_webhook",
"ts": 1560399999,
"lastUid": 12121212
}Join events
The following event types indicate that a user joined the channel:
103:broadcaster join channel105:audience join channel107:user join channel with communication mode
Join event payloads can contain the following fields:
| Field | Type | Description |
|---|---|---|
channelName | String | The channel name. |
uid | Number | The user ID in the channel. |
platform | Number | Device platform: 1 Android, 2 iOS, 5 Windows, 6 Linux, 7 Web, 8 macOS, 0 Other platforms. |
clientType | Number | Returned only when platform is 6. Common values include 3 Local Server Recording, 8 applets, and 10 Cloud Recording. |
clientSeq | Number | Serial number identifying the event order on the app client. |
ts | Number | Unix timestamp in seconds when the event occurred. |
account | String | The user ID. |
{
"channelName": "test_webhook",
"uid": 12121212,
"platform": 1,
"clientSeq": 1625051030746,
"ts": 1560396843,
"account": "test"
}Leave events
The following event types indicate that a user left the channel:
104:broadcaster leave channel106:audience leave channel108:user leave channel with communication mode
Leave event payloads can contain the following fields:
| Field | Type | Description |
|---|---|---|
channelName | String | The channel name. |
uid | Number | The user ID in the channel. |
platform | Number | Device platform: 1 Android, 2 iOS, 5 Windows, 6 Linux, 7 Web, 8 macOS, 0 Other platforms. |
clientType | Number | Returned only when platform is 6. |
clientSeq | Number | Serial number identifying the event order on the app client. |
reason | Number | Leave reason. See the reason table below. |
ts | Number | Unix timestamp in seconds when the event occurred. |
duration | Number | Time that the user stayed in the channel. |
account | String | The user ID. |
| Reason | Description |
|---|---|
1 | The user left the channel normally. |
2 | The connection between the client and Agora timed out. |
3 | Permission issue. For example, the user was kicked out through REST APIs. |
4 | Internal reason on the Agora service. |
5 | The user switched to a new device, forcing the old device to leave. |
9 | The client has multiple IP addresses, so the SDK actively disconnects and reconnects. |
10 | Network connection issue, such as a socket connection error. |
12 | Token error or expired token. |
99 | Unknown network problem. |
999 | Abnormal user activity, such as frequent login and logout. Your app server should call Create a banning rule to remove the user from the current channel. |
0 | Other reasons. |
{
"channelName": "test_webhook",
"uid": 12121212,
"platform": 1,
"clientSeq": 1625051030789,
"reason": 1,
"ts": 1560396943,
"duration": 600,
"account": "test"
}Client role change events
The following event types indicate that a user's live broadcasting role changed:
111:client role change to broadcaster112:client role change to audience
Payloads contain:
| Field | Type | Description |
|---|---|---|
channelName | String | The channel name. |
uid | Number | The user ID in the channel. |
clientSeq | Number | Serial number identifying the event order on the app client. |
ts | Number | Unix timestamp in seconds when the event occurred. |
account | String | The user ID. |
{
"channelName": "test_webhook",
"uid": 12121212,
"clientSeq": 1625051035469,
"ts": 1560396834,
"account": "test"
}