> For the complete documentation index, see [llms.txt](https://docs.console.zenlayer.com/api-reference/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.console.zenlayer.com/api-reference/compute/bmc/load-balancing/createloadbalancer.md).

# CreateLoadBalancer

## 1. API Description

This API (CreateLoadBalancer) is used to create a load balancing instance.

#### Prerequisites

* Query the available zones for creating load balancers: call the [DescribeLoadBalancerZones](/api-reference/compute/bmc/load-balancing/describeloadbalancerzones.md).
* Query whether the load balancing IP can be created in a zone: call the [DescribeLoadBalancerIPv4](https://github.com/zenlayer/zenlayercloud-api-doc-en/blob/main/bmc/load-balancing/describeloadbalanceripv4.md) or [DescribeLoadBalancerIPv6](https://github.com/zenlayer/zenlayercloud-api-doc-en/blob/main/bmc/load-balancing/describeinstances.md).
* Query whether the load balancing specifications can be created in a zone: call the [DescribeLoadBalancerSpecs](/api-reference/compute/bmc/load-balancing/describeloadbalancerspecs.md).
* Cost estimation: to know of load balancer pricing, see [Pricing](https://docs.console.zenlayer.com/welcome/pricing/general-pricing-rules) for more details.

{% hint style="info" %} <mark style="color:blue;">**Note**</mark>

* <mark style="color:blue;">If you create a subscription instance, the amount required will be pre-deducted. If the balance is insufficient, the request will fail. If you create a pay-as-you-go instance, please ensure your account balance is sufficient before calling this API.</mark>
* <mark style="color:blue;">Vouchers can be used for fee deduction in instance creation. See</mark> [<mark style="color:purple;">Vouchers</mark>](https://docs.console.zenlayer.com/welcome/platform/billing-center/vouchers) <mark style="color:blue;">for more details.</mark>
  {% endhint %}

## 2. Input Parameters

The following request parameter list only provides API request parameters.

| Parameter Name        | Required | Type                                                                         | Description                                                                                                                                                                                                |
| --------------------- | -------- | ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| zoneId                | Yes      | String                                                                       | The zone ID.                                                                                                                                                                                               |
| loadBalancerName      | Yes      | String                                                                       | The name of the load balancer.                                                                                                                                                                             |
| chargeType            | Yes      | [ChargeType](/api-reference/compute/bmc/datastructure.md#chargetype)         | <p>Pricing model.</p><p>PREPAID : subscription;</p><p>POSTPAID : pay-as-you-go.</p>                                                                                                                        |
| bandwidth             | Yes      | Integer                                                                      | <p>Bandwidth value.</p><p>Value range: \[ 1,1024 ].</p><p>Unit: Mbps .</p><p>Value range: \[1, 10240]</p>                                                                                                  |
| ipType                | Yes      | String                                                                       | <p>Specify the type of IP added to the load balancer.</p><p>Available values:</p><p>IPv4 IPv6</p>                                                                                                          |
| clientToken           | No       | String                                                                       | Used to ensure the idempotency of the request.                                                                                                                                                             |
| instanceChargePrepaid | No       | [ChargePrepaid](/api-reference/compute/bmc/datastructure.md#chargeprepaid)   | <p>Subscription mode.</p><p>Details of the monthly or yearly subscription configurations, including the subscription period, auto-renewal, etc.</p><p>It is required if the pricing model is PREPAID .</p> |
| vipCount              | No       | Integer                                                                      | <p>Number of additional VIPs to be purchased.</p><p>The load balancer binds 1 IP of the specified type by default.</p>                                                                                     |
| subnetId              | No       | String                                                                       | <p>Subnet ID.</p><p>The subnet ID must be specified when creating a VIP4 type. The primary and secondary IPs of the instance will be obtained in the subnet.</p>                                           |
| cidrBlockId           | No       | String                                                                       | <p>CIDR block ID.</p><p>The CIDR block ID needs to be specified when creating a VIP6 type. If there is only one CIDR block in the zone, it can be unspecified and the CIDR will be used by default.</p>    |
| masterIp              | No       | String                                                                       | Primary IP.                                                                                                                                                                                                |
| backupIp              | No       | String                                                                       | Secondary IP.                                                                                                                                                                                              |
| marketingOptions      | No       | [MarketingInfo](/api-reference/compute/bmc/datastructure.md#marketinginfo)   | Information on marketing campaigns.                                                                                                                                                                        |
| tags                  | No       | [TagAssociation](/api-reference/compute/bmc/datastructure.md#tagassociation) | <p>Bound tags when creating resources.</p><p>Tag keys must be unique.</p>                                                                                                                                  |

## 3. Output Parameters

| Parameter Name | Type   | Description                                                                                                           |
| -------------- | ------ | --------------------------------------------------------------------------------------------------------------------- |
| requestId      | String | <p>The unique request ID, which is returned for each request.</p><p>RequestId is required for locating a problem.</p> |
| orderNumber    | String | Order number.                                                                                                         |
| loadBalancerId | String | Load balancer ID.                                                                                                     |

## 4. Code Example

{% tabs %}
{% tab title="Example" %}
**Create a load balancing instance.**

```json
POST /api/v2/bmc HTTP/1.1
Host: console.zenlayer.com
Content-Type: application/json
X-ZC-Action: CreateLoadBalancer
<Common Request Params>

Request:
{
  "zoneId": "HKG-A",
  "loadBalancerName": "xxxx",
  "specName": "xxxx",
  "clientToken": "xxxx",
  "chargeType": "xxxx",
  "bandwidth": 100,
  "subnetId": "xxxx",
  "ipType": "IPv4"
}

Response:
{
  "requestId": "TEEFDCA5B-76FB-4E91-A18E-DF7F5D2CE41F",
  "response": {
    "requestId": "TEEFDCA5B-76FB-4E91-A18E-DF7F5D2CE41F",
    "orderNumber": "xxxx",
    "loadBalancerId": "xxxx"
  }
}
```

{% endtab %}
{% endtabs %}

## 5. Developer Resources

Zenlayer Cloud API 2.0 integrates [SDKs](/api-reference/api-introduction/toolkit/api-sdk.md)，to make it easier for you to call APIs. More programming languages will be supported.

## 6. Error Codes

The following only lists the error codes related to the API business logic. For other error codes, see [Common Error Codes](/api-reference/api-introduction/instruction/commonerrorcode.md).

| HTTP Status Code | Error Code | Description |
| ---------------- | ---------- | ----------- |
