You need to enable JavaScript to run this app.
文档中心
云服务器

云服务器

复制全文
下载 pdf
标签
CreateTags - 创建标签 (旧版)
复制全文
下载 pdf
CreateTags - 创建标签 (旧版)
调用 CreateTags 接口为一个或多个资源添加用户标签。​
使用说明​
注意​
当前页面为旧版标签接口,未来可能停止维护。新版标签接口使用场景更加广泛,建议新用户使用以下新版标签接口,了解更多。​
注意事项​
  • 单个资源最多可以添加50个标签,单次调用该接口最多支持添加20个标签。​
  • 为同一个资源重复添加相同标签键的标签,则新标签值会自动覆盖原标签值。​
  • “删除中”的资源不允许添加标签。​
调试​
API Explorer
您可以通过 API Explorer 在线发起调用,无需关注签名生成过程,快速获取调用结果。
​
请求参数​
下方仅列出该接口特有的请求参数和部分公共参数。更多信息请见公共参数。​
Action string 必选 示例值:CreateTags​
要执行的操作,取值:CreateTags。​
​
Version string 必选 示例值:2020-04-01​
API的版本,取值:2020-04-01。​
​
ClientToken string 可选 示例值:333456899ff****​
保证请求幂等性。由客户端自动生成一个参数值,确保不同请求间该参数值唯一,避免当调用API超时或服务器内部错误时,客户端多次重试导致重复性操作。​
取值:仅支持ASCII字符,且不能超过64个字符。​
​
ResourceIds.N string[] 可选 示例值:ResourceIds.1=i-l8u0p77yseabkpak****&ResourceIds.2=i-l8u0p7xyseabkbak****​
资源ID。​
  • 参数 - N:表示资源的序号,取值范围:1~50。​
  • 多个资源之间用&分隔。​
​
ResourceType string 必选 示例值:instance​
资源类型,取值:​
  • instance:实例​
  • image:镜像​
  • reservedinstance:预留实例券​
  • scheduledinstance:弹性预约实例​
  • keypair:密钥对​
​
Tags.N.Key string[] 必选 示例值:Tags.1.Key=k1​
为资源添加的用户标签的标签键。​
  • 参数 - N:表示标签键的序号,取值范围:1~20。​
  • 多个标签键之间用&分隔。​
命名规则如下:​
  • 不能以任何大小写形式的volc:或sys:开头。​
volc:或sys:开头为系统预留标签键禁止创建。​
  • 只能包含语言字符、数字、空格和英文符号“_”、“.”、“:”、“/”、“=”、“+”、“-”、“@”。​
  • 长度限制在1~128个字符之间。​
​
Tags.N.Value string[] 可选 示例值:Tags.1.Value=v1​
为资源添加的用户标签的标签值。​
  • 参数 - N:表示标签值的序号,取值范围:1~20。​
  • 多个标签值之间用&分隔。​
命名规则如下:​
  • 只能包含语言字符、数字、空格和英文符号“_”、“.”、“:”、“/”、“=”、“+”、“-”、“@”。​
  • 允许为空,长度限制在0~256个字符之间。​
​
​
​
返回参数​
下表仅列出本接口特有的返回参数。更多信息请参见返回结构。​
说明​
仅当请求参数输入不合法时提示下文中的接口错误码。若请求参数输入无误,将不会提示接口错误码,且接口的返回状态码将为200,但这并不代表对所有资源的操作均已成功,单个资源的操作结果请参见如下返回参数中的信息。​
OperationDetails object[] 示例值:--​
操作详情。​
Error object 示例值:--​
操作的资源错误信息。​
Code string 示例值:InvalidInstance.NotFound​
批量操作时具体单个请求失败的错误码,取值:​
  • InvalidResourceId.NotFound:指定的资源不存在。​
  • InvalidResourceStatus:当前资源的状态不支持此操作。​
  • OperationDenied.ResourceLocked:指定的操作被拒绝,因为您的资源已被其他操作锁定。​
  • InternalError:内部错误,请重试。如果多次尝试失败,请提交工单。​
  • FlowLimitExceeded:您已超过资源请求限速。​
