# CreatePrivateConnect

## 1. API Description

This API is used to create a Layer 2 private connect.

#### Prerequisites

* **Query available ports**\
  You can call [`DescribePrivateConnectAvailablePorts`](https://docs.console.zenlayer.com/api-reference/networking/sdn/private-connect/describeprivateconnectavailableports-1) to query ports that can be added in to the Layer 2 private connect.
* **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.
* 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 private connects billed by flat rate are supported.</mark>
* <mark style="color:blue;">Please view</mark> [<mark style="color:purple;">Connections Validation on Public Cloud</mark>](https://docs.console.zenlayer.com/welcome/cloud-networking/get-started/validate-connection-in-public-cloud) <mark style="color:blue;">for more details.</mark>
* <mark style="color:blue;">This API is an async API. A private connect ID is returned after the creation request is sent. However, it does not mean the creation has been completed. The status of the private connect will be</mark> <mark style="color:blue;">`DEPLOYING`</mark> <mark style="color:blue;">during the creation. You can use</mark> [<mark style="color:purple;">`DescribePrivateConnects`</mark>](https://docs.console.zenlayer.com/api-reference/networking/sdn/private-connect/describeprivateconnects) <mark style="color:blue;">to query the status of the private connect. If the status changes from</mark> <mark style="color:blue;">`DEPLOYING`</mark> <mark style="color:blue;">to</mark> <mark style="color:blue;">`AVAILABLE`</mark><mark style="color:blue;">, it means that the private connect has been created successfully; if no result has been queried, it means the private connect has been created failed. Any operations on the private connect 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="186.34832695571282">Parameter Name</th><th width="111.8203125">Required</th><th width="113.65838623046875">Type</th><th>Description</th></tr></thead><tbody><tr><td>privateConnectName</td><td>No</td><td>String</td><td>Private connect name.<br>Up to 255 characters in length are allowed. The default is <code>private-connect-{current time}</code>.</td></tr><tr><td>endpointA</td><td>Yes</td><td><a href="../../datastructure#createendpointparam">CreateEndpointParam</a></td><td>One access point (A) of the private connect.</td></tr><tr><td>endpointZ</td><td>No</td><td><a href="../../datastructure#createendpointparam">CreateEndpointParam</a></td><td>The other access point (Z) of the private connect.</td></tr><tr><td>bandwidthMbps</td><td>No</td><td>Integer</td><td><p>Maximum bandwidth cap of the private connect, ranging from 1 to 500.<br>Default value: 1</p><p>Unit: Mbps</p></td></tr><tr><td>resourceGroupId</td><td>No</td><td>String</td><td><p>Resource group ID.</p><p>If the value is null, then return all the private connects in the authorized resource groups.</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 private connect.</p><p>Tag keys must be unique.</p></td></tr></tbody></table>

## 3. Output Parameters

<table><thead><tr><th width="223.33333333333331">Parameter Name</th><th width="107">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>privateConnectId</td><td>String</td><td>Private connect ID.</td></tr></tbody></table>

## 4. Code Example

{% tabs %}
{% tab title="Example" %}
**Create a Layer 2 private connect with ports as both access point A and access point Z. The bandwidth cap is 10 Mbps.**

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

Request：
{
   "endpointA": {
      "vlanId": 1001,
      "portId": "your port id"
   },
   "privateConnectName": "fra-sel-prviate-line",
   "endpointZ": {
      "vlanId": 2001,
      "portId": "your portId id"
   },
   "bandwidthMbps": 10
}

Response：
{   
  "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3",
  "response": {
     "requestId": "T98044459-95B2-477E-9A2F-00253A70CC6E"，
     "privateConnectId": "your private connect 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

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

<table><thead><tr><th width="208.5478645066274">HTTP Status Code</th><th width="286">Error Code</th><th>Description</th></tr></thead><tbody><tr><td>404</td><td>INVALID_PORT_NOT_FOUND</td><td>Port does not exist.</td></tr><tr><td>400</td><td>INVALID_PORT_STATUS</td><td>The state of port should be <code>Available</code>.</td></tr><tr><td>400</td><td>INVALID_ENDPOINT_PARAMETER</td><td>Invalid access point type.</td></tr><tr><td>400</td><td>INVALID_CONNECT_ENDPOINT_CONFLICT</td><td>Duplicated access point A and Z.</td></tr></tbody></table>
