The formats of the events that are passed to a function handler vary. This topic describes the event formats for different triggers.

Time trigger

{
    "triggerTime":"2018-02-09T05:49:00Z",
    "triggerName":"timer-trigger",
    "payload":"awesome-fc"
}            
Filed Type Example Description
triggerTime String 2018-02-09T05:49:00Z The triggering time of the function.
triggerName String timer-trigger The name of the time trigger.
payload String awesome-fc The value of the Trigger parameter that you enter in the trigger configuration.

OSS trigger

{
  "events": [
    {
      "eventName": "ObjectCreated:PutObject",
      "eventSource": "acs:oss",
      "eventTime": "2021-08-13T06:45:43.000Z",
      "eventVersion": "1.0",
      "oss": {
        "bucket": {
          "arn": "acs:oss:cn-shanghai:123456789:bucketname",
          "name": "testbucket",
          "ownerIdentity": "123456789"
        },
        "object": {
          "deltaSize": 122539,
          "eTag": "688A7BF4F233DC9C88A80BF985AB7329",
          "key": "image/a.jpg",
          "size": 122539
        },
        "ossSchemaVersion": "1.0",
        "ruleId": "9adac8e253828f4f7c0466d941fa3db81161****"
      },
      "region": "cn-shanghai",
      "requestParameters": {
        "sourceIPAddress": "140.205.XX.XX"
      },
      "responseElements": {
        "requestId": "58F9FF2D3DF792092E12044C"
      },
      "userIdentity": {
        "principalId": "123456789"
      }
    }
  ]
}           
The following table describes parameters that are contained in event.
Parameter Type Example Description
eventName String ObjectCreated:PutObject The type of the event.
eventSource String acs:oss The event source. The value is fixed as acs.oss.
eventTime String 2021-08-13T06:45:43.000Z The time when the event occurred. The time is in the ISO 8601 standard format.
eventVersion String 1.0 The version of the event protocol.
oss Map The content of the OSS event.
bucket Map The details of the OSS bucket.
name String testbucket The name of the bucket.
arn String acs:oss:cn-shanghai:123456789:bucketname The Alibaba Cloud Resource Name (ARN) of the bucket.
ownerIdentity String 123456789 The ID of the user that created the bucket.
object Map The details of the OSS object.
size Int 122539 The size of the OSS object. Unit: byte.
deltaSize Int 122539 The variation of the size of the OSS object. Unit: byte.
  • If a new object is added, the value of this parameter specifies the size of the object.
  • If a new object overwrites the object that has the identical name, the value of this parameter specifies the size difference between the new object and the original object.
eTag String 688A7BF4F233DC9C88A80BF985AB7329 The tag of the object.
key String image/a.jpg The name of the object.
ossSchemaVersion String 1.0 The version of the OSS schema.
ruleId String 9adac8e253828f4f7c0466d941fa3db81161**** The ID of the rule that matches the event.
region String cn-shanghai The region in which the bucket is located.
requestParameters Map The request parameters.
sourceIPAddress String 140.205.XX.XX The IP address from which the request is sent.
responseElements Map The response elements.
requestId String 58F9FF2D3DF792092E12044C The ID of the request.
userIdentity Map The property of the user.
principalId String 123456789 The ID of the Alibaba Cloud account that initiated the request.

Log Service trigger

The event parameter is an input parameter of Function Compute. The following code shows the format of parameters:
{
    "parameter": {},
    "source": {
        "endpoint": "http://cn-shanghai-intranet.log.aliyuncs.com",
        "projectName": "log-com",
        "logstoreName": "log-en",
        "shardId": 0,
        "beginCursor": "MTUyOTQ4MDIwOTY1NTk3ODQ2Mw==",
        "endCursor": "MTUyOTQ4MDIwOTY1NTk3ODQ2NA=="
    },
    "jobName": "1f7043ced683de1a4e3d8d70b5a412843d81****",
    "taskId": "c2691505-38da-4d1b-998a-f1d4bb8c****",
    "cursorTime": 1529486425
}                       
Parameter Description Example
parameter The value of Invocation Parameters. None
source The log block information that you want the function to read from Log Service.
  • endpoint: the Alibaba Cloud region in which the Log Service project is located.
  • projectName: the name of the Log Service project.
  • logstoreName: the name of the Logstore.
  • shardId: the ID of a specified shard in the Logstore.
  • beginCursor: the location where data consumption starts.
  • endCursor: the location where data consumption ends.
{
    "endpoint":"http://cn-shanghai-intranet.log.aliyuncs.com",
    "projectName":"log-com",
    "logstoreName":"log-en",
    "shardId":0,
    "beginCursor":"MTUyOTQ4MDIwOTY1NTk3ODQ2Mw==",
    "endCursor":"MTUyOTQ4MDIwOTY1NTk3ODQ2NA=="
}
jobName The name of an extract, transform, and load (ETL) job in Log Service. The Log Service trigger that is configured for the function corresponds to an ETL job of Log Service. 1f7043ced683de1a4e3d8d70b5a412843d81****
taskId For an ETL job, taskId is the identifier for a deterministic function invocation. c2691505-38da-4d1b-998a-f1d4bb8c****
cursorTime The Unix timestamp of the time when the last log arrives at Log Service. 1529486425

