> 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/bmc/vpc/subnet/describesubnets.md).

# DescribeSubnets

## 1. API Description

This API (DescribeSubnets) is used to query the details of one or more subnets. You can filter the query results with the subnet ID, VPC ID, zone ID and subnet name.

## 2. Input Parameters

The following request parameter list only provides API request parameters.

| Parameter Name  | Required | Type                                                             | Description                                                                                                               |
| --------------- | -------- | ---------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
| subnetIds       | No       | Array of String                                                  | <p>Subnet ID(s).</p><p>The maximum number of subnets in each request is 100.</p>                                          |
| subnetName      | No       | String                                                           | Name of subnet.                                                                                                           |
| cidrBlock       | No       | String                                                           | CIDR block of subnet.                                                                                                     |
| subnetStatus    | No       | [SubnetStatus](/api-reference/bmc/datastructure.md#subnetstatus) | [Status of subnet](https://github.com/zenlayer/zenlayercloud-api-doc-en/blob/main/bmc/vpc/datastructure.md#subnetstatus). |
| zoneId          | No       | String                                                           | Zone ID to which subnets belong.                                                                                          |
| vpcId           | No       | String                                                           | VPC ID.                                                                                                                   |
| resourceGroupId | No       | String                                                           | <p>Resource group ID.</p><p>If the value is null, then return all the subnets in the authorized resource groups.</p>      |
| pageSize        | No       | Integer                                                          | <p>Number of items in the current page result.</p><p>Default value: 20;</p><p>Maximum value: 1000.</p>                    |
| pageNum         | No       | Integer                                                          | <p>Number of pages returned.</p><p>Default value: 1</p>                                                                   |

## 3. Output Parameters

| Parameter Name | Type                                                                  | Description                                                                                                           |
| -------------- | --------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
| requestId      | String                                                                | <p>The unique request ID, which is returned for each request.</p><p>RequestId is required for locating a problem.</p> |
| totalCount     | Integer                                                               | Number of subnets meeting the filtering conditions.                                                                   |
| dataSet        | Array of [SubnetInfo](/api-reference/bmc/datastructure.md#subnetinfo) | Information on subnets.                                                                                               |

## 4. Code Example

{% tabs %}
{% tab title="Example" %}
Query subnets with the CIDR block `10.0.0.0/8`.

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

Request:
{
  "cidrBlock": "10.0.0.0/8",
  "pageSize": 10,
  "pageNum": 1
}

Response:
{
  "requestId": "T2CF86177-29D1-41C0-91E7-542C38C194D7",
  "response": {
    "requestId": "T2CF86177-29D1-41C0-91E7-542C38C194D7",
    "totalCount": 8,
    "dataSet": [
      {
        "subnetId": "669986345980014296",
        "subnetName": "Subnet-LAX3B-Default",
        "zoneId": "LAX-B",
        "availableIpCount": "16777213",
        "cidrBlock": "10.0.0.0/8",
        "subnetStatus": "AVAILABLE",
        "createTime": "2022-07-13T09:43:16Z",
        "vpcSubnetStatus": "BINDED",
        "vpcId": null,
        "vpcName": null,
        "resourceGroupId": "5a4f6519-2977-47cb-b3fc-150fd2b4de71",
        "resourceGroupName": "Default Resource Group",
        "subnetInstanceSet": null
      },
      {
        "subnetId": "669998042870457304",
        "subnetName": "Subnet-LAX3B-Default",
        "zoneId": "LAX-B",
        "availableIpCount": "16777213",
        "cidrBlock": "10.0.0.0/8",
        "subnetStatus": "AVAILABLE",
        "createTime": "2022-07-13T10:06:31Z",
        "vpcSubnetStatus": "BINDED",
        "vpcId": null,
        "vpcName": null,
        "resourceGroupId": "5a4f6519-2977-47cb-b3fc-150fd2b4de71",
        "resourceGroupName": "Default Resource Group",
        "subnetInstanceSet": null
      },
      {
        "subnetId": "670074179940261592",
        "subnetName": "Subnet-SIN4E-Default",
        "zoneId": "SIN-E",
        "availableIpCount": "16777213",
        "cidrBlock": "10.0.0.0/8",
        "subnetStatus": "AVAILABLE",
        "createTime": "2022-07-13T12:37:47Z",
        "vpcSubnetStatus": "BINDED",
        "vpcId": null,
        "vpcName": null,
        "resourceGroupId": "5a4f6519-2977-47cb-b3fc-150fd2b4de71",
        "resourceGroupName": "Default Resource Group",
        "subnetInstanceSet": null
      },
      {
        "subnetId": "675574042144543192",
        "subnetName": "Subnet-HKG5A-Deafault",
        "zoneId": "HKG-A",
        "availableIpCount": "16777213",
        "cidrBlock": "10.0.0.0/8",
        "subnetStatus": "AVAILABLE",
        "createTime": "2022-07-21T02:45:02Z",
        "vpcSubnetStatus": "BINDED",
        "vpcId": "675574041725115352",
        "vpcName": "VPC-HKG-A-Default",
        "resourceGroupId": "5a4f6519-2977-47cb-b3fc-150fd2b4de71",
        "resourceGroupName": "Default Resource Group",
        "subnetInstanceSet": null
      },
      {
        "subnetId": "706839622444915160",
        "subnetName": "Subnet-TYO2A-Default",
        "zoneId": "TYO-A",
        "availableIpCount": "16777213",
        "cidrBlock": "10.0.0.0/8",
        "subnetStatus": "CREATING",
        "createTime": "2022-09-02T06:04:09Z",
        "vpcSubnetStatus": "BINDING",
        "vpcId": "706839622411361496",
        "vpcName": "VPC-TYO-A-Default",
        "resourceGroupId": "5a4f6519-2977-47cb-b3fc-150fd2b4de71",
        "resourceGroupName": "Default Resource Group",
        "subnetInstanceSet": null
      },
      {
        "subnetId": "736091361970760152",
        "subnetName": "Subnet-AMS-C-Default",
        "zoneId": "AMS-C",
        "availableIpCount": "16777213",
        "cidrBlock": "10.0.0.0/8",
        "subnetStatus": "CREATING",
        "createTime": "2022-10-12T14:42:08Z",
        "vpcSubnetStatus": "BINDING",
        "vpcId": "736091361115114712",
Disconnected from the target VM, address: '127.0.0.1:56971', transport: 'socket'
        "vpcName": "VPC-AMS-C-Default",
        "resourceGroupId": "5a4f6519-2977-47cb-b3fc-150fd2b4de71",
        "resourceGroupName": "Default Resource Group",
        "subnetInstanceSet": null
      },
      {
        "subnetId": "750526252527395288",
        "subnetName": "Subnet-FRA-B-Default",
        "zoneId": "FRA-B",
        "availableIpCount": "16777213",
        "cidrBlock": "10.0.0.0/8",
        "subnetStatus": "CREATING",
        "createTime": "2022-11-01T12:41:41Z",
        "vpcSubnetStatus": "BINDING",
        "vpcId": "750526251764025304",
        "vpcName": "VPC-FRA-B_D_E-Default",
        "resourceGroupId": "5a4f6519-2977-47cb-b3fc-150fd2b4de71",
        "resourceGroupName": "Default Resource Group",
        "subnetInstanceSet": null
      },
      {
        "subnetId": "786474054390385368",
        "subnetName": "Subnet-LAX-C-Default",
        "zoneId": "LAX-C",
        "availableIpCount": "16777213",
        "cidrBlock": "10.0.0.0/8",
        "subnetStatus": "CREATING",
        "createTime": "2022-12-21T03:03:33Z",
        "vpcSubnetStatus": "BINDING",
        "vpcId": "786474054256176856",
        "vpcName": "VPC-LAX-C-Default",
        "resourceGroupId": "5a4f6519-2977-47cb-b3fc-150fd2b4de71",
        "resourceGroupName": "Default Resource Group",
        "subnetInstanceSet": null
      }
    ]
  }
}
```

{% endtab %}
{% endtabs %}

## 5. Developer Resources

Zenlayer Cloud API 2.0 integrates [SDKs](/api-reference/api-introduction/toolkit/api-sdk.md)，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](/api-reference/api-introduction/instruction/commonerrorcode.md).

| HTTP Status Code | Error Code | Description |
| ---------------- | ---------- | ----------- |
