All Products
Search
Document Center

Server Load Balancer:CreateRules

Last Updated:May 12, 2026

Adds one or more forwarding rules to a specified HTTP or HTTPS listener.

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

slb:CreateRules

create

*loadbalancer

acs:slb:{#regionId}:{#accountId}:loadbalancer/{#loadbalancerId}

  • slb:tag

  • slb:tag

  • slb:tag

None

Request parameters

Parameter

Type

Required

Description

Example

RegionId

string

Yes

The region ID of the load balancer instance.

You can call the DescribeRegions operation to query region IDs.

cn-hangzhou

LoadBalancerId

string

Yes

The ID of the load balancer instance.

lb-bp1ca0zt07t934w******

ListenerPort

integer

Yes

The frontend listener port of the load balancer instance.

Valid values: 1–65535.

443

ListenerProtocol

string

No

The frontend protocol of the listener.

Note

This parameter is required if you configure listeners that use different protocols on the same port.

https

RuleList

string

Yes

The forwarding rules to add. You can add up to 10 forwarding rules in a single request. Each forwarding rule consists of the following parameters:

  • RuleName (Required): String. The name of the forwarding rule. The name must be 1 to 40 characters in length and can contain letters, digits, hyphens (-), forward slashes (/), periods (.), and underscores (_). Rule names must be unique within the same listener.

  • Domain (Optional): String. The domain name to associate with the forwarding rule. You must specify at least one of this parameter and the Url parameter.

  • Url (Optional): String. The URL path. The path must be 1 to 80 characters in length. It can contain Chinese characters, letters, digits, and the following special characters: - / . % ? # &. The URL path must start with a forward slash (/), but cannot be a single forward slash (/). You must specify at least one of this parameter and the Domain parameter.

  • VServerGroupId (Required): String. The ID of the target vServer group for the forwarding rule.

Note

You must specify the Domain parameter, the Url parameter, or both. The combination of a Domain and a Url must be unique within the same listener.

[{"RuleName":"Rule2","Domain":"test.com","VServerGroupId":"rsp-bp114ni******"}]

DryRun

boolean

No

Response elements

Element

Type

Description

Example

object

RequestId

string

The request ID.

9DEC9C28-AB05-4DDF-9A78-6B08EC9CE18C

Rules

object

Rule

array<object>

A list of forwarding rules.

object

A forwarding rule.

RuleName

string

The name of the forwarding rule.

Rule2

RuleId

string

The ID of the forwarding rule.

rule-bp12jzy0*****

Examples

Success response

JSON format

{
  "RequestId": "9DEC9C28-AB05-4DDF-9A78-6B08EC9CE18C",
  "Rules": {
    "Rule": [
      {
        "RuleName": "Rule2",
        "RuleId": "rule-bp12jzy0*****"
      }
    ]
  }
}

Error codes

HTTP status code

Error code

Error message

Description

400

InvalidParameter

The specified VServerGroupId does not belong to the LoadBalancerId of the rule.

400

InvalidParameterValue.RegionNotSupport

The region does not support the parameter value, %s.

400

TooManyListeners

More than 1 listener is found, please be more specified.

400

DomainExist

rule with same domain and url already exists in specified vip

The specified domain name and URL already exists in another listener rule.

400

OperationFailed.ListenerStatusNotSupport

The status of the listener does not support this operation. Please try again later.

400

OperationFailed.ActionNotSupport

The loadbalancer does not support such action.

400

MissingParameter.RuleName

The parameter RuleName is required.

400

DryRunOperation

Request validation has been passed with DryRun flag set.

Request validation has been passed with DryRun flag set.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.