All Products
Search
Document Center

EventBridge:CreateRule

Last Updated:Oct 28, 2026

Creates an event rule.

Operation description

Creates an event rule.

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

eventbridge:CreateRule

create

*Rule

acs:eventbridge:{#regionId}:{#accountId}:eventbus/{#EventBusName}/rule/{#RuleName}

None None

Request parameters

Parameter

Type

Required

Description

Example

EventBusName

string

Yes

The name of the event bus.

MyEventBus

Description

string

No

The description of the event bus.

Filter rule for Simple Message Queue (formerly MNS) (SMQ)

RuleName

string

Yes

The name of the event rule.

SMQRule

Status

string

No

The status of the rule. Valid values:

  • ENABLE: The rule is enabled. This is the default status.

  • DISABLE: The rule is disabled.

ENABLE

FilterPattern

string

Yes

The event pattern in JSON format. The following patterns are supported:

  • stringEqual pattern

  • stringExpression pattern Each field supports up to five expressions in a map structure.

{ "source": [ { "prefix": "acs." } ], "type": [ { "prefix": "oss:ObjectReplication" } ], "subject": [ { "prefix": "acs:oss:cn-hangzhou:123456789098****:my-movie-bucket/", "suffix": ".txt" } ] }

EventTargets

array<object>

No

The list of event targets.

array<object>

No

The event target.

Id

string

Yes

The custom ID of the event target.

Mlm123456JHd2RsRoKw

Type

string

Yes

The type of the event target. For more information, see Event target parameters.

acs.mns.queue

Endpoint

string

No

The endpoint URL for delivery.

acs:mns:cn-hangzhou:123456789098****:queues/myqueue

PushRetryStrategy

string

No

The retry policy for pushing events. Valid values:

  • BACKOFF_RETRY: backoff retry policy. The system retries 3 times, with a random interval of 10 to 20 seconds between each retry.

  • EXPONENTIAL_DECAY_RETRY: exponential decay retry. The system retries 176 times, with the interval exponentially incrementing to 512 seconds. The total retry time is 1 day. The specific intervals are 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, and then 512 seconds for the remaining 167 retries.

BACKOFF_RETRY

DeadLetterQueue

object

No

The dead-letter queue. Unprocessed events or events that exceed the retry count are written to the dead-letter queue. Supported queue types include ApsaraMQ for RocketMQ, Simple Message Queue (formerly MNS), ApsaraMQ for Kafka, and EventBridge event buses.

Arn

string

No

The ARN of the dead-letter queue. Unprocessed events or events that exceed the retry count are written to the dead-letter queue. Simple Message Queue (formerly MNS) and ApsaraMQ for RocketMQ are supported.

acs:mns:cn-hangzhou:123456789098****:/queues/deadletterqueue

Network

string

No

The network type.

PrivateNetwork

VpcId

string

No

The ID of the VPC where the dead-letter queue resides.

vpc-2z****

VSwitchIds

string

No

The vSwitch ID.

vsw-m12345****

SecurityGroupId

string

No

The security group ID.

sg-2d****

ErrorsTolerance

string

No

The fault tolerance strategy. Valid values:

  • ALL: allows fault tolerance. Exceptions do not block execution. If the retry strategy is exhausted, messages are delivered to the dead-letter queue or discarded based on the configuration.

  • NONE: disables fault tolerance. Exceptions block execution when the retry strategy is exhausted.

ALL

ParamList

array<object>

No

The parameters of the event target.

object

No

The parameters of the event target.

ResourceKey

string

No

The resource parameter of the event target. For more information, see Limits.

body

Form

string

No

The format of the event target parameter. For more information, see Limits.

TEMPLATE

Value

string

No

The value of the event target parameter.

{"key"="value"}

Template

string

No

The parameter template style of the event target.

The value of ${key} is ${value}!

ConcurrentConfig

object

No

The concurrency control configuration.

Concurrency

integer

No

The number of concurrent executions.

2

Sample requests.

POST /openapi/createRule HTTP/1.1 Host: 123456789098****.eventbridge.cn-hangzhou.aliyuncs.com Date: Sat, 18 Apr 2020 05:30:41 GMT x-eventbridge-version: 2020-04-01 Authorization: acs vZ3VL0SuJdHi****:Jo2PbT******azYAYoYslKLvWzg= Content-Type: application/json;charset=UTF-8 Content-Length: 26

{ "EventBusName":"default", "RuleName":"MNSRule", "Description":"Filtering rule for MNS", "Status":"ENABLE", "filterPattern":"{"source": [{"prefix": "acs."}],"type": [{"prefix":"oss:ObjectReplication"}],"subject":[{"prefix":"acs:oss:cn-hangzhou:123456789098****:my-movie-bucket/", "suffix":".txt"}]}", "EventTargets":[ { "Id":"1", "Type":"acs.mns.queue", "Endpoint":"acs:mns:cn-hangzhou:123456789098****:queues/myqueue", "PushRetryStrategy":"BACKOFF_RETRY", "DeadLetterQueue":{ "Arn":"acs:mns:cn-hangzhou:123456789098****:/queues/rule-deadletterqueue" }, "ParamList":[ { "resourceKey":"queue", "form":"CONSTANT", "value":"myqueue" }, { "resourceKey":"body", "form":"TEMPLATE", "value":"{"key"="value"}", "template":"The value of ${key} is ${value}!" } ] } ] }

Response elements

Element

Type

Description

Example

object

Message

string

The error message.

Remote error. requestId: [xxxx], error code: [xxx], message: [The target in event rule is invalid! Endpoint is xxx

RequestId

string

The request ID.

1AD6D598-7506-5D2C-81EA-30E3241A903A

Data

object

The returned data.

RuleARN

string

The ARN of the event rule, which is used for authorization.

acs:eventbridge:cn-hangzhou:123456789098****:eventbus/default/rule/MNSRule

Code

string

The response code. A value of Success indicates that the request is successful. Other values indicate error codes. For more information, see Error codes.

Success

Success

boolean

Indicates whether the operation is successful.

true

Examples

Success response

JSON format

{
  "Message": "Remote error. requestId: [xxxx], error code: [xxx], message: [The target in event rule is invalid! Endpoint is xxx",
  "RequestId": "1AD6D598-7506-5D2C-81EA-30E3241A903A",
  "Data": {
    "RuleARN": "acs:eventbridge:cn-hangzhou:123456789098****:eventbus/default/rule/MNSRule"
  },
  "Code": "Success",
  "Success": true
}

Error codes

HTTP status code

Error code

Error message

Description

403 ServiceNotEnable Service not enable

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.