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
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
project_id |
Yes |
String |
Specifies the project ID. |
Request Parameters
|
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). |
|
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:
|
|
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
|
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
|
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
|
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
|
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
|
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.
Last Article: Template Operations
Next Article: Modifying a Message Template
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.