All Products
Search
Document Center

EventBridge:CreateRule

Last Updated:Sep 15, 2025

Creates an event rule.

Operation description

You can call this API operation to create an event rule.

Debugging

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • For mandatory resource types, indicate with a prefix of * .
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
eventbridge:CreateRulecreate
*Rule
acs:eventbridge:{#regionId}:{#accountId}:eventbus/{#EventBusName}/rule/{#RuleName}
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
EventBusNamestringYes

The name of the event bus.

MyEventBus
DescriptionstringNo

The description of the event bus.

RuleNamestringYes

The name of the event rule.

MNSRule
StatusstringNo

The status of the event rule. Valid values: ENABLE: enables the event rule. It is the default status of the event rule. DISABLE: disables the event rule.

ENABLE
FilterPatternstringYes

The event pattern, in JSON format. Valid values: stringEqual and stringExpression. You can specify up to five expressions in the map data structure in each field.

You can specify up to five expressions in the map data structure in each field.

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

The event targets.

objectYes

The event target.

IdstringYes

The ID of the event target.

12021
TypestringYes

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

acs.mns.queue
EndpointstringNo

The endpoint of the event target.

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

The retry policy that you want to use to push failed events. Valid values: BACKOFF_RETRY and EXPONENTIAL_DECAY_RETRY. BACKOFF_RETRY: A failed event can be retried up to three times. The interval between two consecutive retries is a random value from 10 seconds to 20 seconds. EXPONENTIAL_DECAY_RETRY: A failed event can be retried up to 176 times. The interval between two consecutive retries exponentially increases to a maximum of 512 seconds. The total retry time is 1 day. The specific retry intervals are 1, 2, 4, 8, 16, 32, 64, 128, 256, and 512 seconds. The interval of 512 seconds is used for 167 retries.

BACKOFF_RETRY
DeadLetterQueueobjectNo

The dead-letter queue. Events that are not processed or whose maximum number of retries is exceeded are written to the dead-letter queue. You can use queues in ApsaraMQ for RocketMQ, Simple Message Queue (SMQ, formerly MNS), and ApsaraMQ for Kafka as dead-letter queues. You can also use event buses in EventBridge as dead-letter queues.

ArnstringNo

The Alibaba Cloud Resource Name (ARN) of the dead-letter queue. Events that are not processed or whose maximum number of retries is exceeded are written to the dead-letter queue. Queues in SMQ and ApsaraMQ for RocketMQ can be used as dead-letter queues.

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

The fault tolerance policy. Valid values: ALL and NONE. The value ALL specifies that fault tolerance is allowed. If an error occurs in an event, event processing is not blocked. If the event fails to be sent after the maximum number of retries specified by the retry policy is reached, the event is delivered to the dead-letter queue or discarded based on your configurations. The value NONE specifies that fault tolerance is not allowed. If an error occurs in an event and the event fails to be sent after the maximum number of retries specified by the retry policy is reached, event processing is blocked.

ALL
ParamListarray<object>No

The parameters that are configured for the event target.

objectNo

The parameters that are configured for the event target.

ResourceKeystringNo

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

body
FormstringNo

The format of input parameters for the event target. For more information, see Limits .

TEMPLATE
ValuestringNo

The value of the event target parameter.

{\"key\"=\"value\"}
TemplatestringNo

The structure of the template for the event target.

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

The concurrency configuration.

ConcurrencylongNo

The concurrency.

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"}]}", "Targets":[ { "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 parameters

ParameterTypeDescriptionExample
object
Messagestring

The returned error message.

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

The request ID.

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

The returned data.

RuleARNstring

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

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

The returned HTTP status code. The HTTP status code 200 indicates that the request is successful.

200
Successboolean

Indicates whether the request is successful. Valid values: true and false.

true

Examples

Sample success responses

JSONformat

{
  "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": 200,
  "Success": true
}

Error codes

HTTP status codeError codeError message
403ServiceNotEnableService not enable

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2024-09-25The Error code has changedView Change Details