> 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/sdn/internet/createinternet.md).

# CreateInternet

## 1. API Description

This API (CreateInternet) is used to creates an Internet.

{% hint style="info" %}
**Notes**

* Due to equipment reasons, some regions only support manual delivery, with a delivery cycle of 1-3 days. You can check the **deliveryType** field of [DescribeInternetDatacenters](https://docs.console.zenlayer.com/api-reference/sdn/internet/describeinternetdatacenters.md) to determine whether it is automated delivery.
* This is an asynchronous API. After the creation request is successfully submitted, an Internet `ID` will be returned. The creation is not immediately completed. During this period, the instance state will be **`DEPLOYING`**. You can call DescribeInternets to query the result. If the state (`internetStatus`) changes from **`DEPLOYING`** to **`AVAILABLE`**, the creation is successful. If the state changes to **`FAILED`**, the creation has failed. No operations are allowed on the private connect during the creation process.
* When `internetType=ByInstanceBandwidth95` (95th percentile billing), `commitBandwidth` is required. If `bandwidth` is also specified, it must be greater than or equal to `commitBandwidth`; otherwise the `INVALID_RIPT_BANDWIDTH_LESS_THAN_COMMIT` error is returned.
* When creating a high-availability Internet with `haConfig`, both `internetDcId` and `bfd` are required. A missing `internetDcId` returns the `MISSING_PARAMETER` error, and a missing or incomplete `bfd` returns the `INVALID_RIPT_HA_BFD_REQUIRED` error. BFD cannot be disabled after a high-availability Internet is created.
* When `routingType=BGP`, `bgp` is required and `bgp.asn` must be specified. You must also provide either `bgp.asnList` or `bgp.asSetList` (at least one of them). A missing `bgp` or `bgp.asn` returns the `MISSING_PARAMETER` error; if neither `asnList` nor `asSetList` is provided, the `INVALID_RIPT_BGP_ASN_LIST_MISSING` error is returned; if the ASN does not belong to you, the `INVALID_RIPT_BGP_ASN` error is returned.
* `bgp.tier` specifies the BGP tier: `PREMIUM` (Premium, the default) or `STANDARD` (Standard). The Standard tier is available only in some data centers (see `availableBgpTiers` in [DescribeInternetDatacenters](https://docs.console.zenlayer.com/api-reference/sdn/internet/describeinternetdatacenters.md)), supports only `internetType=ByBandwidth` (fixed bandwidth), and `bandwidth` must be one of the fixed tier levels of that data center (for example, 10000/50000/100000 Mbps; if a value outside the tier levels is passed, the `INVALID_RIPT_BANDWIDTH_NOT_IN_TIER_LEVELS` error message returns the full list of available tier levels). If these conditions are not met, the `INVALID_RIPT_BGP_TIER_NOT_SUPPORTED`, `INVALID_RIPT_INTERNET_TYPE_FOR_STANDARD_BGP`, or `INVALID_RIPT_BANDWIDTH_NOT_IN_TIER_LEVELS` error is returned respectively. `STANDARD` is not supported when `zbgRegionId` is specified (router-based Internet).
* The Zenlayer-side (peer) AS numbers differ between the two tiers: `29752` for Standard BGP and `21859` for Premium BGP. Configure the BGP neighbor on your local router based on the `peerAsns` returned by [DescribeInternetDatacenters](https://docs.console.zenlayer.com/api-reference/sdn/internet/describeinternetdatacenters.md).
  {% endhint %}

## 2. Input Parameters

The following request parameter list only provides API request parameters.

| Parameter Name            | Required | Type                                                                                                                 | Description                                                                                                                                                                                                                                                                                                                                                                                   |
| ------------------------- | -------- | -------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| peerPortId                | Yes      | String                                                                                                               | Connected port ID.                                                                                                                                                                                                                                                                                                                                                                            |
| peerPortVlan              | Yes      | Integer                                                                                                              | <p>VLAN ID.</p><p>Value range: 1000-4000.</p><p>Must be an unallocated VLAN. You can call DescribePortUsableVlan to query available VLANs.</p>                                                                                                                                                                                                                                                |
| routingType               | Yes      | [InternetRouteType](https://docs.console.zenlayer.com/api-reference/sdn/datastructure.md#internetroutetype)          | Routing type.                                                                                                                                                                                                                                                                                                                                                                                 |
| internetName              | No       | String                                                                                                               | Internet name.                                                                                                                                                                                                                                                                                                                                                                                |
| internetDescription       | No       | String                                                                                                               | Internet description.                                                                                                                                                                                                                                                                                                                                                                         |
| internetDcId              | No       | String                                                                                                               | <p>Local data center ID.</p><p>If not specified, it indicates a local connection (Local Internet).</p><p>Required when creating a high-availability Internet with <code>haConfig</code>.</p>                                                                                                                                                                                                  |
| internetType              | No       | [InternetType](https://docs.console.zenlayer.com/api-reference/sdn/datastructure.md#internettype)                    | <p>Bandwidth billing method.</p><p>Default value: ByBandwidth</p>                                                                                                                                                                                                                                                                                                                             |
| commitBandwidth           | No       | Integer                                                                                                              | <p>Committed bandwidth.</p><p>Unit: Mbps.</p><p>This field is required if and only if internetType is ByInstanceBandwidth95.</p><p>Value range: \[5, +)</p>                                                                                                                                                                                                                                   |
| bandwidth                 | No       | Integer                                                                                                              | <p>Bandwidth cap.</p><p>Unit: Mbps.</p><p>Minimum value: 5 Mbps.</p><p>Default value: 5 Mbps.</p><p>Value range: \[5, +)</p>                                                                                                                                                                                                                                                                  |
| publicIPv4BlockSize       | No       | Array of Integer                                                                                                     | <p>Public IPv4 address block.</p><p>Netmask range: 24-30.</p><p>This field is required if and only if routing type is Static or Gateway.</p><p>Currently, only one public CIDR is allowed.</p>                                                                                                                                                                                                |
| bfd                       | No       | [BFDConfig](https://docs.console.zenlayer.com/api-reference/sdn/datastructure.md#bfdconfig)                          | <p>BFD configuration.</p><p>Required when creating a high-availability Internet with <code>haConfig</code>, and cannot be disabled afterward.</p>                                                                                                                                                                                                                                             |
| resourceGroupId           | No       | String                                                                                                               | <p>Resource group ID.</p><p>If not specified, it will be placed in the default resource group.</p>                                                                                                                                                                                                                                                                                            |
| bgp                       | No       | [InternetBgpConfig](https://docs.console.zenlayer.com/api-reference/sdn/datastructure.md#internetbgpconfig)          | BGP configurations.                                                                                                                                                                                                                                                                                                                                                                           |
| tags                      | No       | [TagAssociation](https://docs.console.zenlayer.com/api-reference/sdn/datastructure.md#tagassociation)                | <p>Tags to associate when creating the Internet.</p><p>Note: Tag keys must be unique.</p>                                                                                                                                                                                                                                                                                                     |
| publicIpList              | No       | Array of [InternetIpRequest](https://docs.console.zenlayer.com/api-reference/sdn/datastructure.md#internetiprequest) | <p>List of public IP allocations.</p><p>Mutually exclusive with publicIPv4BlockSize and takes precedence.</p><p>If this field is specified, publicIPv4BlockSize is ignored.</p>                                                                                                                                                                                                               |
| zbgRegionId               | No       | String                                                                                                               | <p>ZBG access node ID.</p><p>If specified, the router-based Internet process is used. Mutually exclusive with <code>haConfig</code>.</p><p>Call <a href="https://docs.console.zenlayer.com/api-reference/zec/vpc-network/border-gateway/describeinterconnectbordergatewayregions.md">DescribeInterconnectBorderGatewayRegions</a> to obtain available nodes.</p>                              |
| haConfig                  | No       | [InternetHaConfig](https://docs.console.zenlayer.com/api-reference/sdn/datastructure.md#internethaconfig)            | <p>HA configuration.</p><p>If specified, the HA creation process is used. Mutually exclusive with <code>zbgRegionId</code>. In this case, both <code>internetDcId</code> and <code>bfd</code> are required.</p>                                                                                                                                                                               |
| publicInterconnectNetmask | No       | Integer                                                                                                              | <p>Public interconnect block netmask.</p><p>If specified, public address interconnection is enabled. Supported only for BGP and Static routing.</p><p>For valid values, see availableRoutingTypes\[].publicInterconnectNetmasks in the response of <a href="https://docs.console.zenlayer.com/api-reference/sdn/internet/describeinternetdatacenters.md">DescribeInternetDatacenters</a>.</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 generated during creation.                                                                               |
| internetId     | String | Internet ID。                                                                                                          |

## 4. Code Example

{% tabs %}
{% tab title="Example" %}
**1. Create an Internet with static routing, a /28 public CIDR, and BFD configured.**

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

Request:
{
  "internetName": "test_Internet",
  "internetDescription": "test_internet_desc",
  "peerPortId": "1170556726903057557",
  "peerPortVlan": 1042,
  "internetType": "ByBandwidth",
  "bandwidth": 50,
  "internetDcId": "AMS1",
  "routingType": "Static",
  "publicIPv4BlockSize": [
    28
  ],
  "bfd": {
    "bfdTxInterval": 100,
    "bfdRxInterval": 100,
    "bfdMultiplier": 10
  }
}


Response:
{
  "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3",
  "response": {
     "requestId": "T98044459-95B2-477E-9A2F-00253A70CC6E",
     "internetId": "your-internet-id",
     "orderNumber": "xxxx"
  }
}
```

**2. Create an Internet and use publicIpList to allocate a /28 IPv4 block and a /64 IPv6 block at the same time.**

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

Request:
{
  "internetName": "test_Internet_v4v6",
  "peerPortId": "1170556726903057557",
  "peerPortVlan": 1042,
  "internetType": "ByBandwidth",
  "bandwidth": 100,
  "internetDcId": "AMS1",
  "routingType": "BGP",
  "publicIpList": [
    { "netmask": 28, "ipType": "IPV4", "ipNetworkType": "BGP_IP", "amount": 2 },
    { "netmask": 64, "ipType": "IPV6", "ipNetworkType": "BGP_IP" }
  ]
}

Response:
{
  "requestId": "T12345678-ABCD-1234-EFGH-000000000010",
  "response": {
    "requestId": "T12345678-ABCD-1234-EFGH-000000000010",
    "internetId": "your-internet-id",
    "orderNumber": "xxxx"
  }
}
```

**3. Create an Internet with the Standard BGP tier (STANDARD) and a fixed bandwidth of 10 Gbps.**

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

Request:
{
  "internetName": "test_Internet_standard_bgp",
  "peerPortId": "1170556726903057557",
  "peerPortVlan": 1043,
  "internetType": "ByBandwidth",
  "bandwidth": 10000,
  "internetDcId": "SIN1",
  "routingType": "BGP",
  "publicIPv4BlockSize": [
    28
  ],
  "bgp": {
    "routeType": "ALL_ROUTES",
    "tier": "STANDARD",
    "asn": 64500,
    "asnList": [
      64500
    ]
  }
}

Response:
{
  "requestId": "T12345678-ABCD-1234-EFGH-000000000011",
  "response": {
    "requestId": "T12345678-ABCD-1234-EFGH-000000000011",
    "internetId": "your-internet-id",
    "orderNumber": "xxxx"
  }
}
```

{% endtab %}
{% endtabs %}

## 5. Developer Resources

Zenlayer Cloud API 2.0 integrates [SDKs](https://docs.console.zenlayer.com/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](https://docs.console.zenlayer.com/api-reference/api-introduction/instruction/commonerrorcode.md).

| HTTP Status Code | Error Code                                          | Description                                                                                                |
| ---------------- | --------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
| 404              | INVALID\_RIPT\_NOT\_SELLABLE                        | This data center does not support Internet.                                                                |
| 400              | INVALID\_RIPT\_IP\_INVALID\_RANGE                   | Invalid IP mask range.                                                                                     |
| 400              | INVALID\_RIPT\_ROUTING\_TYPE\_MISSING               | The routing type of the Internet is missing.                                                               |
| 400              | INVALID\_RIPT\_PUBLIC\_IP\_ALLOCATION\_MISSING      | At least one of `publicIPv4BlockSize` and `publicIpList` must be specified.                                |
| 400              | INVALID\_RIPT\_BANDWIDTH\_LESS\_THAN\_COMMIT        | `bandwidth` must be greater than or equal to `commitBandwidth` when internetType is ByInstanceBandwidth95. |
| 404              | INVALID\_RIPT\_BGP\_ASN                             | Invalid ASN number.                                                                                        |
| 400              | INVALID\_RIPT\_BGP\_ASN\_LIST\_MISSING              | At least one of `bgp.asnList` and `bgp.asSetList` must be specified.                                       |
| 400              | INVALID\_RIPT\_BGP\_TIER\_NOT\_SUPPORTED            | The specified data center does not support the selected BGP tier.                                          |
| 400              | INVALID\_RIPT\_INTERNET\_TYPE\_FOR\_STANDARD\_BGP   | Standard BGP supports fixed bandwidth billing only.                                                        |
| 400              | INVALID\_RIPT\_BANDWIDTH\_NOT\_IN\_TIER\_LEVELS     | The bandwidth is not one of the available Standard BGP tier levels.                                        |
| 400              | INVALID\_RIPT\_PUBLIC\_INTERCONNECT\_NOT\_SUPPORTED | Public interconnect addresses are only supported for Static or BGP routing mode.                           |
| 400              | INVALID\_RIPT\_PUBLIC\_INTERCONNECT\_NETMASK        | Invalid public interconnect netmask. Only 30 or 31 is supported.                                           |
| 400              | INVALID\_RIPT\_HA\_DELIVERY\_TYPE\_NOT\_AUTO        | HA only supports the automated delivery type.                                                              |
| 400              | INVALID\_RIPT\_HA\_PORT\_NOT\_SAME\_CITY            | The primary and secondary ports must be in the same city.                                                  |
| 400              | INVALID\_RIPT\_HA\_ROUTING\_TYPE                    | HA only supports static routing.                                                                           |
| 400              | INVALID\_RIPT\_HA\_DUPLICATE\_PORT                  | The primary and secondary ports cannot be the same physical port.                                          |
| 409              | INVALID\_RIPT\_HA\_PORT\_NOT\_UP                    | The HA port connectivity state is not UP.                                                                  |
| 400              | INVALID\_RIPT\_HA\_PORT\_CATEGORY\_MISMATCH         | The primary and secondary ports must have the same specifications.                                         |
| 400              | INVALID\_RIPT\_HA\_BFD\_REQUIRED                    | BFD configuration is required when creating a high-availability Internet.                                  |
| 403              | OPERATION\_DENIED\_ZBG\_RIPT\_SAME\_CITY            | The ZBG and the Internet cannot be in the same city.                                                       |
