Updated on 2026-07-24 GMT+08:00

Querying the Resource List by Tag

Function

This API is used to search for resources by tag or resource name. For example, in resource management and search, you can search for resources by tag or fuzzy search. By calling this API, you can perform exact or fuzzy query based on multiple tags or resource names. If no tag is specified, all resources are returned. You must have sufficient permissions and the target resource must exist. After the query is successful, the list of resources that meet the query conditions is returned. If the query fails, an error message is returned. Common exceptions include permission verification errors, resource non-existence errors, and parameter verification errors.

Debugging

You can debug this API through automatic authentication in API Explorer or use the SDK sample code generated by API Explorer.

Authorization Information

Each account has all the permissions required to call all APIs, but IAM users must be assigned the required permissions.

  • If you are using role/policy-based authorization, see Permissions Policies and Supported Actions for details on the required permissions.
  • If you are using identity policy-based authorization, the following identity policy-based permissions are required.

    Action

    Access Level

    Resource Type (*: required)

    Condition Key

    Alias

    Dependencies

    modelarts::listResourcesByTag

    List

    -

    g:TagKeys

    modelarts:tag:list

    -

URI

POST /v2/{project_id}/modelarts-service-v2/resource-instances/filter

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Definition

Project ID. For details, see Obtaining a Project ID and Name.

Constraints

N/A

Range

Project ID.

Default Value

N/A

Table 2 Query Parameters

Parameter

Mandatory

Type

Description

limit

No

Integer

Definition

Maximum number of records that can be returned.

Constraints

N/A

Range

[1,500]

Default Value

10.

offset

No

Integer

Definition

Offset of the pagination list query.

Constraints

The value must be an integral multiple of limit.

Range

N/A

Default Value

0.

workspace_id

No

String

Definition

Workspace ID. workspaceId will be set to null.

Constraints

N/A

Range

N/A

Default Value

N/A

Request Parameters

Table 3 Request header parameters

Parameter

Mandatory

Type

Description

Content-Type

Yes

String

Definition

Message body type or format.

Constraints

N/A

Range

  • application/json

  • application/json;charset=utf-8

Default Value

N/A

X-Auth-Token

Yes

String

Definition

User token. It can be obtained by calling the IAM API used to obtain a user token. The value of X-Subject-Token in the response header is the user token. For details about how to obtain the token, see Obtaining a User Token Through Password Authentication.

Constraints

N/A

Range

N/A

Default Value

N/A

Table 4 Request body parameters

Parameter

Mandatory

Type

Description

matches

No

Array of TmsMatch objects

Definition

Matching item. Currently, only fuzzy match of resource names is supported.

Constraints

N/A

tags

No

Array of CombineTmsTags objects

Definition

Tags for matching. Only multiple tags can be ANDed. If this parameter is not specified, all resources are queried.

Constraints

N/A

without_any_tag

No

Boolean

Definition

Specifies whether to only query resources without tags.

Constraints

N/A

Range

true: Query only resources without tags.

false: Query all resources.

Default Value

N/A

limit

No

Integer

Definition

Maximum number of records displayed on each page.

Constraints

N/A

Range

N/A

Default Value

10.

offset

No

Integer

Definition

Start page of the pagination list.

Constraints

N/A

Range

N/A

Default Value

0.

Table 5 TmsMatch

Parameter

Mandatory

Type

Description

key

Yes

String

Definition

Key for matching. Currently, only resource_name is supported.

Constraints

N/A

Range

N/A

Default Value

N/A

value

Yes

String

Definition

Key value, which is case-insensitive. If the key is resource_name, fuzzy search is supported.

Constraints

N/A

Range

N/A

Default Value

N/A

Table 6 CombineTmsTags

Parameter

Mandatory

Type

Description

key

Yes

String

Definition

Tag key.

Range

N/A

values

Yes

Array of strings

Definition

Merged tag values with the same key.

Range

N/A

Response Parameters

Status code: 200

Table 7 Response body parameters

Parameter

Type

Description

resources

Array of TmsResource objects

Definition

Resources list queried by tag.

total_count

Integer

Definition

The total number of records.

Range

N/A

Table 8 TmsResource

Parameter

Type

Description

resource_detail

Object

Definition

Resource details. This parameter is used as an extended field and is left blank by default.

Range

N/A

resource_id

String

Definition

Specifies the resource ID.

Range

N/A

resource_name

String

Definition

Resource name.

Range

N/A

tags

Array of TmsTag objects

Definition

All tags of the current resource.

Range

N/A

Table 9 TmsTag

Parameter

Type

Description

key

String

Definition

Tag key field.

Constraints

N/A

Range

The value can contain 1 to 128 characters. Only letters, digits, spaces, and special characters (_.:=+-@) are allowed. However, the value cannot start or end with a space or start with sys.

Default Value

N/A

value

String

Definition

Tag value field.

Constraints

Only letters, digits, underscores (_), dots (.), slashes (/), equal signs (=), plus signs (+), minus signs (–), and at signs (@) are allowed.

Range

The value can contain 0 to 255 characters.

Default Value

N/A

Status code: 400

Table 10 Response body parameters

Parameter

Type

Description

error_code

String

  • Definition: ModelArts error code.

Range: N/A.

error_msg

String

Definition: Error message.

Range: N/A.

Status code: 401

Table 11 Response body parameters

Parameter

Type

Description

error_code

String

  • Definition: ModelArts error code.

Range: N/A.

error_msg

String

Definition: Error message.

Range: N/A.

Status code: 403

Table 12 Response body parameters

Parameter

Type

Description

error_code

String

  • Definition: ModelArts error code.

Range: N/A.

error_msg

String

Definition: Error message.

Range: N/A.

Status code: 404

Table 13 Response body parameters

Parameter

Type

Description

error_code

String

  • Definition: ModelArts error code.

Range: N/A.

error_msg

String

Definition: Error message.

Range: N/A.

Example Requests

This API is used to query the resource list based on the resource_name tag and matching resources whose names contain resource1. Note: Fuzzy match.

https://{endpoint}/v2/{project_id}/modelarts-service-v2/resource-instances/filter

{
  "matches" : [ {
    "key" : "resource_name",
    "value" : "resource1"
  } ],
  "tags" : [ {
    "key" : "key1",
    "values" : [ "*value1", "value2" ]
  } ]
}

Example Responses

Status code: 200

Response to a normal request.

{
  "resources" : [ {
    "resource_id" : "6efce7bf-677d-400f-b451-3543ed997a24",
    "resource_name" : "service-79ca",
    "tags" : [ {
      "key" : "model_version",
      "value" : "0.1"
    }, {
      "key" : "gpu_type",
      "value" : "v100"
    } ]
  } ],
  "total_count" : 1000
}

Status Codes

Status Code

Description

200

Response to a normal request.

400

Invalid parameter.

401

Authentication failed.

403

Insufficient permissions.

404

Resource not found.

Error Codes

See Error Codes.