# CreateCloudRouter

## 1. API Description

This API is used to create a Layer 3 cloud router.

#### Prerequisites

* **Query available VPCs**\
  You can call [`DescribeCloudRouterAvailableVpcs`](https://docs.console.zenlayer.com/api-reference/networking/sdn/router/describecloudrouteravailablevpcs) to query VPCs that can be added in to the Layer 3 cloud router.
* **Query available border gateways**\
  You can call [`DescribeBorderGateways`](https://docs.console.zenlayer.com/api-reference/compute/zec/vpc-network/border-gateway/describebordergateways) to query border gateways that can be added in to the Layer 3 cloud router.
* **Query available ports**\
  You can call [`DescribeCloudRouterAvailablePorts`](https://docs.console.zenlayer.com/api-reference/networking/sdn/router/describecloudrouteravailableports-1) to query ports that can be added in to the Layer 3 cloud router.
* **Query available locations for public clouds**
  * You can call [`DescribeGoogleRegions`](https://docs.console.zenlayer.com/api-reference/networking/sdn/cloud/describegoogleregions) to query locations supporting for Google Cloud access point.
  * You can call [`DescribeAWSRegions`](https://docs.console.zenlayer.com/api-reference/networking/sdn/cloud/describe-aws-regions) to query locations supporting for AWS access point.
  * You can call [`DescribeTencentRegions`](https://docs.console.zenlayer.com/api-reference/networking/sdn/cloud/describe-tencent-regions) to query locations supporting for Tencent Cloud access point.
* **Query available date centers for virtual edges**
  * You can call [`DescribeVirtualEdgeDatacenters`](https://docs.console.zenlayer.com/api-reference/networking/sdn/common/describevirtualedgedatacenters) to query date centers supporting virtual edges.
* Cloud Connect access bandwidth will be automatically adjusted to the nearest cap higher than the backbone bandwidth.\
  If you need to configure Cloud Connect access bandwidth separately, you can call [`DescribeCloudAvailableBandwidthTiers`](https://docs.console.zenlayer.com/api-reference/networking/sdn/cloud/describecloudavailablebandwidthtiers) to query available cloud connect access bandwidth specifications.

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

* <mark style="color:blue;">Only operations on pay-as-you-go cloud router are supported.</mark>
* <mark style="color:blue;">A cloud router can contains several VPCs, while a VPC can only be added into one cloud router.</mark>
* <mark style="color:blue;">This API is an async API. A cloud router ID is returned after the creation request is sent. However, it does not mean the creation has been completed. The status of the cloud router will be</mark> <mark style="color:blue;">`DEPLOYING`</mark> <mark style="color:blue;">during the creation. You can use</mark> [<mark style="color:purple;">`DescribeCloudRouters`</mark>](https://docs.console.zenlayer.com/api-reference/networking/sdn/router/describe-cloud-routers) <mark style="color:blue;">to query the status of the cloud router. If</mark> <mark style="color:blue;">`cloudRouterStatus`</mark> <mark style="color:blue;">changes from</mark> <mark style="color:blue;">`DEPLOYING`</mark> <mark style="color:blue;">to</mark> <mark style="color:blue;">`RUNNING`</mark><mark style="color:blue;">, it means that the cloud router has been created successfully; if no result has been queried, it means the cloud router has been created failed. Any operations on the cloud router are not allowed while creating.</mark>
  {% endhint %}

## 2. Input Parameters

The following request parameter list only provides API request parameters.

<table><thead><tr><th width="201.453125">Parameter Name</th><th width="108.7059326171875">Required</th><th width="111">Type</th><th>Description</th></tr></thead><tbody><tr><td>cloudRouterName</td><td>No</td><td>String</td><td>Cloud router name.<br>Up to 255 characters in length are allowed. The default is <code>cloud-router-{current time}</code>.</td></tr><tr><td>cloudRouterDescription</td><td>No</td><td>String</td><td>Cloud router description.<br>Up to 255 characters in length are allowed.</td></tr><tr><td>edgePoints</td><td>Yes</td><td>Array of <a href="../../datastructure#createcloudrouteredgepoint">CreateCloudRouterEdgePoint</a></td><td>Access point information in a cloud router.<br>At least two access points must be added to a cloud router.</td></tr><tr><td>resourceGroupId</td><td>No</td><td>String</td><td><p>Resource group ID.</p><p>If the value is null, the cloud router will be added into the default resource group.</p></td></tr><tr><td>marketingOptions</td><td>No</td><td><a href="../../datastructure#marketingoptions">MarketingOptions</a></td><td>Information on marketing campaigns.</td></tr><tr><td>tags</td><td>No</td><td><a href="../../datastructure#tagassociation">TagAssociation</a></td><td><p>Bound tags when creating the cloud router.</p><p>Tag keys must be unique.</p></td></tr></tbody></table>

## 3. Output Parameters

<table><thead><tr><th width="192">Parameter Name</th><th width="97.33333333333331">Type</th><th>Description</th></tr></thead><tbody><tr><td>requestId</td><td>String</td><td>The unique request ID, which is returned for each request. RequestId is required for locating a problem.</td></tr><tr><td>cloudRouterId</td><td>String</td><td>Cloud router ID.</td></tr></tbody></table>

## 4. Code Example

{% tabs %}
{% tab title="Example" %}
**Create a Layer 3 cloud router with a port and a VPC as access points. The access bandwidth is 10 Mbps.**

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

Request：
{
    "cloudRouterStatus":"RUNNING",
    "edgePoints":[
        {
            "ipAddress":"4.4.4.4/24",
            "vlanId": 1024,
            "portId":"your-portId",
            "bgpConnection":{
                "password":"",
                "peerIpAddress":"4.4.4.3",
                "localAsn":62610,
                "peerAsn":6543
            },
            "bandwidthMbps":1
        },
        {
            "vpcId":"your vpc id",
            "bandwidthMbps":1
        }
    ],
    "cloudRouterName":"Test",
    "cloudRouterDescription":"",
    "cloudRouterChargeType":"POSTPAID"
}

Response：
{   
  "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3",
  "response": {
     "requestId": "T98044459-95B2-477E-9A2F-00253A70CC6E"，
     "cloudRouterId": "cloud router id"
  }
}
```

{% endtab %}
{% endtabs %}

## 5. Developer Resources

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

## 6. Error Codes

No 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).​
