All Products
Search
Document Center

:CreateTrigger

Last Updated:Sep 09, 2026

Creates a trigger.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

fc:CreateTrigger

create

*All Resource

*

None None

Request syntax

POST /2021-04-06/services/{serviceName}/functions/{functionName}/triggers HTTP/1.1

Path Parameters

Parameter

Type

Required

Description

Example

serviceName

string

Yes

The name of the service.

demoService

functionName

string

Yes

The name of the function.

demoFunction

Request parameters

Parameter

Type

Required

Description

Example

body

object

No

The definition of the trigger.

invocationRole

string

No

The role that the event source (such as OSS) uses to invoke the function. For more information, see Trigger overview.

acs:ram::1234567890:role/fc-test

qualifier

string

No

The version or alias of the service.

LATEST

sourceArn

string

No

The Alibaba Cloud Resource Name (ARN) of the trigger event source. This parameter can be ignored for timer, HTTP, and EventBridge triggers. This parameter is required for other trigger types. For EventBridge triggers, if you specify this field, an existing EventBridge resource is associated with the trigger. Do not configure the same sourceArn for two different EventBridge triggers. Otherwise, the update or delete operations of the triggers affect each other.

acs:oss:cn-shanghai:12345:mybucket

triggerConfig

string

Yes

The trigger configuration, which varies based on the trigger type. For the specific format, refer to the following data structures:

{"events": ["oss:ObjectCreated:*"], "filter": {"key": {"prefix": "/prefix", "suffix": ".zip"}}}

triggerName

string

Yes

The name of the trigger. The name can contain only letters, digits, underscores (_), and hyphens (-). The name cannot start with a digit or hyphen (-). The name must be 1 to 128 characters in length.

oss_create_object_demo

triggerType

string

Yes

The type of the trigger. Valid values:

Valid values:

  • cdn_events :

    cdn_events

  • timer :

    timer

  • log :

    log

  • mns_topic :

    mns_topic

  • eventbridge :

    eventbridge

  • http :

    http

  • oss :

    oss

  • tablestore :

    tablestore

oss

description

string

No

The description of the trigger.

trigger for test

X-Fc-Account-Id

string

No

The ID of your Alibaba Cloud account.

188077086902****

X-Fc-Date

string

No

The time when the client sends the request. The format is EEE,d MMM yyyy HH:mm:ss GMT.

Wed, 11 May 2022 09:00:00 GMT

X-Fc-Trace-Id

string

No

The custom request ID.

my-test-trace-id

Response elements

Element

Type

Description

Example

object

The trigger definition.

createdTime

string

The time when the trigger was created.

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

invocationRole

string

The ARN of the RAM role that the event source uses to invoke the function.

acs:ram::1234567890:role/fc-test

lastModifiedTime

string

The time when the trigger was last modified.

016-08-15T17:00:00.000+0000

qualifier

string

The version of the service.

LATEST

sourceArn

string

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

acs:oss:cn-shanghai:12345:mybucket

triggerConfig

string

The trigger configuration, which varies based on the trigger type.

{"events": ["oss:ObjectCreated:*"], "filter": {"key": {"prefix": "/prefix", "suffix": ".zip"}}}

triggerName

string

The name of the trigger. The name can contain only letters, digits, underscores (_), and hyphens (-). The name cannot start with a digit or hyphen (-). The name must be 1 to 128 characters in length.

oss_create_object_trigger_demo

triggerType

string

The type of the trigger, such as oss, log, tablestore, timer, http, cdn_events, mns_topic, or eventbridge.

oss

description

string

The description of the trigger.

trigger for test

triggerId

string

The unique ID of the trigger.

3e270f2f-cef2-421a-bc86-ff4e8088****

domainName

string

The domain name. You can concatenate the domain name with the Function Compute endpoint to invoke the function of the corresponding version by using the HTTP protocol. Example: {domainName}.cn-shanghai.fc.aliyuncs.com.

demo-service-demo-function-jkhksh

urlInternet

string

The public domain name. You can access the HTTP trigger over the Internet by using the HTTP or HTTPS protocol.

https://svc-func-xxxxxxxx.cn-hangzhou.fcapp.run

urlIntranet

string

The private endpoint. You can access the HTTP trigger within a VPC by using the HTTP or HTTPS protocol.

https://svc-func-xxxxxxxx.cn-hangzhou-vpc.fcapp.run

Examples

Success response

JSON format

{
  "createdTime": "2016-08-15T15:00:00.000+0000",
  "invocationRole": "acs:ram::1234567890:role/fc-test",
  "lastModifiedTime": "016-08-15T17:00:00.000+0000",
  "qualifier": "LATEST",
  "sourceArn": "acs:oss:cn-shanghai:12345:mybucket",
  "triggerConfig": "{\"events\": [\"oss:ObjectCreated:*\"], \"filter\": {\"key\": {\"prefix\": \"/prefix\", \"suffix\": \".zip\"}}}",
  "triggerName": "oss_create_object_trigger_demo",
  "triggerType": "oss",
  "description": "trigger for test",
  "triggerId": "3e270f2f-cef2-421a-bc86-ff4e8088****",
  "domainName": "demo-service-demo-function-jkhksh",
  "urlInternet": "https://svc-func-xxxxxxxx.cn-hangzhou.fcapp.run",
  "urlIntranet": "https://svc-func-xxxxxxxx.cn-hangzhou-vpc.fcapp.run"
}

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.