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

Querying the KMS Key Bound to a Topic

Function

This API is used to query the ID of the key bound to a topic. Before binding 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 key information.

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:getKmsKey

    List

    topic *

    • g:EnterpriseProjectId

    • g:ResourceTag/<tag-key>

    -

    smn:topic:get

URI

GET /v2/{project_id}/notifications/topics/{topic_urn}/kms

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

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

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Specifies a user token.

It can be obtained by calling an IAM API. The value of X-Subject-Token in the response header is the user token.

Response Parameters

Status code: 200

Table 3 Response body parameters

Parameter

Type

Description

key_id

String

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

status

String

The key status. Options:

  • ENABLED: The key is enabled. All published messages are encrypted and decrypted using the data key generated by the master key.

  • TO_BE_ACTIVATED: The key is to be activated. If the key is not activated, a failure message will be returned when messages are published. Go to DEW to activate the key.

  • DISABLED: The key is disabled. If the key is disabled, a failure message will be returned when messages are published. Go to DEW to enable the key.

  • PENDING_DELETION: The key is to be deleted. If the key is to be deleted, the key can still be used when messages are published.

  • PENDING_IMPORT: The key is to be imported. If the key is to be imported, a failure message will be returned when messages are published. Go to DEW to import the key.

  • DELETED: The key has been deleted. If the key has been deleted, SMN cannot obtain a valid key from DEW. In this case, a failure message will be returned when messages are published. Configure an available key for the topic.

id

String

The resource ID corresponding to the key. It is generated by SMN.

request_id

String

Specifies the request ID, which is unique.

Status code: 403

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: 404

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.

Status code: 500

Table 6 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_05721ee8904211f0871f84a93e8ae4b6/kms

Example Responses

Status code: 200

Response body returned when the request succeeded.

{
  "key_id" : "9a618041-a917-49e0-bb3a-1a90163e97fe",
  "status" : "ENABLED",
  "id" : "d39453da9d6c4026ba0bb3ed1a6efc2d",
  "request_id" : "c16810962f1140da82abcd9e783cf4e2"
}

Status code: 403

Forbidden

{
  "request_id" : "c7da9c96193c4017b6d2250477107416",
  "code" : "SMN.0001",
  "message" : "No permission to request resources."
}

Status code: 404

Not Found

{
  "request_id" : "135be5478b594200be295f6603f223bd",
  "error_code" : "SMN.00010008",
  "error_msg" : "Topic information is not found."
}

Status Codes

Status Code

Description

200

Response body returned when the request succeeded.

403

Forbidden

404

Not Found

500

Internal Server Error

Error Codes

See Error Codes.