Updated on 2025-08-21 GMT+08:00

Querying Message Templates

Function

This API is used to query the message template list.

Calling Method

For details, see Calling APIs.

URI

GET /v2/{project_id}/{domain_id}/lts/events/notification/templates

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID. For details about how to obtain a project ID, see Obtaining the Project ID, Account ID, Log Group ID, and Log Stream ID.

Minimum: 32

Maximum: 32

domain_id

Yes

String

Account ID. For details about how to obtain an account ID, see Obtaining the Project ID, Account ID, Log Group ID, and Log Stream ID.

Minimum: 32

Maximum: 32

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Definition

User token obtained from IAM. For details about how to obtain it, see Obtaining a User Token.

Constraints

N/A

Range

N/A

Default Value

N/A

Content-Type

Yes

String

Definition

Message body format. Set this parameter to application/json;charset=utf8.

Constraints

N/A

Range

N/A

Default Value

N/A

Response Parameters

Status code: 200

Table 3 Response body parameters

Parameter

Type

Description

results

Array of NotificationTemplate objects

Template array.

Table 4 NotificationTemplate

Parameter

Type

Description

name

String

Definition

Message template name.

Range

N/A

type

Array of strings

Definition

Notification method.

Range

  • sms

  • dingding

  • wechat

  • webhook

  • email

  • voice

  • feishu

  • welink

desc

String

Definition

Message template description.

Range

N/A

source

String

Definition

Message template source.

Range

N/A

templates

Array of SubTemplateResBody objects

Definition

Details about the message template of different notification channels.

locale

String

Definition

Message header language. A default header, such as "Dear customer," will be added to the beginning of all messages in the language you select.

Range

  • zh-cn

  • en-us

create_time

Long

Definition

Time when the message template was created (timestamp in milliseconds).

Range

N/A

modify_time

Long

Definition

Time when the message template was last updated (timestamp in milliseconds).

Range

N/A

project_id

String

Definition

Project ID.

Range

N/A

Table 5 SubTemplateResBody

Parameter

Type

Description

sub_type

String

Definition

Notification channel of the message template.

Range

  • sms

  • dingding

  • wechat

  • webhook

  • email

  • voice

  • feishu

  • welink

content

String

Definition

Message template body of the corresponding notification channel. A variable following a dollar sign ($) can only be one of the following variables. The supported variables vary according to alarm rule types (keyword or SQL). Currently, the two alarm rule types have the following common variables:

Alarm severity: ${event_severity};

Occurrence time: ${starts_at};

Alarm source: $event.metadata.resource_provider;

Resource type: $event.metadata.resource_type;

Resource ID: ${resources};

Statistical type: by keyword;

Expression: $event.annotations.condition_expression;

Current value: $event.annotations.current_value;

Statistical period: $event.annotations.frequency;

Variables specific to keyword alarms:

Query time: $event.annotations.results[0].time;

Query log: $event.annotations.results[0].raw_results;

Variables specific to SQL alarms:

Log group/stream name: $event.annotations.results[0].resource_id;

Query statement: $event.annotations.results[0].sql;

Query time: $event.annotations.results[0].time;

Query URL: $event.annotations.results[0].url;

Query log: $event.annotations.results[0].raw_results;

Alarm severity: ${event_severity};

Occurrence time: ${starts_at};

Alarm source: $event.metadata.resource_provider;

Resource type: $event.metadata.resource_type;

Resource ID: ${resources};

Statistical type: by keyword;

Expression: $event.annotations.condition_expression;

Current value: $event.annotations.current_value;

Statistical period: $event.annotations.frequency;

Variables specific to keyword alarms:

Query time: $event.annotations.results[0].time;

Query log: $event.annotations.results[0].raw_results;

Variables specific to SQL alarms:

Log group/stream name: $event.annotations.results[0].resource_id;

Query statement: $event.annotations.results[0].sql;

Query time: $event.annotations.results[0].time;

Query URL: $event.annotations.results[0].url;

Query log: $event.annotations.results[0].raw_results;

NOTE:
Each variable must be followed by an English semicolon (;). Otherwise, the template replacement fails.

Range

N/A

topic

String

Definition

Email subject. This field is valid when sub_type (notification channel) is set to email.

Range

N/A

sendType

String

Definition

Rendering mode of the message. This field is valid only when the message template type is webhook.

Range

  • HTML

  • JSON

version

String

Definition

Applicable version of the message template.

Range

v1: indicates the LTS message template.

Status code: 500

Table 6 Response body parameters

Parameter

Type

Description

error_code

String

Definition

Error code. For details, see Error Codes.

Range

N/A

error_msg

String

Definition

Error message.

Range

N/A

Example Requests

Query the message template list.

GET https://{endpoint}/v2/{project_id}/{domain_id}/lts/events/notification/templates

/v2/{project_id}/{domain_id}/lts/events/notification/templates

Example Responses

Status code: 200

The request is successful.

{
  "results" : [ {
    "create_time" : 1701352010150,
    "desc" : "This is the SMS test mode.",
    "locale" : "zh-cn",
    "modify_time" : 1701352010150,
    "name" : "15nWzUsOHA",
    "project_id" : "2a473356cca5487f8373be891bffc1cf",
    "source" : "LTS",
    "templates" : [ {
      "content" : "\"This is an SMS test template.\"",
      "sub_type" : "sms"
    } ],
    "type" : [ "" ]
  }, {
    "create_time" : 1702021411612,
    "desc" : "This is the SMS test mode.",
    "locale" : "zh-cn",
    "modify_time" : 1702021411612,
    "name" : "RZ2ObeluNN",
    "project_id" : "2a473356cca5487f8373be891bffc1cf",
    "source" : "LTS",
    "templates" : [ {
      "content" : "\"This is an SMS test template.\"",
      "sub_type" : "sms"
    } ],
    "type" : [ "" ]
  } ]
}

Status code: 500

The server has received the request but encountered an internal error.

{
  "error_code" : "LTS.2017",
  "error_msg" : "Find Alarm rule failed."
}

Status Codes

Status Code

Description

200

The request is successful.

500

The server has received the request but encountered an internal error.

Error Codes

See Error Codes.