Updated on 2024-09-06 GMT+08:00

Querying Topics

Function

This API is used to query topics by page. The topics are sorted by creation time in descending order. You can specify offset and limit. If no topic has been created, an empty list is returned.

Calling Method

For details, see Calling APIs.

URI

GET /v2/{project_id}/notifications/topics

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

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

Table 2 Query Parameters

Parameter

Mandatory

Type

Description

offset

No

Integer

Specifies the offset.

If the offset is an integer greater than 0 but less than the number of resources, all resources in excess of this offset will be queried. The default offset is 0.

limit

No

Integer

Specifies the maximum number of records in each query.

The number ranges from 1 to 100 and is generally 10, 20, or 50. Specifies the number of resources returned on each page. The default number is 100.

enterprise_project_id

No

String

Specifies the enterprise project ID.

name

No

String

Specifies the name of the topic to be searched for, which must be fully matched.

fuzzy_name

No

String

Specifies the name of the topic to be searched. Fuzzy matching is used.

topic_id

No

String

Specifies the topic ID for exact search.

fuzzy_display_name

No

String

Specifies the display name of the topic to be searched. Fuzzy matching is used. The display name cannot exceed 192 bytes.

Request Parameters

Table 3 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 4 Response body parameters

Parameter

Type

Description

request_id

String

Specifies the request ID, which is unique.

topic_count

Integer

Specifies the number of returned topics. No matter what offset and limit values you have set in the request, this API always returns the total number of topics in your account.

topics

Array of ListTopicsItem objects

Specifies the topic structure array.

Table 5 ListTopicsItem

Parameter

Type

Description

topic_urn

String

Specifies the resource identifier of the topic, which is unique.

name

String

Specifies the topic name.

display_name

String

Specifies the topic display name, which is presented as the name of the email sender in email messages.

push_policy

Integer

Specifies the message push policy. 0 indicates that the message sending fails and the message is cached in the queue. 1 indicates that the failed message is discarded.

enterprise_project_id

String

Specifies the enterprise project ID.

topic_id

String

Specifies the topic ID.

Status code: 400

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.

Status code: 403

Table 7 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 8 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 9 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

Querying topics

GET https://{SMN_Endpoint}/v2/{project_id}/notifications/topics?offset=0&limit=100

null

Example Responses

Status code: 200

OK

{
  "request_id" : "6a63a18b8bab40ffb71ebd9cb80d0085",
  "topic_count" : 1,
  "topics" : [ {
    "topic_urn" : "urn:smn:regionId:8bad8a40e0f7462f8c1676e3f93a8183:test_topic_v2",
    "display_name" : "testtest",
    "name" : "test_topic_v1",
    "push_policy" : 0,
    "enterprise_project_id" : "0",
    "topic_id" : "84698185946d44d08431aa441d8e2cf2"
  } ]
}

Status Codes

Status Code

Description

200

OK

400

Bad Request

403

Unauthorized

404

Not Found

500

Internal Server Error

Error Codes

See Error Codes.