Help Center> Simple Message Notification> API Reference> APIs> Subscription Operations> Querying Subscriptions of a Specified Topic

Querying Subscriptions of a Specified Topic

Function

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

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.

See Obtaining a 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 value is an integer greater than 0 but less than the number of resources, all resources after this offset will be queried.

Default value: 0

limit

No

Integer

Specifies the maximum number of records in each query.

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

Default value: 100

Request Parameters

Table 3 Request header parameter

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Specifies the user token.

It can be obtained by calling the IAM API (value of X-Subject-Token in the response header).

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 address.
  • sms: The endpoints are phone numbers.
  • functionstage: The endpoints are FunctionGraph 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.

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 subscriptions of a specified topic

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
  }, {
    "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@xx.com",
    "remark" : "",
    "status" : 0
  } ]
}

Status Codes

Status Code

Description

200

OK

400

Bad Request

403

Unauthorized

404

Not Found

500

Internal Server Error

Error Codes

See Error Codes.