Creating Tags in Batches
Function
This API is used to add tags to multiple resources of a cloud service. A maximum of 10 tags can be added to one resource. A maximum of 50 resources can be tagged at a time.
Calling Method
For details, see Calling APIs.
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, no identity policy-based permission required for calling this API.
 
URI
POST /v1.0/resource-tags/batch-create
Request Parameters
| 
        Parameter  | 
      
        Mandatory  | 
      
        Type  | 
      
        Description  | 
     
|---|---|---|---|
| 
        X-Auth-Token  | 
      
        Yes  | 
      
        String  | 
      
        Specifies the user token. TMS is a global service. When calling the Identity and Access Management (IAM) API to obtain a user token, set the scope field to domain. The value of X-Subject-Token in the response header is the user token.  | 
     
| 
        Parameter  | 
      
        Mandatory  | 
      
        Type  | 
      
        Description  | 
     
|---|---|---|---|
| 
        project_id  | 
      
        No  | 
      
        String  | 
      
        Specifies the project ID. This parameter is mandatory when resource_type is a region-specific service.  | 
     
| 
        resources  | 
      
        Yes  | 
      
        Array of ResourceTagBody objects  | 
      
        Specifies the resource list.  | 
     
| 
        tags  | 
      
        Yes  | 
      
        Array of CreateTagRequest objects  | 
      
        Specifies tags.  | 
     
| 
        Parameter  | 
      
        Mandatory  | 
      
        Type  | 
      
        Description  | 
     
|---|---|---|---|
| 
        resource_id  | 
      
        Yes  | 
      
        String  | 
      
        Specifies the resource ID.  | 
     
| 
        resource_type  | 
      
        Yes  | 
      
        String  | 
      
        Specifies the resource type. This parameter is case-sensitive. Examples include: ecs, scaling_group, images, disk,vpcs, security-groups, shared_bandwidth, eip, and cdn. For more details, see "Querying Service Supported by TMS".  | 
     
| 
        Parameter  | 
      
        Mandatory  | 
      
        Type  | 
      
        Description  | 
     
|---|---|---|---|
| 
        key  | 
      
        Yes  | 
      
        String  | 
      
        Specifies the tag key. The value can contain up to 36 characters including letters, digits, hyphens (-), and underscores (_).  | 
     
| 
        value  | 
      
        Yes  | 
      
        String  | 
      
        Specifies the tag value. The value can contain up to 43 characters including letters, digits, periods (.), hyphens (-), and underscores (_). It can be an empty string.  | 
     
Response Parameters
Status code: 200
| 
        Parameter  | 
      
        Type  | 
      
        Description  | 
     
|---|---|---|
| 
        failed_resources  | 
      
        Array of TagCreateResponseItem objects  | 
      
        Specifies the information about resources failed to be tagged.  | 
     
| 
        Parameter  | 
      
        Type  | 
      
        Description  | 
     
|---|---|---|
| 
        resource_id  | 
      
        String  | 
      
        Specifies the resource ID.  | 
     
| 
        resource_type  | 
      
        String  | 
      
        Specifies the resource type.  | 
     
| 
        error_code  | 
      
        String  | 
      
        Specifies the error code.  | 
     
| 
        error_msg  | 
      
        String  | 
      
        Specifies the error message.  | 
     
Status code: 400
| 
        Parameter  | 
      
        Type  | 
      
        Description  | 
     
|---|---|---|
| 
        error  | 
      
        RespErrorMessage object  | 
      
        Response error information.  | 
     
| 
        Parameter  | 
      
        Type  | 
      
        Description  | 
     
|---|---|---|
| 
        error_code  | 
      
        String  | 
      
        Request error code  | 
     
| 
        error_msg  | 
      
        String  | 
      
        Error message  | 
     
Status code: 401
| 
        Parameter  | 
      
        Type  | 
      
        Description  | 
     
|---|---|---|
| 
        error  | 
      
        RespErrorMessage object  | 
      
        Response error information.  | 
     
| 
        Parameter  | 
      
        Type  | 
      
        Description  | 
     
|---|---|---|
| 
        error_code  | 
      
        String  | 
      
        Request error code  | 
     
| 
        error_msg  | 
      
        String  | 
      
        Error message  | 
     
Status code: 403
| 
        Parameter  | 
      
        Type  | 
      
        Description  | 
     
|---|---|---|
| 
        error  | 
      
        RespErrorMessage object  | 
      
        Response error information.  | 
     
| 
        Parameter  | 
      
        Type  | 
      
        Description  | 
     
|---|---|---|
| 
        error_code  | 
      
        String  | 
      
        Request error code  | 
     
| 
        error_msg  | 
      
        String  | 
      
        Error message  | 
     
Status code: 404
| 
        Parameter  | 
      
        Type  | 
      
        Description  | 
     
|---|---|---|
| 
        error  | 
      
        RespErrorMessage object  | 
      
        Response error information.  | 
     
| 
        Parameter  | 
      
        Type  | 
      
        Description  | 
     
|---|---|---|
| 
        error_code  | 
      
        String  | 
      
        Request error code  | 
     
| 
        error_msg  | 
      
        String  | 
      
        Error message  | 
     
Status code: 405
| 
        Parameter  | 
      
        Type  | 
      
        Description  | 
     
|---|---|---|
| 
        error  | 
      
        RespErrorMessage object  | 
      
        Response error information.  | 
     
| 
        Parameter  | 
      
        Type  | 
      
        Description  | 
     
|---|---|---|
| 
        error_code  | 
      
        String  | 
      
        Request error code  | 
     