说明​
Code与Message按顺序一一对应。​
​
Message string 示例值:The specified instance does not exist.​
批量操作时具体单个请求失败的错误信息,取值:​
  • The specified ResourceId does not exist.​
  • The status of the specified resource does not support this request.​
  • The specified operation is denied as your resource is locked for another operation.​
  • An internal error has occurred.​
  • You've reach the limit on request rate of resources.​
说明​
Code与Message按顺序一一对应。​
​
​
ResourceId string 示例值:i-l8u0p77yseabkpak****​
操作的资源ID。​
​
​
​
​
请求示例​
​
GET /?Action=CreateTags&Version=2020-04-01&ResourceType=instance&ResourceIds.1=i-l8u0p77yseabkpak****&ResourceIds.2=i-l8u0p7xyseabkbak****&Tags.1.Key=k1&Tags.1.Value=v1 HTTP/1.1​
Host: ecs.cn-beijing.volcengineapi.com​
Region: cn-beijing​
ServiceName: ecs​
​
返回示例​
​
{​
"ResponseMetadata": {​
"RequestId": "2021062415303301022514515207C4****",​
"Action": "CreateTags",​
"Version": "2020-04-01",​
"Service": "ecs",​
"Region": "cn-beijing"​
},​
"Result": {​
"OperationDetails": [​
{​
"Error": null,​
"ResourceId": "i-l8u0p77yseabkpak****"​
},​
{​
"Error": {​
"Code": "InvalidResourceId.NotFound",​
"Message": "The specified ResourceId does not exist."​
},​
"ResourceId": "i-l8u0p7xyseabkbak****"​
}​
]​
}​
}​
​
错误码​
下表为您列举了该接口与业务逻辑相关的错误码。公共错误码请参见公共错误码文档。​
​
状态码​
错误码​
错误信息​
说明​
400​
IdempotentParameterMismatch​
The request uses the same client token as a previous, but non-identical request. Do not reuse a client token with different requests, unless the requests are identical.​
幂等参数不一致。​
400​
InvalidClientToken.Malformed​
The specified ClientToken is malformed.​
指定的ClientToken不合法。​
400​
InvalidTagKey.Malformed​
The specified TagKey is malformed.​
指定的标签的键不合法。​
400​
InvalidTagValue.Malformed​
The specified TagValue is malformed.​
指定的标签的值不合法。​
400​
LimitExceeded.MaximumResourceIds​
You've reached the limit on the number of ResourceIds that you can set.​
指定的资源ID数量超过限制。​
400​
LimitExceeded.MaximumTags​
You've reached the limit on the number of tags that you can create.​
指定的标签数量超过最大限制。​
400​
MissingParameter.ResourceType​
The required parameter ResourceType is not supplied.​
参数ResourceType不能为空。​
400​
QuotaExceeded.MaximumTags​
You've reached the limit on the number of Tags that you can create.​
已达到单个资源可创建标签上限。​
404​
InvalidResourceId.NotFound​
The specified ResourceId does not exist.​
指定资源不存在。​
404​
InvalidResourceType.NotFound​
The specified ResourceType does not exist.​
指定的资源类型不存在。​
404​
InvalidTag.NotFound​
The specified tag does not exist.​
指定的键值不存在。​
409​
InvalidTagKey.Conflict​
The specified TagKey already exists.​
指定的标签键已存在。​
412​
IdempotentProcessing​
The request uses the same client token as a previous one that is still in process.​
先前的幂等请求仍在处理中,请稍后重试。​
500​
InternalError​
An internal error has occurred.​
内部错误,请重试。如果多次尝试失败,请提交工单。​
​
​
最近更新时间:2025.09.04 16:59:40
这个页面对您有帮助吗?
有用
有用
无用
无用