AddTags

Last Updated: Dec 15, 2017

Description

Bind a tag to your services for easier, customizable O&M. Before binding a tag, consider the following:

  • Tags can be created for ECS instances, disks, snapshots, images, and security groups.
  • Each resource can bind with up to 10 tags.
  • If the key for the tag to be bound already exists for the specified resource, the value is overwritten.
  • Tag.n.Key must uniquely match Tag.n.Value.

Request parameter

Name Type Required Description
Action String Yes The name of this interface. Value: AddTags.
RegionId String Yes Indicates the resource region.
ResourceId String Yes Indicates the resource ID of the tag to be created.
ResourceType String Yes The types of the resources to add a tag.
  • image
  • instance
  • snapshot
  • disk
  • securitygroup
All values must be lowercased.
Tag.n.Key String Yes This parameter indicates the tag key where n ranges from 1 to 5. Tag names can be up to 64 characters in length and:
  • Cannot begin with aliyun.
  • Cannot begin with http:// or https:// .
  • Cannot be an empty string.
Tag.n.Value String Yes This parameter indicates the tag value where n ranges from 1 to 5. Tags can be up to 128 characters in length and:
  • Cannot begin with aliyun.
  • Cannot begin with http:// or https://.
  • Can be an empty string.

Response parameter

Name Type Description
RequestId String Request ID

Error codes

Error code Error message HTTP status code Meaning
MissingParameter The input parameter ResourceId that is mandatory for processing this request is not supplied. 400 ResourceId parameter is not specified.
InvalidResourceId.NotFound The specified RegionId does not exist. 404 Specified ResourceId does not exist.
MissingParameter The input parameter RegionId that is mandatory for processing this request is not supplied. 400 RegionId parameter is not specified.
InvalidRegionId.NotFound The RegionId provided does not exist in our records. 404 Specified RegionId does not exist.
MissingParameter The input parameter ResourceType that is mandatory for processing this request is not supplied. 400 ResourceType parameter is not specified.
InvalidResourceType.NotFound The ResourceType provided does not exist in our records. 404 Specified ResourceType does not exist.
MissingParameter.TagKey The input parameter Tag.n.Key that is mandatory for processing this request is not supplied. 400 Tag.n.Key parameter is not specified.
InvalidTagKey.Malformed The specified Tag.n.Key is not valid. 400 Specified Tag.n.Key is invalid.
MissingParameter.TagValue The input parameter Tag.n.Value that is mandatory for processing this request is not supplied. 400 Tag.n.Value parameter is not specified.
InvalidTagValue.Malformed The specified Tag.n.Value is not valid. 400 Specified Tag.n.Value is invalid.
OperationDenied.QuotaExceed The quota of tags on resource is beyond permitted range. 400 More than 10 user tags exist on the resource.
InvalidTag.Mismatch The specified Tag.n.Key and Tag.n.Value are not match. 400 Tag.n.Key and Tag.n.Value are not unique matches.
InvalidTagCount The specified tags are beyond the permitted range. 400 More than 5 tags are specified.
InvalidResourceId.NotSupported The specified ResourceId does not support tagging. 403 Tagging is unsupported for the specified resource ID.

Examples

Request example

  1. https://ecs.aliyuncs.com/?Action=AddTags
  2. &ResourceId=s-946ntx4wr
  3. &ResourceType=snapshot
  4. &RegionId=cn-shenzhen
  5. &Tag.1.Key=test
  6. &Tag.1.Value=api
  7. &<Common Request Parameter>

Response example

XML format

  1. <AddTagsResponse>
  2. <RequestId>C46FF5A8-C5F0-4024-8262-B16B639225A0</RequestId>
  3. </AddTagsResponse>

JSON format

  1. {
  2. "RequestId": "C46FF5A8-C5F0-4024-8262-B16B639225A0"
  3. }
Thank you! We've received your feedback.