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 rare high-concurrency scenarios, extra templates may be successfully created.
Calling Method
For details, see Calling APIs.
URI
POST /v2/{project_id}/notifications/message_template
| 
        Parameter  | 
      
        Mandatory  | 
      
        Type  | 
      
        Description  | 
     
|---|---|---|---|
| 
        project_id  | 
      
        Yes  | 
      
        String  | 
      
        Specifies the project ID.For details about how to obtain the project ID, see Obtaining the Project ID.  | 
     
Request Parameters
| 
        Parameter  | 
      
        Mandatory  | 
      
        Type  | 
      
        Description  | 
     
|---|---|---|---|
| 
        X-Auth-Token  | 
      
        Yes  | 
      
        String  | 
      
        Specifies a user token. It can be obtained by calling an IAM API. The value of X-Subject-Token in the response header is the user token.  | 
     
| 
        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 sms functionstage 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
| 
        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 an HTTPS message template with the name of confirm_message
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.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.