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

FieldDescription
Content-Typeapplication/json
Agora-SignatureThe 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-V2The 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

FieldTypeDescription
noticeIdStringNotification ID that identifies an event notification from the Agora service.
productIdNumberBusiness ID that identifies the real-time communication service.
eventTypeNumberEvent type. See Channel event types.
notifyMsNumberUnix timestamp in milliseconds when Agora sends the notification to your server. The value is updated when the notification is resent.
sidStringSession ID.
payloadJSON ObjectEvent details. See Channel event types.

Request example

{
  "noticeId": "2000001428:4330:107",
  "productId": 1,
  "eventType": 101,
  "notifyMs": 1611566412672,
  "payload": {}
}

Channel event types

TypeNameDescription
101channel createCreates a channel.
102channel destroyDestroys a channel.
103broadcaster join channelIn the live broadcasting profile, the host joins the channel.
104broadcaster leave channelIn the live broadcasting profile, the host leaves the channel.
105audience join channelIn the live broadcasting profile, an audience member joins the channel.
106audience leave channelIn the live broadcasting profile, an audience member leaves the channel.
107user join channel with communication modeIn the communication profile, a user joins the channel.
108user leave channel with communication modeIn the communication profile, a user leaves the channel.
111client role change to broadcasterAn audience member switches roles to become a host.
112client role change to audienceA host switches roles to become an audience member.

channel create

The channel is created when the first user joins. The payload contains:

FieldTypeDescription
channelNameStringThe channel name.
tsNumberUnix 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:

FieldTypeDescription
channelNameStringThe channel name.
tsNumberUnix timestamp in seconds when the event occurred.
lastUidNumberThe 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 channel
  • 105: audience join channel
  • 107: user join channel with communication mode

Join event payloads can contain the following fields:

FieldTypeDescription
channelNameStringThe channel name.
uidNumberThe user ID in the channel.
platformNumberDevice platform: 1 Android, 2 iOS, 5 Windows, 6 Linux, 7 Web, 8 macOS, 0 Other platforms.
clientTypeNumberReturned only when platform is 6. Common values include 3 Local Server Recording, 8 applets, and 10 Cloud Recording.
clientSeqNumberSerial number identifying the event order on the app client.
tsNumberUnix timestamp in seconds when the event occurred.
accountStringThe 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 channel
  • 106: audience leave channel
  • 108: user leave channel with communication mode

Leave event payloads can contain the following fields:

FieldTypeDescription
channelNameStringThe channel name.
uidNumberThe user ID in the channel.
platformNumberDevice platform: 1 Android, 2 iOS, 5 Windows, 6 Linux, 7 Web, 8 macOS, 0 Other platforms.
clientTypeNumberReturned only when platform is 6.
clientSeqNumberSerial number identifying the event order on the app client.
reasonNumberLeave reason. See the reason table below.
tsNumberUnix timestamp in seconds when the event occurred.
durationNumberTime that the user stayed in the channel.
accountStringThe user ID.
ReasonDescription
1The user left the channel normally.
2The connection between the client and Agora timed out.
3Permission issue. For example, the user was kicked out through REST APIs.
4Internal reason on the Agora service.
5The user switched to a new device, forcing the old device to leave.
9The client has multiple IP addresses, so the SDK actively disconnects and reconnects.
10Network connection issue, such as a socket connection error.
12Token error or expired token.
99Unknown network problem.
999Abnormal 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.
0Other 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 broadcaster
  • 112: client role change to audience

Payloads contain:

FieldTypeDescription
channelNameStringThe channel name.
uidNumberThe user ID in the channel.
clientSeqNumberSerial number identifying the event order on the app client.
tsNumberUnix timestamp in seconds when the event occurred.
accountStringThe user ID.
{
  "channelName": "test_webhook",
  "uid": 12121212,
  "clientSeq": 1625051035469,
  "ts": 1560396834,
  "account": "test"
}