Updated on 2023-10-19 GMT+08:00

Creating an SMS Template

Function

This API is used to create a template.

URI

POST /v2/{project_id}/msgsms/templates

Table 1 URI parameter

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID. For details, see Obtaining Account, User, and Project Information.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

Content-Type

Yes

String

Request body parameter type. This parameter must be set to application/json.

X-Auth-Token

Yes

String

User token. It can be obtained by calling the IAM API used to obtain a user token. The value of X-Subject-Token in the response header is a token.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

app_id

Yes

String

Primary key ID of the application. For details, see id in Table 5.

brackets

No

String

Bracket type. Enumerated values:

  • CN: Chinese brackets
  • GB: English brackets ([])
    NOTICE:
    • Default value: CN
    • If the entered value is not within the preceding enumerated value range, the value is processed as CN.
    • This parameter is valid only when region is set to cn.

region

Yes

String

Region.

  • cn: Chinese mainland
  • intl: international

send_country

No

Array of integers

List of IDs of countries or regions to which SMSs are sent. It can be obtained from Table 4. This parameter is mandatory when region is set to intl.

sign_id

No

String

Primary key ID of the signature. For details, see id in Table 5. This parameter is valid only when region is set to cn.

template_content

Yes

String

Template content. Read Template and Variable Specifications and Sample Template carefully before configuring this parameter.

template_desc

No

String

Template description.

template_name

Yes

String

Template name.

template_type

Yes

String

Template type. This parameter is valid only when region is set to cn. Enumerated values:

  • VERIFY_CODE_TYPE: verification code
  • NOTIFY_TYPE: notification

    For international SMSs, the value is fixed to NOTIFY_TYPE.

universal_template

No

Integer

Whether the template is a general template.

  • 0: non-general template
  • 1: general template

Response Parameters

Table 4 Response body parameters

Parameter

Type

Description

id

String

Primary key ID of the template.

template_name

String

Template name.

Request Example

POST /v2/845ada5bc7444f1295cd517af0123da1/msgsms/templates 
Host: 100.85.***.***:30300
Content-Type: application/json
X-Auth-Token: ****
Content-Length: 308
 
{
    "app_id": "******9c-1a6b-4ee5-9651-5bca450694b3",
    "brackets": "GB",
    "region": "cn",
    "sign_id": "******10-c3fb-427e-965c-a98ae844c5bd",
    "template_content": "Test",
    "template_name": "auto_test789",
    "template_type": "NOTIFY_TYPE",
    "universal_template": 0
}

Response Example

{
    "id": "******27-37eb-4229-bee9-0eba4d8a897f",
    "template_name": "auto_test789"
}

Returned Values

Status Code

Description

200

OK

201

Created

401

Unauthorized

403

Forbidden

404

Not Found

500

System error