Request format
We send a POST request to thecb_url you registered. The event name appears in both the query parameters and the request body:
data; the three outer fields are always the same. time is the Unix timestamp (in seconds) when the event occurred.
Verify the signature (required)
The signature in the callback request headers uses exactly the same algorithm as server API calls (see the Overview), just in the opposite direction: this time we sign with yourapp_key and you verify. The request headers are app_id / nonce / timestamp / signature.
Without signature verification, anyone who knows your callback URL can forge events. Don’t skip this step.
Response requirements
- The HTTP status code must be
200 - The response body must be standard JSON:
{"code": 0} - Our request timeout is 5 seconds. Your handler must return within that time (move heavy work to async processing)
Only
agent_join and agent_operate are synchronous; all others are asynchronous notifications.
Asynchronous notification events
channel_open — Channel opened
channel_destroy — Channel destroyed
reason: 1 destroyed explicitly (the destroy endpoint was called), 2 destroyed automatically because the online count reached 0.
user_join — User joins the channel
user_leave — User leaves the channel
reason:1left voluntarily,2removed,3replaced by another session with the same uid,4heartbeat timeout,5channel destroyed,6switched to audience,7device connection lost7only applies to SIP / H.323 terminals joined through the device gateway: the terminal dropped abnormally (signaling or media timeout, network failure). A normal hang-up on the terminal is still1, so you can tell a normal hang-up from an unexpected droponlineis the number of online users in the channel after this user left;0means the channel is now empty
user_stream_change — The streams a user publishes change
Sent when a user starts or stops publishing a stream (turning the microphone, camera, screen sharing, and so on on or off).
desc). SRTC does not interpret desc — you set it when publishing a
track. Which desc means microphone or camera is up to your own convention.
- Sent only when the set of
descvalues the user is publishing changes. Changing resolution, bitrate, or other parameters does not trigger it - Several tracks with the same
desc(such as simulcast layers) count as one opened/closedare thedescvalues that started or stopped publishing this time;descsis everydescstill published after the change- All changes from one update arrive in a single event. To tell whether a medium was turned on or off, rebuild the
previous set as
descsminusopenedplusclosed, then compare it withdescs name/avatar/join_athelp you lay out a mixed picture yourself.avatarcomes from the user propertyprops.avatarand is empty if not set- No further event is sent when the user leaves the channel; treat
user_leaveas “stopped publishing everything” - Events may arrive out of order. Trust the one with the largest
ts_ms(milliseconds)
im_connect / im_disconnect — IM device online / offline
im_disconnect has an extra reason, with the same values as user_leave.
device_type: 0 unknown, 1 Windows, 2 Android, 3 iOS, 4 Linux, 5 macOS, 6 WebRTC, 7 WeChat Mini Program, 8 HarmonyOS.
From 80 up is the range for agents joining on the server side (81 MCU, 82 SIP, 83 H.323, 84 GB28181, 85 RTSP, 86 RTMP, 87 file playback, 88 deprecated (number reserved, no longer used), 89 transcription, 90 voice recording, 91 single-stream output).
Devices joining through the device gateway report their own actual type (for example 82 for SIP and 83 for H.323), not a uniform 80.
agent_online / agent_offline — Device online / offline
Tells you whether a device is online outside the channel: a phone or GB28181 camera is online once it registers with the device gateway, and offline once it unregisters or disconnects.
A direct IP phone or endpoint is probed periodically by the device gateway: it’s online when a probe succeeds, and offline after several probes fail in a row.
This is unrelated to whether it’s in a channel (for joining and leaving a channel, see user_join / user_leave).
agent_offline has two extra fields:
idis the device ID in List devices;gwis the gateway the device is ontype:2SIP,3H.323,4GB28181 surveillancecontactidentifies the device: the registration username for SIP, the short number for H.323, and the device number for GB28181 (sip_no, not a channel number); for a direct IP device, it’s the address you registered (ip:port)reason:1the device unregistered,4heartbeat timeout,7unreachable by probe (direct IP devices only)heartbeat_atis the time of the last heartbeat. An offline event caused by heartbeat timeout waits for the timeout to be determined, so it’s sent 5–7 minutes after the actual disconnect. When you need the actual disconnect time, use this field
regsip, regh323, gb28181) send these two events based on their registration status.
For direct IP devices (ipsip, iph323), the device gateway probes them periodically to determine their online status: for H.323 it tries to connect to the endpoint’s TCP call port
(1720 if no port is given), and for SIP it sends the endpoint an OPTIONS request (5060 if no port is given; for a direct-dial address in the form number@IP:port, the address after @ is probed). If it connects or gets a response, the device is online;
after several failed probes in a row (3 by default, one every 30 seconds), agent_offline is sent with reason 7.
An endpoint that’s in a call is treated as online and isn’t probed. RTSP stream pull still has no online or offline status.
Probing direct IP devices has a few limitations:
- The device gateway must be able to reach the endpoint’s IP directly. An endpoint behind NAT that the gateway can’t reach can’t be probed and is reported as offline
- A few endpoints don’t respond to
OPTIONSfrom unknown sources (allowlists, security policies) and are also reported as offline. Verify with the actual endpoint model before going live - Offline notifications are delayed by about “probe interval × failure count”, roughly 1.5 minutes by default
agent_online again;
when heartbeats resume after going offline, an online event is sent again. Devices don’t belong to a particular app, so every app that subscribes to this event receives it.
agent_invite_failed — Device invitation failed
Sent when a device invited with Invite devices to the channel failed to enter:
no/type/contact: the target room number, device type (2SIP,3H.323,4GB28181,5RTSP, and so on), and device identifier from the invitationname: the device nameuid: the device’s uid in the channel (starts with_agent_). Only devices registered in the device list have one; it’s empty for ad hoc devices called directlycode: whenreasonisjoin_refused, the error code for the refused entry (for example, the code you returned when rejecting theagent_joincallback);0otherwisemsg: the original description, such as a SIP status line, an H.323 release reason, a stream pull error, or a server message, for troubleshooting
reason values: busy endpoint busy, rejected endpoint declined, no_answer no answer, unreachable can’t call / can’t connect,
stream_failed stream pull failed, join_refused entry refused (the call went through but entry was refused, and retries still failed), error other.
- Sent only for devices invited by the platform; failures of devices dialing in by themselves are not sent
- At most once per invitation; a device that entered successfully and then dropped off is not an invitation failure, that goes through
user_leave(reason7) - Requires a newer device gateway version; older device gateways don’t report it
mcu_task — Recording or stream mixing task status changes
task_typeis a bit mask; for its meaning, see the Cloud recording and stream mixing guidetask_status:0pending,1in progress,2ending,3ended abnormally,4ended normallyerr_deschas content only when the task ended abnormallyrecord_count/total_duration/total_sizeare the number of files, total duration (seconds), and total bytes produced by this recording
record_count in this event is often still 0: recording files start transcoding and uploading only after the task ends.
Once all files are uploaded, we send this event once more, and the counts in that one are complete. Use it for reconciliation.
mcu_record — A recording file is complete
- The recording is longer than the segment limit (1 hour by default): it is split into rolling segments by duration during transcoding, with continuous time between segments
- The underlying recording stops automatically partway through because there has been no audio or video for 30 seconds, and is then restarted: a new segment starts, with a time gap between segments
- Get playback URLs by
record_id, nottask_id—task_idbelongs to the task, and one task has severalrecord_ids. Pass it when calling Get a recording file’s playback URL seqstarts at 1; sorting by it gives the playback orderoffset_msis this segment’s offset (in milliseconds) from the start of the whole recording; use it to build the progress bar for continuous playback of several segments.began_at/ended_atare wall-clock times, for aligning with the timeline of your own businessreason:1split by duration,2resumed after an interruption (there is a gap from the previous segment; continuous playback jumps there, so it’s worth showing a hint in your UI),3final segment when the task ended,0unknownis_lastbeingtruemeans all files of this recording have been produced, and you can start assembling the complete playback
vod_size is in bytes; duration is in seconds.
mcu_alarm — Recording task alarm
alarm_brief above means “Task ended abnormally”.) Use it to feed your own alerting system. Recording is billed continuously, and if no one notices an abnormal interruption, what you lose is the recording itself.
Push tasks that keep failing also use this event (see Media output guide · Push failure alarms):
task_type0means it’s a push alarm, andtask_idis then the push task’spush_id, not an MCU task, so don’t pass it tomcu/*endpointstask_typegreater than0means an MCU task alarm, with the same bit meanings asmcu_task
talkrec_task — Voice recording task status changes
task_status: 0 pending, 1 in progress, 3 ended abnormally, 4 ended normally (there is no “ending” state as in mcu).
Starting voice recording is asynchronous—calling the endpoint only means the request was accepted. The task changes to in progress only after the voice recording gateway joins the channel successfully,
so this event is the most reliable signal of “whether voice recording is actually running”.
talkrec_record — A voice segment is complete
record_idis the segment ID used to get the playback URL, nottask_idduration_msis in milliseconds (segments are usually only a few seconds long, so second-level precision isn’t enough)end_reason, why the segment closed:0unknown,1normal end (talk button released),2split on timeout,3user left,4task stopped,5idle timeout (fallback)
end_reason is worth watching: 2 means the segment was cut off by the duration limit (one utterance is split into several segments),
and 5 means the server closed the segment as a fallback. If it appears often, silence detection isn’t wrapping up segments properly, and it’s worth checking the audio quality.
ai_summary_ready — Meeting minutes generation finished
session_idis the recognition session ID, the same as the one returned by Start speech recognitionstatus:2completed,3failed; on failureerrorgives the reason, and it is empty on success- The minutes content is long and is not included in the callback; when you receive it, call Get meeting minutes with
session_id
status: 3 sent.
At the same time, the channel also receives a custom message whose action is ai_summary_ready (carrying only session_id and status),
which clients can use to refresh the minutes they display.
Synchronous events
For these two events, we wait for your answer before continuing, so your handling must be fast (5-second timeout).agent_join — Device requests to join the channel
type is the agent type: 1 MCU, 2 SIP, 3 H.323, 4 GB28181 surveillance, 5 RTSP stream pull, 6 RTMP stream pull, 7 file playback, 8 deprecated (number reserved, no longer used), 9 transcription.
no is the target room number the device wants to join (the meeting number in your own business).
You need to turn it into a session: use no to find the corresponding channel, call Get a channel join token to get a sid, and return it to us as is:
code rejects the device’s join. If your user details don’t need extended props and the device is unconditionally trusted, you can skip subscribing to this event.
agent_operate — A device in the channel is controlled (microphone or camera on/off, start/stop sharing)
op_type:
Returning a non-zero
code rejects the operation. If you don’t subscribe to this event, all media operations on devices are allowed automatically (share requests from endpoints are allowed too).
An endpoint’s share is published in the channel as screen sharing (screen), just like screen sharing from a client. Sharing started or stopped through the server API
Turn device sharing on or off
(starting applies to stream-pulling devices only) does not trigger agent_start_share / agent_stop_share: you started it yourself, so you aren’t asked again.
Idempotency and ordering
Callbacks are delivered at least once, with no guarantee of ordering or uniqueness:- Retries lead to duplicate deliveries, so make your handling idempotent by a combination such as
channel+uid+time - The network and queues can reorder events, so don’t rely on “join arrives before leave” to track state yourself; when you need authoritative state, use the query endpoints