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

Querying a Message Template

Function

This API is used to query details about a single message notification template, including its name, content, and creation time. The query provides precise data support for template management.

Calling Method

For details, see Calling APIs.

URI

GET /v2/{project_id}/{domain_id}/lts/events/notification/template/{template_name}

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Definition

Project ID. It can be obtained by calling an API or from the console. For details, see Obtaining a Project ID.

Constraints

N/A

Range

N/A

Default Value

N/A

domain_id

Yes

String

Definition

Account ID. For details about how to obtain it, see Obtaining an Account ID.

Constraints

N/A

Range

N/A

Default Value

N/A

template_name

Yes

String

Definition

Name of the message template to be obtained.

Constraints

N/A

Range

N/A

Default Value

N/A

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

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 4 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 5 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 a message template with a specified name.

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

/v2/{project_id}/{domain_id}/lts/events/notification/template/{template_name}

Example Responses

Status code: 200

The request is successful.

{
  "create_time" : 1702955600631,
  "desc" : "description",
  "locale" : "zh-cn",
  "modify_time" : 1702955600631,
  "name" : "postman-test",
  "project_id" : "2a473356cca5487f8373be891bffc1cf",
  "source" : "LTS",
  "templates" : [ {
    "content" : "Severity: ${event_severity};\nOccurred: ${starts_at};\nResource ID: ${resources};\nStatistical type: by keyword;\nExpression: $event.annotations.condition_expression;\nCurrent value: $event.annotations.current_value;\nStatistical period: $event.annotations.frequency;",
    "sub_type" : "sms"
  }, {
    "content" : "Severity: ${event_severity};\nOccurred: ${starts_at};\nResource ID: ${resources};\nStatistical type: by keyword;\nExpression: $event.annotations.condition_expression;\nCurrent value: $event.annotations.current_value;\nStatistical period: $event.annotations.frequency;",
    "sub_type" : "dingding"
  }, {
    "content" : "Severity: ${event_severity};\nOccurred: ${starts_at};\nResource ID: ${resources};\nStatistical type: by keyword;\nExpression: $event.annotations.condition_expression;\nCurrent value: $event.annotations.current_value;\nStatistical period: $event.annotations.frequency;",
    "sub_type" : "wechat"
  }, {
    "content" : "Severity: ${event_severity};\nOccurred: ${starts_at};\nResource ID: ${resources};\nStatistical type: by keyword;\nExpression: $event.annotations.condition_expression;\nCurrent value: $event.annotations.current_value;\nStatistical period: $event.annotations.frequency;",
    "sub_type" : "webhook"
  }, {
    "content" : "Severity: ${event_severity};\nOccurred: ${starts_at};\nAlarm source: $event.metadata.resource_provider;\nResource type: $event.metadata.resource_type;\nResource ID: ${resources};\nStatistical type: by keyword;\nExpression: $event.annotations.condition_expression;\nCurrent value: $event.annotations.current_value;\nStatistical period: $event.annotations.frequency;\nQuery time: $event.annotations.results[0].time;\nQuery log: $event.annotations.results[0].raw_results;",
    "sub_type" : "email"
  }, {
    "content" : "Severity: ${event_severity};\nOccurred: ${starts_at};\nResource ID: ${resources};\nStatistical type: by keyword;\nExpression: $event.annotations.condition_expression;\nCurrent value: $event.annotations.current_value;\nStatistical period: $event.annotations.frequency;",
    "sub_type" : "voice"
  } ],
  "type" : [ ]
}

Status code: 500

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

{
  "error_code" : "LTS.2018",
  "error_msg" : "Failed to get notification template."
}

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.