All Products
Search
Document Center

Cloud Storage Gateway:TagResources

Last Updated:Aug 28, 2026

Creates and attaches tags to resources.

Operation description

If you have a large number of instances, you can create multiple tags, add them to instances, and then filter instances by tag.

  • A tag consists of a key-value pair. Each key must be unique within a region for an Alibaba Cloud account. Different keys can be mapped to the same value.

  • If you specify a tag that does not exist, the tag is automatically created and added to the specified gateway.

  • If a tag to be added has the same key as an existing tag on the gateway, the new tag overwrites the existing tag.

  • You can attach up to 20 tags to each gateway.

  • You can attach tags to up to 50 gateways in an API request.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

hcs-sgw:TagResources

update

*All Resource

*

None None

Request parameters

Parameter

Type

Required

Description

Example

RegionId

string

Yes

The region ID. Call the DescribeRegions operation to query region IDs.

cn-hangzhou

ResourceRegionId

string

No

The region ID of the resource.

cn-hangzhou

ResourceType

string

Yes

The type of the resource. Valid value: GATEWAY.

GATEWAY

Tag

array<object>

Yes

The tags.

object

No

The tags.

Key

string

Yes

The tag key. You can specify 1 to 20 tag keys for a gateway. The tag key cannot be an empty string.

testkey1

Value

string

No

The tag value associated with the specified tag key. You can specify 1 to 20 tag values for a gateway. The tag value can be an empty string.

testvalue1

ResourceId

array

Yes

The gateway IDs. You can specify 1 to 50 gateway IDs in a single request.

string

No

The gateway ID.

gw-uf6wjk5xxxxxxx

Response elements

Element

Type

Description

Example

object

RequestId

string

The request ID.

224DB9F7-3100-4899-AB9C-C938BCCB43E7

Examples

Success response

JSON format

{
  "RequestId": "224DB9F7-3100-4899-AB9C-C938BCCB43E7"
}

Error codes

HTTP status code

Error code

Error message

Description

400 MissingParameter.ResourceIds The parameter - ResourceIds.N should not be null.
400 MissingParameter.Tags The parameter - Tags should not be null.
400 Missing.TagKey The Tag.N.Key parameter is blank.
400 InvalidParameter.TagKey The Tag.N.Key parameter is invalid.
400 InvalidParameter.TagValue The Tag.N.Value parameter is invalid.
400 InvalidParameter.ResourceType The ResourceType parameter is invalid.
400 Duplicate.TagKey The Tag.N.Key contain duplicate key.
400 MissingParameter.TagOrResourceId The specified Tags and ResourcesIds are not allow to both empty.
400 NumberExceed.ResourceIds The ResourceIds parameter's number is exceed , Valid : 50
400 NumberExceed.Tags The Tags parameter's number is exceed , Valid : 20
400 QuotaExceed.TagsPerResource The tags per resource number is exceed, Valid: 20
403 PermissionDenied.Scope The specified operator not have permission to set Scope value.
403 PermissionDenied.TagOwnerUid The specified operator not have permission to set TagOwnerUid value.
403 PermissionDenied.TagOwnerBid The specified operator not have permission to set TagOwnerBid value.
403 NoPermissionKey.Operator These keys are not permission for this operator.
403 NoPermissionKey.Scope These keys are not permission for this scope.
403 NoPermissionKey.Category These keys are not permission for this category.
403 NoPermission.SystemTag The operator is not permission for the system tag.
403 NoPermission.Operator The operator is not permission for this operate.
404 InvalidResourceType.NotFound The ResourceType provided does not exist in our records.
404 InvalidResourceId.NotFound The specified ResourceId is not found in our records.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.