All Products
Search
Document Center

Server Load Balancer:CreateLoadBalancer

Last Updated:Apr 22, 2026

Creates a Network Load Balancer (NLB) instance in a specified region.

Operation description

  • When you create an NLB instance, the service-linked role AliyunServiceRoleForNlb is automatically created and assigned to you.

  • CreateLoadBalancer is an asynchronous operation. After you send a request, the system returns an instance ID and runs the task in the background. You can call GetLoadBalancerAttribute to query the status of an NLB instance.

    • If an NLB instance is in the Provisioning state, the NLB instance is being created.

    • If an NLB instance is in the Active state, the NLB instance is created.

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

nlb:CreateLoadBalancer

create

*LoadBalancer

acs:nlb:{#regionId}:{#accountId}:loadbalancer/*

*VSwitch

acs:vpc:{#regionId}:{#accountId}:vswitch/{#VSwitchId}

EipAddress

acs:vpc:{#regionId}:{#accountId}:eip/{#AllocationId}

*VPC

acs:vpc:{#regionId}:{#accountId}:vpc/{#VpcId}

  • nlb:AddressType
None

Request parameters

Parameter

Type

Required

Description

Example

LoadBalancerType

string

No

The type of the Server Load Balancer (SLB) instance. Set the value to network, which indicates an NLB instance.

network

LoadBalancerName

string

No

The name of the NLB instance.

It must be 2 to 128 characters in length, can contain letters, digits, periods (.), underscores (_), and hyphens (-), and must start with a letter.

NLB1

AddressType

string

Yes

The type of IPv4 addresses used for the NLB instance. Valid values are:

  • Internet: The nodes of an Internet-facing NLB instance have public IP addresses. The DNS name of an Internet-facing NLB instance is publicly resolvable to the public IP addresses of the nodes. Therefore, Internet-facing NLB instances can route requests from clients over the Internet.

  • Intranet: The nodes of an internal-facing NLB instance have only private IP addresses. The DNS name of an internal-facing NLB instance is publicly resolvable to the private IP addresses of the nodes. Therefore, internal-facing NLB instances can route requests only from clients with access to the virtual private cloud (VPC) for the NLB instance.

Note

To enable a public IPv6 address for a dual-stack NLB instance, call the EnableLoadBalancerIpv6Internet operation.

Internet

AddressIpVersion

string

No

The version of IP addresses used for the NLB instance. Valid values:

  • ipv4 (default)

  • DualStack

ipv4

VpcId

string

Yes

The ID of the VPC where you want to create the NLB instance.

vpc-bp1b49rqrybk45nio****

ZoneMappings

array<object>

Yes

The mappings between zones and vSwitches. An NLB instance can be deployed in up to 10 zones. If the region supports two or more zones, you must specify at least two zones.

object

No

The mapping between the zone and the vSwitch. An NLB instance can be deployed in up to 10 zones. If the region supports two or more zones, you must specify at least two zones.

VSwitchId

string

Yes

The ID of the vSwitch in the zone. You can specify only one vSwitch (subnet) in each zone of an NLB instance. An NLB instance can be deployed in up to 10 zones. If the region supports two or more zones, you must specify at least two zones.

vsw-sersdf****

ZoneId

string

Yes

The ID of the zone where the NLB instance is deployed. An NLB instance can be deployed in up to 10 zones. If the region supports two or more zones, specify at least two zones.

You can call the DescribeZones operation to query the most recent zone list.

cn-hangzhou-a

PrivateIPv4Address

string

No

The private virtual IP address (VIP) of the IPv4 version. The private IPv4 address that the NLB instance uses to provide external services.

192.168.10.1

AllocationId

string

No

The ID of the elastic IP address (EIP) that is associated with the Internet-facing NLB instance. Each zone is assigned one EIP. An NLB instance can be deployed in up to 10 zones. If the region supports two or more zones, specify at least two zones.

eip-bp1aedxso6u80u0qf****

Ipv6Address

string

No

The VIP of the IPv6 version. The IPv6 address that the NLB instance uses to provide external services.

2408:400a:d5:3080:b409:840a:ca:e8e5

Ipv4LocalAddresses

array

No

The local IPv4 addresses. The IP addresses that the NLB instance uses to communicate with the backend servers. The number of IP addresses must be an even number, which must be at least 2 and at most 8.

string

No

The local IPv4 address.

192.168.10.2

Ipv6LocalAddresses

array

No

The local IPv6 addresses. The IP addresses that the NLB instance uses to communicate with the backend servers. The number of IP addresses must be an even number, which must be at least 2 and at most 8.

string

No

The local IPv6 address.

2408:400a:d5:3080:b409:840a:ca:e8e6

BandwidthPackageId

string

No

The ID of the Internet Shared Bandwidth instance that is associated with the Internet-facing NLB instance.

cbwp-bp1vevu8h3ieh****

LoadBalancerBillingConfig

object

No

The billing settings of the NLB instance.

PayType

string

No

The billing method of the NLB instance.

Set the value to PostPay, which specifies the pay-as-you-go billing method.

PostPay

ResourceGroupId

string

No

The ID of the resource group to which the instance belongs.

rg-atstuj3rtop****

DryRun

boolean

No

Perform a dry run without actually making the request. Valid values are:

  • true: Perform only a dry run. The system checks the request for potential issues, including missing parameter values, incorrect request syntax, and service limits. If the request fails the check, an error message specifying the issue is returned. If the request passes, the DryRunOperation error code is returned.

  • false (default): Check the request and perform the operation. If the request passes the check, a 2xx HTTP status code is returned, and the operation is performed.

false

ClientToken

string

No

The client token used to ensure the idempotence of the request.

You can use the client to generate the token. Ensure that the token is unique among different requests. Only ASCII characters are allowed.

Note

If you do not specify this parameter, the value of RequestId is used.**** The value of RequestId is different for each request.

123e4567-e89b-12d3-a456-426655440000

RegionId

string

No

The ID of the region where the NLB instance is deployed.

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

cn-hangzhou

DeletionProtectionConfig

object

No

The configuration of the deletion protection feature.

Enabled

boolean

No

Specifies whether to enable the deletion protection feature. Valid values:

  • true

  • false (default)

false

Reason

string

No

The reason why the deletion protection feature is enabled or disabled. The reason must be 2 to 128 characters in length, can contain letters, digits, periods (.), underscores (_), and hyphens (-), and must start with a letter.

Instance is running

ModificationProtectionConfig

object

No

The configuration of the configuration read-only mode.

Status

string

No

Specifies whether to enable the configuration read-only mode. Valid values:

  • NonProtection: does not enable the configuration read-only mode. You cannot set the Reason parameter. If the Reason parameter is set, the value is cleared.

  • ConsoleProtection: enables the configuration read-only mode. You can set the Reason parameter.

Note

If the parameter is set to ConsoleProtection, the configuration read-only mode is enabled. You cannot modify the configurations of the NLB instance in the NLB console. However, you can call API operations to modify the configurations of the NLB instance.

ConsoleProtection

Reason

string

No

The reason for enabling the configuration read-only mode. The reason must be 2 to 128 characters in length, can contain letters, digits, periods (.), underscores (_), and hyphens (-), and must start with a letter.

Note

This parameter takes effect only when Status is set to ConsoleProtection.

Business protection period

Tag

array<object>

No

The tags.

object

No

The tag.

Key

string

No

The key of the tag. The tag key can be up to 64 characters in length, cannot start with aliyun or acs:, and cannot contain http:// or https://. The tag key can contain letters, digits, and the following special characters: _ . : / = + - @

You can specify up to 20 tags in each call.

env

Value

string

No

The value of the tag. The tag value can be up to 128 characters in length, cannot start with acs: or aliyun, and cannot contain http:// or https://. The tag value can contain letters, digits, and the following special characters: _ . : / = + - @

You can specify up to 20 tags in each call.

product

Response elements

Element

Type

Description

Example

object

response

RequestId

string

The ID of the request.

CEF72CEB-54B6-4AE8-B225-F876FF7BA984

LoadbalancerId

string

The ID of the NLB instance.

nlb-83ckzc8d4xlp8o****

OrderId

integer

The ID of the order for the NLB instance.

20230000

Examples

Success response

JSON format

{
  "RequestId": "CEF72CEB-54B6-4AE8-B225-F876FF7BA984",
  "LoadbalancerId": "nlb-83ckzc8d4xlp8o****",
  "OrderId": 20230000
}

Error codes

HTTP status code

Error code

Error message

Description

400 OperationDenied.OnlyPayByTrafficSupported The operation is not allowed because of OnlyPayByTrafficSupported.
400 OperationFailed.%s The operation failed because of %s. Failed to call the API operation due to %.
400 Mismatch.ZoneIdAndVswitchId The ZoneIdAndVswitchId is mismatched for %s and %s.
400 QuotaExceeded.%s The quota of %s is exceeded, usage %s/%s.
400 DryRunOperation Request validation has been passed with DryRun flag set. Request validation has been passed with DryRun flag set.
400 OperationDenied.OnlyPostPaidSupported The operation is not allowed because of OnlyPostPaidSupported.
400 OperationFailed.DuplicateZones. The operation failed because of Can not Specify duplicate zones.
400 ResourceNotEnough.VSwitchIp The specified resource of VSwitchIp is not enough. The specified virtual switch (vSwitch) IP resources are insufficient.
400 DuplicatedParam.AllocationId The param of AllocationId is duplicated.
400 ResourceInConfiguring.VswitchId The specified resource of VswitchId is being configured, please try again later. The specified resource of VswitchId is being configured, please try again later.
400 IllegalParam The param of %s is illegal.
400 OperationFailed.UnpaidBill The operation failed because of UnpaidBill.
400 OperationDenied.ServiceLinkedRoleNotExist The operation is not allowed because of ServiceLinkedRoleNotExist. The operation is not allowed because of ServiceLinkedRoleNotExist.Please check if the necessary permissions are granted in RAM for the NLB.
400 ResourceAlreadyAssociated.AllocationId The specified resource of %s is already associated.
400 OperationFailed.vSwitchNotSupportIpv6 The operation failed because of vSwitchNotSupportIpv6.
400 InvalidZones The current zone list is illegal. The Availability Zone used in Zone maping is illegal.
400 QuotaExceeded.QuotaInsufficient The quota of %s is exceeded, usage %s/%s. The quota is insufficient, currently used %s/%s. Please modify the quota size in the quota center.
400 ResourceInUse.IP The specified resource of IP is in use.
400 OperationFailed.CreateOrderError Operation failed because CreateOrderError. The operation failed because the order creation failed.
400 OperationFailed.NotExist.ResourceGroup Operation failed because ResourceGroup not exist. The specified resource group does not exist.
400 IllegalParam.loadBalancerName Param loadBalancerName is illegal. The instance name is invalid. Check the parameters.
400 SystemBusy System is busy, please try again later.
400 MissingParam.%s The parameter of %s is missing.
400 IllegalParam.DeletionProtectionConfig DeletionProtectionConfig reason is illegal. The reason parameter for changing the delete protection status is invalid.
400 IllegalParam.ModificationProtectionConfig ModificationProtectionConfig reason is illegal. ModificationProtectionConfig reason is illegal.
400 Throttling.User Request was denied due to api flow control. Request was denied due to api flow control.
403 UnauthorizedZone The specified zone of %s is not authorized.
403 Forbidden.NoPermission Authentication is failed for NoPermission. Authentication is failed for NoPermission.
403 UnauthorizedRegion The specified region of %s is not authorized.
404 ResourceNotFound.VSwitch The specified resource of vSwitch is not found. The specified vSwitch resource was not found. Please check the input parameters.
404 ResourceNotFound.Vpc The specified resource of Vpc is not found. The specified VPC resource was not found. Please check the input parameters.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.