Creating a Message Template

Function

This API is used to create a message template for quick message sending and reduced request data volume. By default, a user can create a maximum of 100 message templates. However, in a high-concurrency scenario, which is rare, extra templates may be successfully created.

URI

POST /v2/{project_id}/notifications/message_template

Table 1 Path parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Specifies the project ID.

See Obtaining a Project ID.

Request Parameters

Table 2 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).

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

message_template_name

Yes

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

Yes

String

Specifies the protocol supported by the template.

The following protocols are supported:

  • default
  • email
  • sms
  • functionstage (FunctionGraph function)
  • dms
  • http and https

content

Yes

String

Specifies the template content, which supports plain text only. The template content cannot be left blank or larger than 256 KB.

Response Parameters

Status code: 201

Table 4 Response body parameters

Parameter

Type

Description

request_id

String

Specifies the request ID, which is unique.

message_template_id

String

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

Status code: 400

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

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

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.

Example Requests

Creating a message template

POST https://{SMN_Endpoint}/v2/{project_id}/notifications/message_template

{
  "message_template_name" : "confirm_message",
  "protocol" : "https",
  "content" : "(1/2)You are invited to subscribe to topic({topic_id}). Click the following URL to confirm subscription:(If you do not want to subscribe to this topic, ignore this message.)"
}

Example Responses

Status code: 201

OK

{
  "request_id" : "6a63a18b8bab40ffb71ebd9cb80d0085",
  "message_template_id" : "57ba8dcecda844878c5dd5815b65d10f"
}

Status Codes

Status Code

Description

201

OK

400

Bad Request

403

Unauthorized

404

Not Found

500

Internal Server Error

Error Codes

See Error Codes.