CDN trigger

{  "events": [
      {
         "eventName": "CdnDomainStarted",
         "eventVersion": "1.0.0",
         "eventSource": "cdn",
         "region": "cn-hangzhou",
         "eventTime": "2018-03-16T14:19:55+08:00",
         "traceId": "cf89e5a8-7d59-4bb5-a33e-4c3d08e25acf",
         "resource": {
              "domain": "example.com"
         },
         "eventParameter": {
              "domain": "example.com"
         },
         "userIdentity": {
              "aliUid": "164901546557****"
         }
      }
   ]
}
The following table explains the parameters involved in the event.
Filed Type Example Description
eventName String CachedObjectsRefreshed The type of the event involved.
eventSource String cdn The name of the event source.
region String cn-hangzhou The region where the Alibaba Cloud Content Delivery Network resides. Default value: cn-hangzhou.
eventVersion String 1.0.0 The version of the event trigger.
eventTime String 2018-06-14T15:31:49+08:00 The time at which an event occurred.
traceId String c6459282-6a4d-4413-894c-e4ea39686738 The ID passed by the event source for troubleshooting.
resource String The information of the resources.
domain String example.com The domain names that correspond to the IP addresses that were blocked or unblocked.
eventParameter String The parameters of the event.
domain String example.com The domain names that correspond to the IP addresses that were blocked or unblocked.
userIdentity String The attributes of the user.
aliUid String 164901546557**** The ID of your Alibaba Cloud account.

Tablestore trigger

{
    "Version": "Sync-v1",
    "Records": [
        {
            "Type": "PutRow",
            "Info": {
                "Timestamp": 1506416585740836
            },
            "PrimaryKey": [
                {
                    "ColumnName": "pk_0",
                    "Value": 1506416585881590900
                },
                {
                    "ColumnName": "pk_1",
                    "Value": "2017-09-26 17:03:05.8815909 +0800 CST"
                },
                {
                    "ColumnName": "pk_2",
                    "Value": 1506416585741000
                }
            ],
            "Columns": [
                {
                    "Type": "Put",
                    "ColumnName": "attr_0",
                    "Value": "hello_table_store",
                    "Timestamp": 1506416585741
                },
                {
                    "Type": "Put",
                    "ColumnName": "attr_1",
                    "Value": 1506416585881590900,
                    "Timestamp": 1506416585741
                }
            ]
        }
    ]
}
The following table explains the parameters involved in the event.
Parameter Category Example Description
Version String Sync-v1 The version number of the Payload.
Records Array The array that contains the row of incremental data in the data table.
Type String PutRow The type of the data row. Valid values:
  • PutRow: inserts a row of data.
  • UpdateRow: updates the specified row data.
  • DeleteRow: deletes a specified row.
Info String The basic information of the data row.
Timestamp Int64 1506416585740836 The time when the data row was last modified in UTC.
PrimaryKey Array The array that stores the primary key column.
ColumnName String pk_0 The name of the primary key column.
Value String, Integer, or Blob 1506416585881590900 The content of the primary key column.
Columns Array The array that stores the attribute columns.
Type String Put The type of the attribute column. Valid values:
  • Put: Add a version.
  • DeleteOneVersion: deletes a version.
  • DeleteAllVersions: Delete all versions.
ColumnName String attr_0 The name of the attribute column.
Value Integer, Boolean, Double, String, or Blob hello_table_store The content of the attribute column.
Timestamp Int64 1506416585741 The time when the attribute column was last modified in UTC.

