# CreatePort

## 1. API Description

This API is used to create a port.

#### Prerequisites

Before creating a port, you can call [`DescribeDatacenters`](https://docs.console.zenlayer.com/api-reference/networking/common/describedatacenters#describedatacenters) to query data centers in which port creation is supported.

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

<mark style="color:blue;">This API is an async API. A port ID is returned after the creation request is sent. However, it does not mean the creation has been completed. The status of the port will be</mark> <mark style="color:blue;">`CREATING`</mark> <mark style="color:blue;">during the creation. You can use</mark> [<mark style="color:purple;">`DescribePorts`</mark>](https://docs.console.zenlayer.com/api-reference/networking/sdn/describeports#describeports) <mark style="color:blue;">to query the status of the port. If the status changes from</mark> <mark style="color:blue;">`Creating`</mark> <mark style="color:blue;">to</mark> <mark style="color:blue;">`Running`</mark><mark style="color:blue;">, it means that the port has been created successfully;</mark> <mark style="color:blue;">`No`</mark> <mark style="color:blue;">means the port is still being created. Any operations on the port 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="180.955511412116">Parameter Name</th><th width="111">Required</th><th width="94.5753173828125">Type</th><th>Description</th></tr></thead><tbody><tr><td>dcId</td><td>Yes</td><td>String</td><td><p>Code of data center.</p><p>To obtain code, you can call <a href="../common/describedatacenters"><code>DescribeDataCenters</code></a>, and find <code>dcId</code> in the response.</p></td></tr><tr><td>portName</td><td>Yes</td><td>String</td><td><p>Port name.</p><p>Up to 255 characters in length are allowed. You're recommended to use data center code combined with port speed.</p></td></tr><tr><td>portRemarks</td><td>No</td><td>String</td><td><p>Note of port.</p><p>Up to 255 characters in length are allowed.</p></td></tr><tr><td>portType</td><td>Yes</td><td>String</td><td><p>Port speed.</p><p>To obtain port speed, you can call <a href="describedatacenterportprice"><code>DescribeDataCenterPortType</code></a>, and find <code>portType</code> in the response.</p></td></tr><tr><td>businessEntityName</td><td>Yes</td><td>String</td><td><p>Your business entity name.</p><p>The entity name to be used on the Letter of Authorization (LOA). This should be the name that is registered with the colocation facility.</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 port.</p><p>Tag keys must be unique.</p></td></tr></tbody></table>

## 3. Output Parameters

<table><thead><tr><th width="197.33333333333331">Parameter Name</th><th width="95">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>portId</td><td>String</td><td>Port ID.</td></tr></tbody></table>

## 4. Code Example

{% tabs %}
{% tab title="Example" %}
**Create a** `1G` **port in** `SIN1`**.**

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

Request:
{
  "dcId": "SIN1",
  "portName": "your-port-name",
  "portRemarks": "your-port-remarks",
  "portType": "1G",
  "businessEntityName": "your-business-entity-name"
}

Response:
{
  "requestId": "T3811A0E7-C250-40A2-96AD-08AD759E1BC2",
  "response": {
    "requestId": "T3811A0E7-C250-40A2-96AD-08AD759E1BC2",
    "portId": "your-port-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="203.33333333333331">HTTP Status Code</th><th width="200">Error Code</th><th>Description</th></tr></thead><tbody><tr><td>7111</td><td>SELF_SERVICE_PORT_NOT_SHELF</td><td>Port is unavailable for sale.</td></tr></tbody></table>
