# DescribePortUsableVlan

## 1. API Description

This API is used to query available VLANs for the port.

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

<mark style="color:blue;">At least one of the following parameters needs to be passed in: Port or data center.</mark>
{% endhint %}

## 2. Input Parameters

The following request parameter list only provides API request parameters.

<table><thead><tr><th width="194.15238095238095">Parameter Name</th><th width="118">Required</th><th width="98">Type</th><th>Description</th></tr></thead><tbody><tr><td>dcId</td><td>No</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>portId</td><td>No</td><td>String</td><td>Port ID.</td></tr></tbody></table>

## 3. Output Parameters

<table><thead><tr><th width="199.33333333333331">Parameter Name</th><th width="166">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>start</td><td>Integer</td><td>Start value of VLAN range.</td></tr><tr><td>end</td><td>Integer</td><td>End value of VLAN range.</td></tr><tr><td>inuseVlanList</td><td>Array of Integer</td><td>List of occupied VLANs.</td></tr></tbody></table>

## 4. Code Example

{% tabs %}
{% tab title="Example" %}
**Query available VLANs for a port.**

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

Request: {
  "portId": "your-port-id"
}

Response: {
  "requestId": "TEEFDCA5B-76FB-4E91-A18E-DF7F5D2CE41F",
  "response": {
    "requestId": "TEEFDCA5B-76FB-4E91-A18E-DF7F5D2CE41F",
    "dataSet": {
      "start": 1,
      "end": 4000,
      "inuseVlanList":[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 3999, 4000]
    }
  }
}
```

{% 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="195.33333333333331">HTTP Status Code</th><th width="286">Error Code</th><th>Description</th></tr></thead><tbody><tr><td>7112</td><td>SELF_SERVICE_PORT_VLAN_PORT_AND_DC_NEED_AT_LEAST_ONE</td><td><mark style="color:blue;">At least one port or one data center needs to be passed in.</mark></td></tr></tbody></table>
