Help Center/ Simple Message Notification/ API Reference/ APIs/ Key Management/ Updating the KMS Key Bound to a Topic
Updated on 2025-11-21 GMT+08:00

Updating the KMS Key Bound to a Topic

Function

This API is used to update the key ID. Before updating a KMS key, create an agency named smn_kms_agency on IAM and assign resource operation permissions to SMN. SMN uses this agency to query the key status and create a data key.

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, the following identity policy-based permissions are required.

    Action

    Access Level

    Resource Type (*: required)

    Condition Key

    Alias

    Dependencies

    smn:topic:updateKmsKey

    Write

    topic *

    • g:EnterpriseProjectId

    • g:ResourceTag/<tag-key>

    -

    • smn:topic:get
    • smn:topic:getKmsKey

URI

PUT /v2/{project_id}/notifications/topics/{topic_urn}/kms/{id}

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

The project ID. For details about how to obtain the project ID, see Obtaining a Project ID.

topic_urn

Yes

String

Unique resource identifier of a topic. To obtain the resource identifier, see Querying Topics.

id

Yes

String

The ID of the resource that has been bound to the key.

Request Parameters

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

key_id

Yes

String

The ID of the customer master key created on DEW. For details, see Creating a Key.

Response Parameters

Status code: 200

Table 3 Response body parameters

Parameter

Type

Description

request_id

String

The unique request ID.

id

String

The unique ID of the key bound to the topic. It is automatically generated by SMN.

Status code: 400

Table 4 Response body parameters

Parameter

Type

Description

request_id

String

Specifies the request ID, which is unique.

code

String

Specifies the error code.

message

String

Describes the error message.

Status code: 401

Table 5 Response body parameters

Parameter

Type

Description

request_id

String

Specifies the request ID, which is unique.

code

String

Specifies the error code.

message

String

Describes the error message.

Example Requests

Example for a successful request

https://{SMN_Endpoint}/v2/{project_id}/notifications/topics/urn:smn:regionId:44ef0bd78eb24f02b40614fe85a7d234:topic_34176907904211f0bfc684a93e8ae4b6/kms/108484454fd34af5b10bd3ef7ee35e0f

{
  "key_id" : "99a5ca7c-56f4-48c3-a92e-e9a517d3d7de"
}

Example Responses

Status code: 200

Response body returned when the request succeeded.

{
  "request_id" : "169f9f6efc6d4da09dd106da6038d954",
  "id" : "9a719209230d4ce19058c1ef10011d7b"
}

Status code: 400

Bad Request

{
  "request_id" : "cfe44dcb8ebc4cf48fe704be08375bcc",
  "error_code" : "SMN.00013064",
  "error_msg" : "The kms key resource id is not available."
}

Status code: 401

Unauthorized

{
  "request_id" : "c8b2f5d6891d44dca2e42c2295a9d1f9",
  "error_code" : "SMN.00000005",
  "error_msg" : "Invalid token."
}

Status Codes

Status Code

Description

200

Response body returned when the request succeeded.

400

Bad Request

401

Unauthorized

Error Codes

See Error Codes.