Help Center/ Simple Message Notification/ API Reference/ APIs/ Subscriptions/ Querying Subscriptions of a Specified Topic
Updated on 2024-09-06 GMT+08:00

Querying Subscriptions of a Specified Topic

Function

This API is used to query subscriptions to a specified topic by page. The list is sorted by subscription adding time in ascending order. You can specify offset and limit. If no subscription has been added to the topic, an empty list is returned.

Calling Method

For details, see Calling APIs.

URI

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

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.

topic_urn

Yes

String

Specifies the resource identifier of the topic, which is unique. To obtain the resource identifier, see Querying Topics.

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.

fuzzy_remark

No

String

Specifies the subscription remark for fuzzy match. The value can contain up to 128 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.

subscription_count

Integer

Specifies the number of subscriptions.

subscriptions

Array of ListSubscriptionsItem objects

Specifies the subscription structure.

Table 5 ListSubscriptionsItem

Parameter

Type

Description

topic_urn

String

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

protocol

String

Specifies the subscription protocol. (Different protocols indicate different types of endpoints to receive messages.) The following protocols are supported:

default

email: The endpoints are email addresses.

sms: The endpoints are phone numbers.

functionstage: FunctionGraph (function) transmission protocol. The endpoints are functions.

http and https: The endpoints are URLs.

subscription_urn

String

Specifies the resource identifier of a subscription, which is unique.

owner

String

Specifies the project ID of the topic creator.

endpoint

String

Specifies the message receiving endpoint.

remark

String

Specifies the remarks.

status

Integer

0 indicates that the subscription is not confirmed. 1 indicates that the subscription is confirmed. 3 indicates that the subscription is canceled.

filter_polices

Array of SubscriptionsFilterPolicy objects

Specifies the filter policy.

Table 6 SubscriptionsFilterPolicy

Parameter

Type

Description

name

String

Specifies the filter policy name.

name can contain 1 to 32 characters, including lowercase letters, digits, and underscores (). name cannot start or end with an underscore, nor contain consecutive underscores. name cannot start with **smn**.

string_equals

Array of strings

Specifies the string array for exact match. An array can contain 1 to 10 strings. The array content must be unique. The string cannot be null or an empty string "". A string can contain 1 to 32 characters, including letters, digits, and underscores (_).

Status code: 400

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

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

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.

Status code: 500

Table 10 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 subscriptions of the topic named test_topic_v2

GET https://{SMN_Endpoint}/v2/{project_id}/notifications/topics/urn:smn:regionId:762bdb3251034f268af0e395c53ea09b:test_topic_v1/subscriptions?offset=0&limit=100

null

Example Responses

Status code: 200

OK

{
  "request_id" : "6a63a18b8bab40ffb71ebd9cb80d0085",
  "subscription_count" : 2,
  "subscriptions" : [ {
    "topic_urn" : "urn:smn:regionId:762bdb3251034f268af0e395c53ea09b:test_topic_v1",
    "protocol" : "sms",
    "subscription_urn" : "urn:smn:regionId:762bdb3251034f268af0e395c53ea09b:test_topic_v1:2e778e84408e44058e6cbc6d3c377837",
    "owner" : "762bdb3251034f268af0e395c53ea09b",
    "endpoint" : "xxxxxxxxxxx",
    "remark" : "",
    "status" : 0,
    "filter_polices" : [ {
      "name" : "alarm",
      "string_equals" : [ "os", "process" ]
    }, {
      "name" : "service",
      "string_equals" : [ "api", "db" ]
    } ]
  }, {
    "topic_urn" : "urn:smn:regionId:762bdb3251034f268af0e395c53ea09b:test_topic_v1",
    "protocol" : "email",
    "subscription_urn" : "urn:smn:regionId:762bdb3251034f268af0e395c53ea09b:test_topic_v1:a2d52a9f5c3b47f48c3fafb177a58796",
    "owner" : "762bdb3251034f268af0e395c53ea09b",
    "endpoint" : "xx@example.com",
    "remark" : "",
    "status" : 0,
    "filter_polices" : [ {
      "name" : "alarm",
      "string_equals" : [ "os", "process" ]
    }, {
      "name" : "service",
      "string_equals" : [ "api", "db" ]
    } ]
  } ]
}

Status Codes

Status Code

Description

200

OK

400

Bad Request

403

Unauthorized

404

Not Found

500

Internal Server Error

Error Codes

See Error Codes.