Updated on 2023-02-13 GMT+08:00

Querying Message Templates

Function

This API is used to query the template list by page. The list is sorted by template creation time in ascending order. You can specify offset and limit. If no template has been created, an empty list is returned. The parameters message_template_name and protocol are added.

URI

GET /v2/{project_id}/notifications/message_template

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.

Default: 0

limit

No

Integer

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.

Default: 100

message_template_name

No

String

Specifies the template name.

Enter 1 to 64 characters, and start with a letter or digit. Only letters, digits, hyphens (-), and underscores (_) are allowed.

protocol

No

String

Specifies the protocol supported by the template.

The following protocols are supported:

default

email

sms

functionstage

dms

http and https

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.

message_template_count

Integer

Specifies the number of returned templates.

message_templates

Array of MessageTemplate objects

Specifies the Message_template structure array.

Table 5 MessageTemplate

Parameter

Type

Description

message_template_id

String

Specifies the template ID.

message_template_name

String

Specifies the template name.

protocol

String

Specifies the protocol supported by the template.

The following protocols are supported:

email

sms

functionstage

dms

http and https

tag_names

Array of strings

Specifies the variable list.

create_time

String

Specifies when the template was created. The UTC time is in YYYY-MM-DDTHH:MM:SSZ format.

update_time

String

Specifies the last time when the template was updated. The UTC time is in YYYY-MM-DDTHH:MM:SSZ format.

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 message templates

GET https://{SMN_Endpoint}/v2/{project_id}/notifications/message_template?offset=0&limit=2&message_template_name=test1&protocol=email

null

Example Responses

Status code: 200

OK

{
  "request_id" : "6a63a18b8bab40ffb71ebd9cb80d0085",
  "message_template_count" : 3,
  "message_templates" : [ {
    "message_template_name" : "confirm_message",
    "protocol" : "sms",
    "update_time" : "2016-08-02T08:22:18Z",
    "create_time" : "2016-08-02T08:22:18Z",
    "tag_names" : [ "topic_urn" ],
    "message_template_id" : "79227dfdf88d4e52a1820ca1eb411635"
  }, {
    "message_template_name" : "confirm_message",
    "protocol" : "email",
    "update_time" : "2016-08-02T08:22:19Z",
    "create_time" : "2016-08-02T08:22:19Z",
    "tag_names" : [ "topic_id" ],
    "message_template_id" : "ecf63465804a4b10a0573980be78ffba"
  }, {
    "message_template_name" : "confirm_message",
    "protocol" : "https",
    "update_time" : "2016-08-02T08:22:20Z",
    "create_time" : "2016-08-02T08:22:20Z",
    "tag_names" : [ "topic_id" ],
    "message_template_id" : "57ba8dcecda844878c5dd5815b65d10f"
  } ]
}

Status Codes

Status Code

Description

200

OK

400

Bad Request

403

Unauthorized

404

Not Found

500

Internal Server Error

Error Codes

See Error Codes.