> 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/platform-service/zrm/tag/describeresourcebytags.md). Agents can also search and read this documentation through its [MCP server](https://docs.console.zenlayer.com/api-reference/~gitbook/mcp).

# DescribeResourceByTags

## 1. API Description

This API (DescribeResourceByTags) is used to query resources bound to tags.

{% hint style="info" %}
**Note**

* At least one of `tags` or `tagKeys` must be provided.
  {% endhint %}

## 2. Input Parameters

The following request parameter list only provides API request parameters.

| Parameter Name | Required | Type                                                                                                      | Description       |
| -------------- | -------- | --------------------------------------------------------------------------------------------------------- | ----------------- |
| tags           | No       | Array of [Tag](https://docs.console.zenlayer.com/api-reference/platform-service/zrm/datastructure.md#tag) | List of tags.     |
| tagKeys        | No       | Array of String                                                                                           | List of tag keys. |

## 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                                                                                                                     | Total number of resources bound to the specified tags.                                                                |
| dataSet        | Array of [ResourceInfo](https://docs.console.zenlayer.com/api-reference/platform-service/zrm/datastructure.md#resourceinfo) | List of resources bound to the specified tags.                                                                        |

## 4. Code Example

{% tabs %}
{% tab title="Example" %}
**1. Retrieve all resources bound to tags**

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

Request：
{
  "tags": [
    {
      "key": "env",
      "value": "production"
    }
  ],
  "tagKeys": [
    "env"
  ]
}

Response：
{
  "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3",
  "response": {
    "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3",
    "totalCount": 1,
    "dataSet": [
      {
        "resourceType": "BMC_INSTANCE",
        "resourceUuid": "123456789012345678"
      }
    ]
  }
}
```

{% endtab %}
{% endtabs %}

## 5. Developer Resources

Zenlayer Cloud API 2.0 integrates [SDKs](https://docs.console.zenlayer.com/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](https://docs.console.zenlayer.com/api-reference/api-introduction/instruction/commonerrorcode.md).

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