MNS topic trigger

  • When you create a trigger, if the event format is set to STREAM.
    • If the message attribute (MessageAttributes) is excluded from the message, the event format is as follows.

      Note If the message attribute (MessageAttributes) is excluded from the message, the content of the event is formatted as a JSON string.
      # The message body. 
      'hello topic'
    • If the message contains a message attribute (MessageAttributes), the event format is as follows.

      Note The content of the event contains MessageAttributes-related key-value pairs. For more information, see PublishMessage.
          {
              "body": "hello topic",
              "attrs": {
                  "Extend": "{\\"key\\":\\"value\\"}"
              }
          }                    
  • When you create a trigger, if the event format is set to JSON.
    • If the message attribute (MessageAttributes) is excluded from the message, the event format is as follows.

          {
              "TopicOwner": "118620210433****",
              "Message": "hello topic",
              "Subscriber": "118620210433****",
              "PublishTime": 1550216480040,
              "SubscriptionName": "test-fc-subscribe",
              "MessageMD5": "BA4BA9B48AC81F0F9C66F6C909C3****",
              "TopicName": "Mytopic",
              "MessageId": "2F5B3C082B923D4EAC694B76D928****"
          }        
                                  
    • If the message contains a message attribute (MessageAttributes), the event format is as follows.

      Note The content of the event contains MessageAttributes-related key-value pairs. For more information, see PublishMessage.
          {
              "key": "value",
              "TopicOwner": "118620210433****",
              "Message": "hello topic",
              "Subscriber": "118620210433****",
              "PublishTime": 1550216302888,
              "SubscriptionName": "test-fc-subscribe",
              "MessageMD5": "BA4BA9B48AC81F0F9C66F6C909C3****",
              "TopicName": "Mytopic",
              "MessageId": "2F5B3C281B283D4EAC694B742528****"
          }
                                  
The following table explains the parameters involved in the event.
Filed Type Example Description
key String value Key-value pairs related to message attributes.
TopicOwner String 118620210433**** The AccountId of the subscribed topic.
Message String hello topic The content of the message.
Subscriber String 118620210433**** The AccountId of the user.
PublishTime Map 1550216302888 The time when the message was published.
SubscriptionName String test-fc-subscribe The name of the subscription.
MessageMD5 String BA4BA9B48AC81F0F9C66F6C909C3**** The MD5 hash of the message body.
TopicName String Mytopic The name of the topic.
MessageId String 2F5B3C281B283D4EAC694B742528**** The ID of the message.

API Gateway trigger

{
    "path":"api request path",
    "httpMethod":"request method name",
    "headers":{all headers,including system headers},
    "queryParameters":{query parameters},
    "pathParameters":{path parameters},
    "body":"string of request payload",
    "isBase64Encoded":"true|false, indicate if the body is Base64-encode"
}  
Note
  • If the value of isBase64Encoded is true, the body content that API Gateway sends to Function Compute is Base64-encoded. Function Compute must perform Base64 decoding on the body content before processing.
  • If the value of isBase64Encoded is false, API Gateway does not perform Base64 encoding on the body content. Function Compute can directly obtain the body content.

RocketMQ trigger

{
    "id":"94ebc15f-f0db-4bbe-acce-56fb72fb****",
    "source":"RocketMQ-Function-rocketmq-trigger",
    "specversion":"1.0",
    "type":"mq:Topic:SendMessage",
    "datacontenttype":"application/json; charset=utf-8",
    "subject":"acs:mq:cn-hangzhou:164901546557****:MQ_INST_164901546557****_BXhFHryi%TopicName",
    "time":"2021-04-08T06:01:20.766Z",
    "aliyunaccountid":"164901546557****",
    "aliyunpublishtime":"2021-10-15T02:05:16.791Z",
    "aliyunoriginalaccountid":"164901546557****",
    "aliyuneventbusname":"RocketMQ-Function-rocketmq-trigger",
    "aliyunregionid":"cn-chengdu",
    "aliyunpublishaddr":"42.120.XX.XX",
    "data":{
        "topic":"TopicName",
        "systemProperties":{
            "MIN_OFFSET":"0",
            "TRACE_ON":"true",
            "MAX_OFFSET":"8",
            "MSG_REGION":"cn-hangzhou",
            "KEYS":"systemProperties.KEYS",
            "CONSUME_START_TIME":1628577790396,
            "TAGS":"systemProperties.TAGS",
            "INSTANCE_ID":"MQ_INST_164901546557****_BXhFHryi"
        },
        "userProperties":{

        },
        "body":"TEST"
    }
}     
The following table describes the parameters in the data field. For more information about the parameter definition in the CloudEvents specification, see Overview.
Parameter Type Example Description
topic String TopicName The name of the topic.
systemProperties Map The system properties.
MIN_OFFSET Int 0 The minimum offset.
TRACE_ON Boolean true Indicates whether a message trace exists. Valid values:
  • true: A message trace exists.
  • false: No message trace exists.
