You can call this operation to create a trigger.

Request headers

This operation uses only common request headers. For more information, see Common parameters.

Request syntax

POST /services/{serviceName}/functions/{functionName}/triggers 

Request parameters

Parameter Type Position Required Example Description
serviceName String Path Yes service_name

The name of the service.

functionName String Path Yes function_name

The name of the function.

Object Body Yes

The definition of the trigger.

invocationRole String Body Yes acs:ram::198611****4430:role/aliyunosseventnotificationrole

The role required when the trigger source such as OSS invokes the function. For more information, see Overview.

qualifier String Body Yes LATEST

The version or alias of the service.

sourceArn String Body Yes acs:oss:cn-shanghai:12345:mybucket

The Alibaba Cloud Resource Name (ARN) of the event source for the trigger.

triggerConfig String Body Yes true

The configurations of the trigger. The configurations vary with trigger types.

triggerName String Body Yes trigger_name

The name of the trigger.

triggerType String Body Yes oss

The type of the trigger. Valid values:

  • oss: the OSS trigger. For more information, see Overview of OSS event triggers.
  • log: the Log Service trigger. For more information, see Overview of SLS triggers.
  • timer: the timer trigger. For more information, see Timer trigger.
  • http: the HTTP trigger. For more information, see Overview.
  • tablestore: the Tablestore trigger. For more information, see Overview.
  • cdn_events: the CDN event trigger. For more information, see Overview.
  • mns_topic: the MNS topic trigger. For more information, see Overview.

Response parameters

Parameter Type Example Description
ETag String 738136ea26b79cee660862cd7628****

The ETag value of the trigger name. This value is used to ensure that the modified trigger is consistent with the trigger to be modified.

createdTime String 2016-08-15T15:00:00.000+0000

The time when the trigger was created.

invocationRole String acs:ram::198611****4430:role/aliyunosseventnotificationrole

The role required when the trigger source such as OSS invokes the function. For more information, see Overview.

lastModifiedTime String 2020-04-08T01:48:21Z

The last time when the trigger was updated.

qualifier String LATEST

The version of the service. For more information, see Manage versions.

sourceArn String acs:oss:cn-shanghai:12345:mybucket

The Alibaba Cloud Resource Name (ARN) of the event source for the trigger.

triggerConfig String true

The configurations of the trigger. The configurations vary with trigger types.

triggerName String trigger_name

The name of the trigger.

triggerType String oss

The type of the trigger. Valid values:

Examples

Sample requests

POST /services/service_name/functions/function_name/triggers HTTP/1.1 
            

Sample success responses

JSON format

HTTP/1.1 200 OK Common response headers {   "triggerName": "trigger_name",   "description": "test_description",   "triggerId": "b883122b-6f86-4889-bb69-1729a41***",   "sourceArn": "acs:oss:cn-shanghai:12345:mybucket",   "triggerType": "oss",   "invocationRole": "acs:ram::198611****4430:role/aliyunosseventnotificationrole",   "qualifier":LATEST,   "triggerConfig": {     "events": [       "oss:ObjectCreated:*"     ],     "filter": {       "key": {         "prefix": "prefix_text",         "suffix": ".zip"       }     }   },   "createdTime": "2020-04-08T01:48:21Z",   "lastModifiedTime": "2020-04-08T01:48:21Z" }