| 
        error_msg  | 
      
        String  | 
      
        Error message  | 
     
Status code: 406
| 
        Parameter  | 
      
        Type  | 
      
        Description  | 
     
|---|---|---|
| 
        error  | 
      
        RespErrorMessage object  | 
      
        Response error information.  | 
     
| 
        Parameter  | 
      
        Type  | 
      
        Description  | 
     
|---|---|---|
| 
        error_code  | 
      
        String  | 
      
        Request error code  | 
     
| 
        error_msg  | 
      
        String  | 
      
        Error message  | 
     
Status code: 409
| 
        Parameter  | 
      
        Type  | 
      
        Description  | 
     
|---|---|---|
| 
        error  | 
      
        RespErrorMessage object  | 
      
        Response error information.  | 
     
| 
        Parameter  | 
      
        Type  | 
      
        Description  | 
     
|---|---|---|
| 
        error_code  | 
      
        String  | 
      
        Request error code  | 
     
| 
        error_msg  | 
      
        String  | 
      
        Error message  | 
     
Status code: 410
| 
        Parameter  | 
      
        Type  | 
      
        Description  | 
     
|---|---|---|
| 
        error  | 
      
        RespErrorMessage object  | 
      
        Response error information.  | 
     
| 
        Parameter  | 
      
        Type  | 
      
        Description  | 
     
|---|---|---|
| 
        error_code  | 
      
        String  | 
      
        Request error code  | 
     
| 
        error_msg  | 
      
        String  | 
      
        Error message  | 
     
Status code: 412
| 
        Parameter  | 
      
        Type  | 
      
        Description  | 
     
|---|---|---|
| 
        error  | 
      
        RespErrorMessage object  | 
      
        Response error information.  | 
     
| 
        Parameter  | 
      
        Type  | 
      
        Description  | 
     
|---|---|---|
| 
        error_code  | 
      
        String  | 
      
        Request error code  | 
     
| 
        error_msg  | 
      
        String  | 
      
        Error message  | 
     
Status code: 429
| 
        Parameter  | 
      
        Type  | 
      
        Description  | 
     
|---|---|---|
| 
        error  | 
      
        RespErrorMessage object  | 
      
        Response error information.  | 
     
| 
        Parameter  | 
      
        Type  | 
      
        Description  | 
     
|---|---|---|
| 
        error_code  | 
      
        String  | 
      
        Request error code  | 
     
| 
        error_msg  | 
      
        String  | 
      
        Error message  | 
     
Status code: 500
| 
        Parameter  | 
      
        Type  | 
      
        Description  | 
     
|---|---|---|
| 
        error  | 
      
        RespErrorMessage object  | 
      
        Response error information.  | 
     
| 
        Parameter  | 
      
        Type  | 
      
        Description  | 
     
|---|---|---|
| 
        error_code  | 
      
        String  | 
      
        Request error code  | 
     
| 
        error_msg  | 
      
        String  | 
      
        Error message  | 
     
Status code: 501
| 
        Parameter  | 
      
        Type  | 
      
        Description  | 
     
|---|---|---|
| 
        error  | 
      
        RespErrorMessage object  | 
      
        Response error information.  | 
     
| 
        Parameter  | 
      
        Type  | 
      
        Description  | 
     
|---|---|---|
| 
        error_code  | 
      
        String  | 
      
        Request error code  | 
     
| 
        error_msg  | 
      
        String  | 
      
        Error message  | 
     
Status code: 503
| 
        Parameter  | 
      
        Type  | 
      
        Description  | 
     
|---|---|---|
| 
        error  | 
      
        RespErrorMessage object  | 
      
        Response error information.  | 
     
Example Requests
Adding tags to a resource in batches
POST https://{Endpoint}/v1.0/resource-tags/batch-create
{
  "project_id" : "xxxdcffffffff",
  "resources" : [ {
    "resource_id" : "a28531fa-a8d5-468e-8417-86a80962ee5e",
    "resource_type" : "disk"
  }, {
    "resource_id" : "a28531fa-a8d5-468e-8417-86a8096ddddd",
    "resource_type" : "vpc"
  } ],
  "tags" : [ {
    "key" : "ENV",
    "value" : "dev"
  }, {
    "key" : "DEPT",
    "value" : "pdd"
  } ]
}
 Example Responses
Status code: 200
Success
{
  "failed_resources" : [ {
    "resource_id" : "e1eb7c40cbea4c8389cde527594a306d",
    "resource_type" : "disk",
    "error_code" : "TMS.0002",
    "error_msg" : "Bad request"
  } ]
}
 Status Codes
| 
        Status Code  | 
      
        Description  | 
     
|---|---|
| 
        200  | 
      
        Success  | 
     
| 
        400  | 
      
        Bad Request  | 
     
| 
        401  | 
      
        Unauthorized  | 
     
| 
        403  | 
      
        Forbidden  | 
     
| 
        404  | 
      
        Not Found  | 
     
| 
        405  | 
      
        Method Not Allowed  | 
     
| 
        406  | 
      
        Not Acceptable  | 
     
| 
        409  | 
      
        Conflict  | 
     
| 
        410  | 
      
        Gone  | 
     
| 
        412  | 
      
        Precondition Failed  | 
     
| 
        429  | 
      
        Too Many Requests  | 
     
| 
        500  | 
      
        Internal Server Error  | 
     
| 
        501  | 
      
        Not Implemented  | 
     
| 
        503  | 
      
        Service Unavailable  | 
     
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.