All Products
Search
Document Center

Server Load Balancer:CreateRules

Last Updated:Sep 08, 2026

Adds 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 SLB instance.

You can call the DescribeRegions operation to query region IDs.

cn-hangzhou

LoadBalancerId

string

Yes

The ID of the SLB instance.

lb-bp1ca0zt07t934w******

ListenerPort

integer

Yes

The frontend listener port of the SLB instance.

Valid values: 1 to 65535.

443

ListenerProtocol

string

No

The frontend protocol of the SLB instance.

Note

This parameter is required when listeners that use different protocols are configured 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 contains 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 (_). The names of forwarding rules must be unique within a listener.

  • Domain (optional): String. The request domain name associated with the forwarding rule. You must specify at least one of Domain and Url.

  • Url (optional): String. The access path. The path must be 1 to 80 characters in length and can contain Chinese characters, letters, digits, hyphens (-), forward slashes (/), periods (.), percent signs (%), question marks (?), number signs (#), and ampersands (&). The URL cannot be only a forward slash (/), but must start with a forward slash (/). You must specify at least one of Url and Domain.

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

Note

You must specify at least one of Domain and Url. You can also specify both. The combination of Domain and Url must be unique within a 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>

The list of forwarding rules.

object

The list of forwarding rules.

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. The Vgw ip is empty. Specify the Vgw ip parameter.
400 InvalidParameterValue.RegionNotSupport The region does not support the parameter value, %s. The specified parameter value is not supported in the current region.
400 TooManyListeners More than 1 listener is found, please be more specified. More than one listener was found. Provide more specific query conditions.
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. The operation failed because the current listener is being modified. Try again later.
400 OperationFailed.ActionNotSupport The loadbalancer does not support such action. The operation failed because IPv6 SLB instances do not support this operation.
400 MissingParameter.RuleName The parameter RuleName is required. The RuleName parameter is missing.
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.