• Simple Message Notification

smn
  1. Help Center
  2. Simple Message Notification
  3. API Reference
  4. APIs
  5. Resource Tag Operations
  6. Adding a Resource Tag

Adding a Resource Tag

Description

  • API name

    CreateResourceTag

  • Function

    You can add a maximum of 10 tags to a resource.

    The API is idempotent. If a to-be-created tag has the same key as an existing tag, the tag will be created and overwrite the existing one.

URI

  • URI format

    POST /v2/{project_id}/{resource_type}/{resource_id}/tags

  • Parameter description

    Parameter

    Mandatory

    Type

    Description

    project_id

    Yes

    String

    Project ID

    resource_type

    Yes

    String

    Resource type

    The value can be smn_topic.

    resource_id

    Yes

    String

    Resource ID

    Obtain a resource ID:

    • Add X-SMN-RESOURCEID-TYPE=name in the request header and set the resource ID to the topic name.
    • Call the GetResourceInstances API to obtain the resource ID.

Request

  • Parameter description

    Parameter

    Mandatory

    Type

    Description

    tag

    Yes

    Resource tag structure

    Resource tag to be added. For details, see section Resource Tag Structure.

  • Request example
    POST /v2/{project_id}/{resource_type}/{resource_id}/tags
  • Example request
    {
         "tag":
         {
            "key":"DEV",
            "value":"DEV1"
         }
    }

Response

None

Returned Value

  • Normal

    Returned Value

    Description

    204

    No Content

  • Abnormal

    Returned Value

    Description

    400 Bad Request

    Incorrect request parameters.

    401 Unauthorized

    Authentication failed.

    403 Forbidden

    No permission to access the requested resource.

    404 Not Found

    The requested resource does not exist.

    500 Internal Server Error

    Request failed because the server is abnormal.

Error Code

See section Error Code.