Reviewed-by: Daniel Kováč <a86700324@noreply.gitea.eco.tsi-dev.otc-service.com> Co-authored-by: wanghuijuan738 <wanghuijuan738@huawei.com> Co-committed-by: wanghuijuan738 <wanghuijuan738@huawei.com>
12 KiB
Creating a Message Template
Description
- Function
Create a message template for quick message sending to reduce the 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.
Message templates are identified by name, but you can create different templates with the same name as long as they are configured for different protocols. You must create a Default template with the same name as each custom template. The Default template is used when no specific template has been set for a given protocol. If a template is configured for a specific protocol, any subscriber who chose that protocol during subscription will receive messages using that specific template. If you create a custom template but do not create a default template with the same name, you cannot use the custom template to publish messages.
URI
- Parameter description
Parameter
Mandatory
Type
Description
project_id
Yes
String
Project ID
Request
- Parameter description
Parameter
Mandatory
Type
Description
message_template_name
Yes
String
Template name
Enter 1 to 64 characters, and start with a letter or digit. Only letters, digits, hyphens (-), and underscores (_) are allowed.
content
Yes
String
Template content, which currently supports plain text only
The template content cannot be left blank or larger than 256 KB.
protocol
No
String
Protocol supported by the template
Currently, the following protocols are supported:
- default
- sms
- http and https
- Example request
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.)" }
Response
- Parameter description
Parameter
Type
Description
request_id
String
Request ID, which is unique
message_template_id
String
Resource identifier of the template, which is unique
- Example response
{ "request_id": "ca03efa691624d8eb2dfeba01a1bcf6e", "message_template_id": "57ba8dcecda844878c5dd5815b65d10f" }
Returned Value
See Returned Value.
Error Codes
See Error Codes.