MAX_OFFSET Int 8 The maximum offset.
MSG_REGION String cn-hangzhou The region from which the message was sent.
KEYS String systemProperties.KEYS The keys for filtering.
CONSUME_START_TIME Long 1628577790396 The start time of consumption. Unit: milliseconds.
UNIQ_KEY String AC14C305069E1B28CDFA3181CDA2**** The unique key of the message.
TAGS String systemProperties.TAGS The tags for filtering.
INSTANCE_ID String MQ_INST_123456789098****_BXhFHryi The ID of the instance.
userProperties Map N/A The user properties.
body String TEST The content of the message.

RabbitMQ trigger

  {
    "id":"bj694332-4cj1-389e-9d8c-b137h30b****",
    "source":"RabbitMQ-Function-rabbitmq-trigger",
    "specversion":"1.0",
    "type":"amqp:Queue:SendMessage",
    "datacontenttype":"application/json;charset=utf-8",
    "subject":"acs:amqp:cn-hangzhou:164901546557****:/instances/amqp-cn-tl32e756****/vhosts/eb-connect/queues/housekeeping",
    "time":"2021-08-12T06:56:40.709Z",
    "aliyunaccountid":"164901546557****",
    "aliyunpublishtime":"2021-10-15T08:58:55.140Z",
    "aliyunoriginalaccountid":"164901546557****",
    "aliyuneventbusname":"RabbitMQ-Function-rabbitmq-trigger",
    "aliyunregionid":"cn-chengdu",
    "aliyunpublishaddr":"42.120.XX.XX",
    "data":{
        "envelope":{
            "deliveryTag":98,
            "exchange":"",
            "redeliver":false,
            "routingKey":"housekeeping"
        },
        "body":{
            "Hello":"RabbitMQ"
        },
        "props":{
            "contentEncoding":"UTF-8",
            "messageId":"f7622d51-e198-41de-a072-77c1ead7****"
        }
    }
}
The following table describes the parameters in the data field. For more information about the parameter definition in the CloudEvents specification, see Overview.
Parameter Type Example Description
body Map The content of the message.
Hello String EventBridge The user data.
props Map The properties of the message.
contentEncoding String utf-8 The format in which the content of the message is encoded.
messageId String f7622d51-e198-41de-a072-77c1ead7**** The ID of the message. The ID of each message is unique.
envelope Map The envelope information about the message.
deliveryTag Int 98 The tag of the message.
exchange String N/A The name of the exchange that sent the message.
redeliver Boolean false Indicates whether the message can be resent. Valid values:
  • true: The message can be resent.
  • false: The message cannot be resent.
routingKey String housekeeping The routing rule of the message.

MNS queue trigger

{
    "id":"c2g71017-6f65-fhcf-a814-a396fc8d****",
    "source":"MNS-Function-mnstrigger",
    "specversion":"1.0",
    "type":"mns:Queue:SendMessage",
    "datacontenttype":"application/json; charset=utf-8",
    "subject":"acs:mns:cn-hangzhou:164901546557****:queues/zeus",
    "time":"2021-04-08T06:28:17.093Z",
    "aliyunaccountid":"1649015465574023",
    "aliyunpublishtime":"2021-10-15T07:06:34.028Z",
    "aliyunoriginalaccountid":"164901546557****",
    "aliyuneventbusname":"MNS-Function-mnstrigger",
    "aliyunregionid":"cn-chengdu",
    "aliyunpublishaddr":"42.120.XX.XX",
    "data":{
        "requestId":"606EA3074344430D4C81****",
        "messageId":"C6DB60D1574661357FA227277445****",
        "messageBody":"TEST"
    }
}
The following table describes the parameters in the data field. For more information about the parameter definition in the CloudEvents specification, see Overview.
Parameter Type Example Description
requestId String 606EA3074344430D4C81**** The ID of the request. The ID of each request is unique.
messageId String C6DB60D1574661357FA227277445**** The ID of the message. The ID of each message is unique.
messageBody String TEST The content of the message.

HTTP trigger

The function signatures for HTTP triggers are request and response objects, instead of event objects. Therefore, HTTP triggers do not follow the formats of events. For more information, see Configure an HTTP trigger.