> 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/cn/sdn/data-center-port/createport.md).

# CreatePort

## 1. 接口描述

本接口(CreatePort)用于创建端口。

{% hint style="info" %}
**注意事项**

* 本接口为异步接口，当创建Port请求下发成功后会返回一个Port`ID`列表，此时创建Port操作并未立即完成。在此期间Port的状态将会处于 **`CREATING`**，Port创建结果可以通过调用 [**DescribePorts**](/api-reference/cn/sdn/data-center-port/describeports.md#describeports) 接口查询，如果Port状态由\*\*`CREATING`\*\* (创建中)变为 **`RUNNING`**，则代表Port创建成功，否则代表还在创建中。创建过程中不可对Port进行任何操作。
  {% endhint %}

## 2. 请求参数

以下请求参数列表仅列出了接口中需要的请求参数

| 参数名称               | 必选 | 类型                                                                      | 描述                                                                                                                                                    |
| ------------------ | -- | ----------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| dcId               | 是  | String                                                                  | <p>数据中心ID。</p><p>可通过 <a href="/api-reference/cn/sdn/location/describedatacenters.md">DescribeDataCenters</a> 接口获取。</p>                                |
| portName           | 是  | String                                                                  | <p>数据中心端口名称。</p><p>不超过 255 字符，建议使用数据中心四字码+数据中心端口规格。</p>                                                                                               |
| portType           | 是  | String                                                                  | <p>数据中心端口规格。</p><p>可通过 <a href="/api-reference/cn/sdn/data-center-port/describedatacenterportprice.md">DescribeDataCenterPortPrice</a> 接口获取，取值：1G</p> |
| businessEntityName | 是  | String                                                                  | <p>商业实体名称。</p><p>用于 LOA 抬头。</p>                                                                                                                       |
| portRemarks        | 否  | String                                                                  | <p>数据中心端口备注信息。</p><p>不超过 255 字符。</p>                                                                                                                  |
| marketingOptions   | 否  | [MarketingInfo](/api-reference/cn/sdn/datastructure.md#marketinginfo)   | 市场营销活动相关信息。                                                                                                                                           |
| tags               | 否  | [TagAssociation](/api-reference/cn/sdn/datastructure.md#tagassociation) | <p>创建数据中心端口时关联的标签。</p><p>注意：关联<code>标签键</code>不能重复。</p>                                                                                               |

## 3. 响应结果

| 参数名称        | 类型     | 描述                                                       |
| ----------- | ------ | -------------------------------------------------------- |
| requestId   | String | <p>唯一请求 ID。</p><p>每次请求都会返回。定位问题时需要提供该次请求的 requestId。</p> |
| orderNumber | String | 创建数据中心端口产生的订单号。                                          |
| portId      | String | 创建成功的数据中心端口 ID。                                          |

## 4. 代码示例

{% tabs %}
{% tab title="示例" %}
**1.在新加坡1（SIN1）创建一个1G规格的数据中心端口。**

```
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",
    "orderNumber": "your-order-number",
    "portId": "your-port-id"
  }
}
```

{% endtab %}
{% endtabs %}

## 5. 开发者工具

Zenlayer Cloud API 2.0 提供了配套的[开发工具集（SDK）](/api-reference/cn/api-introduction/toolkit.md)，未来会陆续支持更多开发语言，方便快速接入和使用Zenlayer的产品和服务。

## 6. 错误码

下面包含业务逻辑中遇到的错误码，其他错误码见[公共错误码](/api-reference/cn/api-introduction/instruction/commonerrorcode.md)

| HTTP状态码 | 错误码 | 说明 |
| ------- | --- | -- |
