Event callback
ApsaraVideo Live provides event notifications for live stream ingest, recording (including on-demand recording), snapshots, content moderation, and dual-stream disaster recovery. This topic describes how to configure these callbacks, lists the callback parameters, and provides examples.
Overview
ApsaraVideo Live sends event notifications via HTTP callbacks. HTTPS is also supported. To receive these notifications, you need to deploy an HTTP service and configure a callback URL in the ApsaraVideo Live console or by using an API.
HTTP GET: When a stream ingest or interruption event occurs, ApsaraVideo Live sends an HTTP GET request to your callback URL, with the event details delivered as URL parameters.
HTTP POST: When other types of events occur, ApsaraVideo Live sends an HTTP POST request to your callback URL, with the event details delivered in the JSON body.
Some SSL certificates are incompatible. If you encounter certificate issues, try an HTTP callback.
Usage notes
Connectivity: Your callback URL must be publicly accessible.
Timeout & Retries: The service expects a response within 5 seconds. If the request times out, it will retry up to 5 times at 1-second intervals.
Domain scoping:
Callbacks for stream ingest and dual-stream recovery can be configured only for ingest domains.
Callbacks for recording, snapshot, and content moderation can be configured only for streaming domains.
Callback management
Stream ingest callback
This callback notifies you of a domain's ingest status, including successful ingest, stream interruption, and ingest exceptions. Configure the callback URL in the console or using an API.
Console configuration
Log on to the ApsaraVideo Live console.
In the left-side navigation pane, choose Feature Management > Callbacks.
Select the Ingest Domain that you want to configure.
On the Callback Settings tab, enable the Stream Ingest Callbacks switch, and configure the following parameters:
Callback Type: Set callbacks for ingest and interruption events or exception events.
Callback URL: Your public endpoint for receiving the notifications. Ingest and interruption events use HTTP GET, and exception events use HTTP POST.
Callback Authentication: Select whether to enable authentication. When enabled, enter an authentication key. For authentication process, see Callback authentication.
Click OK.
API configuration
API | Description |
Adds an ingest callback configuration. | |
Queries an ingest callback configuration. | |
Deletes an ingest callback configuration. |
Ingest and interruption events
Callback logic
For stream pushing, ApsaraVideo Live sends a callback for successful ingest if the live source remains connected for at least two seconds after ApsaraVideo Live receives an OnPublish message.
If you use stream pulling (fixed-time or on-demand) for a streaming domain (Domain B) and require callback notifications, configure the stream ingest callback for the associated ingest domain (Domain A). The logic remains consistent: once the connection is established, the stream pulling is considered successful if the live source remains connected for at least two seconds.
Do not rely solely on callback notifications to determine if a stream has been successfully ingested. We recommend calling the API to query the online stream list. Confirm the stream is active before distributing the playback URL to users.
If no data is received by the ApsaraVideo Live live center for 10 seconds, the service will automatically terminate the ingest connection.
Parameters
Parameter | Description |
action | The type of event that triggered the callback.
|
ip | The IP address of the ingest client. |
id | The stream name. |
app | The ingest domain. If no ingest domain is associated, this parameter returns the streaming domain. |
appname | The AppName of the stream. |
time | The Unix timestamp, in seconds, when the callback was sent. |
usrargs | User-defined ingest parameters. |
node | The point of presence (POP) or server that receives the stream. |
height | The video height in pixels, provided only in the first callback. |
width | The video width in pixels, , provided only in the first callback. |
Example of an ingest event
http://1.1.X.X?action=publish&ip=192.168.0.1&id=world&app=example.aliyundoc.com&appname=liveApp****&time=1609220385&usrargs={user-defined-parameters}&node=cdnvideocenter01020711****.cm3&height=720&width=1280Example of an interruption event
http://1.1.X.X?action=publish_done&ip=192.168.0.0&id=world&app=example.aliyundoc.com&appname=liveApp****&time=1609220385&usrargs={user-defined-parameters}&node=cdnvideocenter01020711****.cm3&height=720&width=1280Ingest exception events
Parameters
Parameter | Description |
action | publish_exception_notify |
domain | The ingest domain. |
appname | The AppName of the stream. |
stream | The stream name. |
ip | The IP address of the ingest client. |
time | The Unix timestamp, in seconds, when the callback was sent. |
type | The exception event type. |
event_time | The Unix timestamp, in seconds, when the exception occurred. |
Exception types
Code | Event type |
1001 | The URL contains invalid characters. |
2001 | The video codec is on the blocklist. |
2002 | The video codec is not on the allowlist. |
2003 | The audio codec is on the blocklist. |
2004 | The audio codec is not on the allowlist. |
3001 | Failed to parse the audio header. |
3002 | Failed to parse the video header. |
3003 | Failed to parse the metadata. |
4001 | Inconsistent video width and height. |
4002 | The metadata indicates no audio data, but the stream contains audio data. |
4003 | The actual audio and video data does not match the header. |
4004 | The metadata indicates no video data, but the stream contains video data. |
4005 | The audio codec changed mid-stream. |
4006 | The video codec changed mid-stream. |
4007 | An audio frame was received before the audio header. |
4008 | A video frame was received before the video header. |
5001 | Excessive CTS jitter. |
5002 | Non-monotonic Decoding Time Stamps (DTS). |
5003 | The timestamp difference between audio and video is too large. |
5004 | The audio DTS increment is too large. |
5005 | The video DTS increment is too large. |
5006 | The interval between received audio frames is too long. |
5007 | The interval between received video frames is too long. |
5008 | The keyframe interval is too long. |
Example of an exception event
{
"action": "publish_exception_notify",
"domain": "demo.aliyundoc.com",
"appname": "liveApp****",
"stream": "liveStream****",
"ip": "141.01.****",
"time": "1739760710",
"type": "5002",
"event_time": "1739760710"
}Live recording callback
Live recording callbacks notify you of recording status, file generation, and recording errors.
Console configuration
Log on to the ApsaraVideo Live console.
In the left-side navigation pane, choose Feature Management > Callbacks.
Select the Streaming Domain that you want to configure.
On the Callback Settings tab, enable the Recording Callbacks switch and configure the following parameters:
Callback URL: Your public endpoint for receiving the notifications. Recording callbacks use HTTP POST requests.
Triggering Event: Select File Generation or File Generation and Recording Status.
On-demand Callback URL: If you have configured on-demand recording, the service sends an HTTP callback to this URL when a live stream begins. Your server must respond to this request to determine whether the stream should be recorded. By default, this parameter is set to
*, which disables the on-demand recording feature.Callback Authentication: Select whether to enable authentication. When enabled, enter an authentication key. For authentication process, see Callback authentication.
Click OK.
API configuration
API | Description |
Adds a recording callback configuration for a domain. | |
Queries a recording callback configuration. | |
Deletes a recording callback configuration for a domain. |
Recording status callback
Sent when a recording session starts or pauses.
Parameters
Parameter | Description |
domain | The streaming domain for the recording. |
app | The AppName of the stream. |
stream | The stream name. |
event | The event.
|
Example
{
"domain": "demo.aliyundoc.com",
"app": "liveApp****",
"stream": "liveStream****",
"event": "record_started"
}File generation callback
Sent upon file creation, providing details such as file path, duration, and timestamps.
Parameters
Parameter | Description |
domain | The streaming domain for the recording. |
app | The AppName of the stream. |
stream | The stream name. |
uri | The relative path of the recording file in your OSS bucket or ApsaraVideo VOD bucket. |
record_id | The ID of the index file. |
file_url | The full URL of the recording file. |
duration | The duration of the recording file, in seconds. |
start_time | The recording start time, as a Unix timestamp in seconds. |
stop_time | The recording end time, as a Unix timestamp in seconds. |
is_finished | Indicates whether the recording is complete. This parameter is returned only when the live stream is recorded to ApsaraVideo VOD. |
oss_endpoint | The storage endpoint. |
oss_bucket | The name of the storage bucket. |
push_args | User-defined parameters from the ingest URL starting with Note
|
Example
If the ingest URL is rtmp://demo.aliyundoc.com/liveApp****/liveStream****?callback_args1=value1&callback_myid=1231389741, the callback payload is as follows:
{
"domain": "demo.aliyundoc.com",
"app": "liveApp****",
"stream": "liveStream****",
"uri": "liveApp****/liveStream****/0_2017-03-08-23:09:46_2017-03-08-23:10:40.flv",
"file_url": "http://****.oss-****.aliyuncs.com/liveApp****/liveStream****/0_2017-03-08-23:09:46_2017-03-08-23:10:40.flv",
"duration": 69.403,
"start_time": 1488985786,
"stop_time": 1488985840,
"push_args": {
"callback_args1": "value1",
"callback_myid": "1231389741"
}
}Recording error callback
Triggered by source stream exceptions or storage write failures (OSS).
Parameters
Parameter | Description |
domain | The streaming domain for the recording. |
app | The AppName of the stream. |
stream | The stream name. |
event | The event type.
|
error_info | The error information in JSON format. It includes the following fields:
|
file_info | The file information. This parameter is returned only for
|
Example of an recording error
{
"domain": "example.com",
"app": "live",
"stream": "stream123",
"event": "record_error",
"error_info": {
"code": "TsSegmenterFail",
"message": "ts segmenter error"
}
}Error codes
Code | Message | Description |
BucketNotFound | Bucket not found | The bucket does not exist or has been deleted. |
AccessDenied | Bucket not belong config userId | The bucket does not belong to the account where the recording configuration is added. |
StreamFormatError | video stream format error | The live stream format is invalid. |
UserDisable | Unauthorized access to OSS by user | The user is not authorized to access OSS, or the authorization has been revoked. |
Example of a remuxing error
{
"domain": "example.com",
"app": "live",
"stream": "stream123",
"event": "transformat_error",
"error_info": {
"code": "PermissionDenied.ResourceAccess",
"message": "MTS not authorized to operate on the OutputBucket"
},
"file_info": {
"uri": "record/live/stream123/2025-11-19-03-17-03_2025-11-19-03-28-39.flv",
"start_time": 1763493420,
"stop_time": 1763494119
}
}Error codes
Code | Message | Description |
InvalidParameter.ResourceNotFound | The resource operated cannot be found | The bucket does not exist or has been deleted. |
InvalidParameter.ResourceContentBad | The resource operated InputFile is bad | Remuxing failed due to issues with the source stream quality. |
PermissionDenied.ResourceAccess | MTS not authorized to operate on the OutputBucket | The user is not authorized to access OSS, or the authorization has been revoked. |
On-demand recording callback
On-demand recording allows you to programmatically decide whether to record a live stream based on stream metadata.
When a live stream matches your pre-configured on-demand recording template (at the domain, app, or stream level), the recording service sends an HTTP request to your On-demand callback URL with the stream details. Your server must then respond to indicate whether to record the stream and provide specific recording settings.
Request parameters
Parameter | Type | Description |
domain | String | The streaming domain. |
app | String | The AppName of the stream. |
stream | String | The stream name. |
codec | String | The codec. Valid values:
|
vbitrate | String | The video bitrate. Unit: kbps. |
Request example
GET /?app=seq_all&domain=demo.aliyundoc.com&stream=ondemand8&vbitrate=2000&codec=h264 HTTP/1.1
Host: pull.aliyundoc.com
User-Agent: Go-http-client/1.1
Accept-Encoding: gzipResponse parameters
Parameter | Type | Required | Description |
ApiVersion | String | No | The API version. The default value is 1.0. |
NeedRecord | Boolean | Yes | Indicates whether to record the stream. |
Interval | JSONObject | No | The recording cycle for a specific format. Range: 5 to 21600. Unit: seconds. |
Format | JSONArray | No | The recording format. Supported formats: MP4, FLV, and M3U8. |
Response example
{
"ApiVersion": "1.0",
"NeedRecord": true,
"Interval": {
"Mp4": 300,
"Flv": 120,
"M3U8": 180
},
"Format": ["mp4","flv"]
}Response handling
The recording service processes your response to override existing configurations:
Interval: Your provided Interval value will override the recording cycle configured in the recording template.Format: The service calculates the intersection between your requested Format and the pre-configured formats in the recording template. If there are no common formats, the stream will not be recorded.
An HTTP status code other than 200 indicates a failed call to your API endpoint.
The response body cannot exceed 2,048 bytes. The system truncates any content beyond this limit for security purposes.
Live snapshot callback
ApsaraVideo Live supports event notifications for live snapshots. You can configure the callback URL in the console or via API.
Console configuration
Log on to the ApsaraVideo Live console.
In the left-side navigation pane, choose Feature Management > Callbacks.
Select the Streaming Domain that you want to configure.
On the Callback Settings tab, enable the Snapshot Callbacks switch and configure the following parameters:
Callback URL: Your public endpoint for receiving the notifications. Snapshot callbacks use HTTP POST requests.
Callback Authentication: Select whether to enable authentication. When enabled, enter an authentication key. For authentication process, see Callback authentication.
Click OK.
API configuration
API | Description |
Adds a live snapshot callback configuration. | |
Modifies a live snapshot callback configuration. | |
Queries the live snapshot callback configuration. | |
Deletes a live snapshot callback configuration. |
Snapshot callback parameters
Parameter | Description |
Event | The type of event. The value is |
DomainName | The streaming domain. |
AppName | The AppName of the stream. |
StreamName | The stream name. |
OssBucket | The name of the OSS bucket that stores the snapshots. |
OssEndpoint | The OSS endpoint where the snapshots are stored. |
OssObject | The name of the snapshot file in the OSS bucket. |
CreateTime | The timestamp when the snapshot was created. |
SnapshotUrl | The full URL of the snapshot file in the OSS bucket. |
Size | The size of the image in bytes. |
Width | The width of the image in pixels. |
Height | The height of the image in pixels. |
Example
{
"Event": "Snapshot",
"DomainName": "demo.aliyundoc.com",
"AppName": "liveApp****",
"StreamName": "liveStream****",
"OssBucket": "liveBucket****",
"OssEndpoint": "oss-cn-shan****.aliyuncs.com",
"OssObject": "1****.jpg",
"CreateTime": "2015-12-01T17:36:00Z",
"SnapshotUrl": "http://liveBucket****.oss-cn-shan****.aliyuncs.com/1****.jpg",
"Size": "36291",
"Width": "1280",
"Height": "720"
}Content moderation callback
ApsaraVideo Live supports event notifications for video and audio moderation results. You can configure the callback URL in the console or via API.
Video moderation callback
Triggered only for video content that is flagged as problematic.
Console configuration
Log on to the ApsaraVideo Live console.
In the left-side navigation pane, choose Feature Management > Callbacks.
Select the Streaming Domain that you want to configure.
On the Callback Settings tab, enable the Video Moderation Callbacks switch and configure the callback URL. The URL must point to your own endpoint. When a video moderation event is triggered, ApsaraVideo Live will send an HTTP POST request to your specified URL, with the event details delivered in the JSON body.
Click OK.
API configuration
API | Description |
Adds a video moderation callback configuration. | |
Queries a video moderation callback configuration. | |
Modifies a video moderation callback configuration. | |
Deletes a video moderation callback configuration. |
Callback parameters
The notification provides moderation details and the storage location of the snapshot taken from the flagged content.
Parameter | Type | Description |
DomainName | String | The streaming domain. |
AppName | String | The AppName of the stream. |
StreamName | String | The stream name. |
OssEndpoint | String | The OSS endpoint. |
OssBucket | String | The OSS bucket. |
OssObject | String | The object name. |
Result | JSONArray | The moderation results. For more information, see Result. |
Result
Parameter | Type | Description |
BizType | String | The business type. This parameter can be used to select a model. By default, the value is the domain name. |
Scene | String | The detection scene.
|
Label | String | The category of the result. The categories vary based on the detection scene. Categories for
Categories for
Categories for
Categories for
Categories for
|
Rate | Float | The confidence score. Range: 0 to 100. Note This value is for reference only. Do not use this value in your business logic. Use the |
Extent | String | A reserved parameter. |
This version is for new users by default. Existing users remain on their current version. To use this version, submit a ticket.
Example
{
"DomainName": "demo.aliyundoc.com",
"AppName": "liveApp****",
"StreamName": "liveStream****",
"OssEndpoint": "oss-cn-hang****.aliyuncs.com",
"OssBucket": "liveBucket****",
"OssObject": "example.jpg",
"Result": [
{
"BizType": "demo.aliyundoc.com",
"Result": [
{"Label": "Porn", "Rate": 11, "Suggestion": "review", "Scene": "porn", "Extent": {}},
{"Label": "Ad", "Rate": 11, "Suggestion": "review", "Scene": "ad", "Extent": {}}
]
}
]
}Audio moderation callback
Triggered only for audio content that is flagged as problematic.
Console configuration
Log on to the ApsaraVideo Live console.
In the left-side navigation pane, choose Feature Management > Callbacks.
Select the Streaming Domain that you want to configure.
On the Callback Settings tab, enable the Audio Moderation Callbacks switch and configure the callback URL. The URL must point to your own endpoint. When a video moderation event is triggered, ApsaraVideo Live will send an HTTP POST request to your specified URL, with the event details delivered in the JSON body.
Click OK.
API configuration
API | Description |
Adds an audio moderation callback configuration. | |
Deletes an audio moderation callback configuration. | |
Modifies an audio moderation callback configuration. | |
Queries an audio moderation callback configuration. |
Callback parameters
The notification includes the transcribed text of the problematic audio and the contextual information from the next minute.
Parameter | Type | Description |
DomainName | String | The streaming domain. |
AppName | String | The AppName of the stream. |
StreamName | String | The stream name. |
Timestamp | Int | The timestamp, in seconds. |
Result | JSONArray | The moderation results. For more information, see Result. |
Result
Parameter | Type | Description |
Scene | String | The detection scene. |
Label | String | The category of the detection result. Valid values:
|
Suggestion | String | The suggested action. Valid values:
|
Rate | Float | The confidence score. Range: 0 to 100. Note This value is for reference only. Do not use this value in your business logic. Use the |
Details | JSONArray | Details of the transcribed audio. The array contains one or more elements, and each element corresponds to a sentence. For the structure, see Detail. |
Detail
Parameter | Type | Description |
StartTime | Int | The start timestamp of the sentence, in seconds. |
EndTime | Int | The end timestamp of the sentence, in seconds. |
Text | String | The transcribed text. |
Label | String | The category of the detection result. Valid values:
|
Example
{
"DomainName": "example.aliyundoc.com",
"AppName": "liveApp****",
"StreamName": "5d9747eba39b44769852d276f9ff****",
"Timestamp": 1572248095,
"Result": [
{
"Scene": "antispam",
"Label": "ad",
"Suggestion": "block",
"Rate": 99.91,
"Details": [
{
"StartTime": 1572248023,
"EndTime": 1572248040,
"Text": "The hotel offers 120 days of free accommodation. It can be shared with friends and family. Visit the reception center at No. 96 Tuanjie Street, Mangshi. Hotline: 2285699.",
"Label": "ad"
},
{
"StartTime": 1572248040,
"EndTime": 1572248070,
"Text": "Discover a rare collection of classic villas nestled in the heart of the Hot Spring Resort Town. Located adjacent to the prestigious Longduo Hot Springs and the historic Lianghe Golden Pagoda, this is where luxury meets nature.",
"Label": "normal"
},
{
"StartTime": 1572248072,
"EndTime": 1572248077,
"Text": "Joyful times and cozy days, made all the more carefree with your beautiful company.",
"Label": "normal"
},
{
"StartTime": 1572248078,
"EndTime": 1572248086,
"Text": "fme043 A little break from the hustle with cozy music and movies.",
"Label": "normal"
}
]
}
]
}Dual-stream disaster recovery callback
This callback notifies you when a stream switch occurs for failover.
Console configuration
Log on to the ApsaraVideo Live console.
In the left-side navigation pane, choose Feature Management > Callbacks.
Select the Ingest Domain to configure.
On the Callback Settings tab, enable the Dual-stream Disaster Recovery Callbacks switch and configure the callback URL.
Click OK.
Callback parameters
Parameter | Description |
action | The event type. Fixed value: |
domain | The ingest domain. |
appname | The AppName of the stream. |
streamname | The stream name. |
upstreamsequence | The identifier of the primary stream after the switch. |
upstreamip | The IP address of the client publishing the primary stream after the switch. |
upstreamtime | The start time of the primary stream ingest after the switch. This is a Unix timestamp in seconds. |
changereason | The reason for the switchover. |
changetime | The time when the stream switchover occurred. This is a Unix timestamp in seconds. |
time | The time when the callback notification was generated. This is a Unix timestamp in seconds. |
Example
{
"action": "multistream_set_master_result",
"domain": "demo.aliyundoc.com",
"appname": "liveApp****",
"streamname": "liveStream****",
"upstreamsequence": "main",
"upstreamip": "203.**.***.10",
"upstreamtime": 17*****710,
"changereason": "merge_cut_manually",
"changetime": 17*****705,
"time": 17*****706
}Callback authentication
ApsaraVideo Live supports callback authentication for stream ingest, recording, snapshots, and dual-stream disaster recovery events. When enabled, authentication works as follows:
ApsaraVideo Live includes the ALI-LIVE-TIMESTAMP and ALI-LIVE-SIGNATURE headers in its callback requests, so your receiver server can verify that the callback request is authentic and has not been tampered with.
ALI-LIVE-SIGNATURE calculation
ALI-LIVE-SIGNATURE=MD5SUM(MD5CONTENT)
MD5CONTENT=Domain|ALI-LIVE-TIMESTAMP Value|Auth KEYwhere:
Domain: The domain source varies by callback type:For stream ingest and dual-stream disaster recovery callbacks: Use the ingest domain where the callback URL is configured.
For recording and snapshot callbacks: Use the domain of the callback URL. For example, if the callback URL is
https://learn.aliyundoc.com/your/callback, the domain value islearn.aliyundoc.com.
ALI-LIVE-TIMESTAMP: The UNIX timestamp when the request was sent. Unit: second.Auth KEY: The authentication key configured for the corresponding callback URL.
Receiver server authentication
When receiving callback messages, the callback message receiver server determines the callback domain based on the callback type. It then concatenates the callback domain, the value of ALI-LIVE-TIMESTAMP, and the authentication key, calculates the MD5 hash of this string, and compares the calculated hash value with the value of the ALI-LIVE-SIGNATURE header in the request. If the values do not match, the request is unauthorized.
Callback records
The ApsaraVideo Live console supports viewing the history and payloads of live stream ingest and recording callback events. Other callback types are not supported.
Limitations
New or updated callback configurations require up to 5 minutes to take effect. After they take effect, callback records appear as expected.
Up to 1,000 callback records from the last 7 days are available.
Steps
Log on to the ApsaraVideo Live console.
In the left-side navigation pane, click Feature Management > Callbacks.
Select the ingest or streaming domain where the callback URL is configured.
On the Callback Records tab, select Stream Ingest Callbacks or Recording Callbacks.
You can filter the callback records by time range, AppName, and StreamName.