All Products
Search
Document Center

Server Load Balancer:CreateRules

Last Updated:Mar 02, 2026

Creates forwarding rules for an 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 ID of the region where the Server Load Balancer (SLB) instance is deployed.

You can call the DescribeRegions operation to query the most recent region list.

cn-hangzhou

LoadBalancerId

string

Yes

The ID of the SLB instance.

lb-bp1ca0zt07t934w******

ListenerPort

integer

Yes

The frontend listener port that is used by the SLB instance.

Valid values: 1 to 65535.

443

ListenerProtocol

string

No

The frontend protocol that is used by the SLB instance.

Note

This parameter is required if the same port is used by listeners that use different protocols.

https

RuleList

string

Yes

The forwarding rules that you want to create. You can create at most 10 forwarding rules in each call. Each forwarding rule contains the following parameters:

  • RuleName: Required. The value must be of the STRING type. 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 (_). Forwarding rule names must be unique within the same listener.

  • Domain: Optional. The value must be a string. The domain name that is associated with the forwarding rule. You must specify this parameter or the URL parameter.

  • Url: Optional. The value must be 1 to 80 characters in length, and can contain letters, digits, hyphens (-), forward slashes (/), periods (.), percent signs (%), question marks (?), number signs (#), and ampersands (&). The value must be a string. The URL cannot be only a forward slash (/). However, it must start with a forward slash (/). You must specify this parameter or the Domain parameter.

  • VServerGroupId: Required. The value must be a string. The ID of the vServer group to be specified in the forwarding rule.

Note

You must specify at least one between the Domain and URL parameters. You can also specify both. The combination of Domain and Url must be unique within the same listener.

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

Response elements

Element

Type

Description

Example

object

RequestId

string

The request ID.

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

Rules

object

Rule

array<object>

The forwarding rules.

object

RuleName

string

The name of the forwarding rule.

Rule2

RuleId

string

The forwarding rule ID.

rule-bp12jzy0*****

Examples

Success response

JSON format

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

Error response

JSON format

{"Code":"InvalidParameter","Message":"The specified parameter is not valid.","HostId":"slb-pop.aliyuncs.com","RequestId":"0669D684-69D8-408E-A4FA-B9011E0F4E66"}

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.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.