tencent cloud



最后更新时间:2024-05-20 17:52:50

    1. API Description

    Domain name for API request: sms.tencentcloudapi.com.

    1. This API is used to add an SMS template. You need to read the Tencent Cloud SMS Body Template Review Standards before starting an application.
    2. Note: individual users cannot use this API to apply for SMS body templates. For more information, see Identity Verification Overview. If your account identity is individual, you can log in to the console to apply for SMS body templates.
      • Note: because of the improved security of TencentCloud API 3.0, API authentication is more complicated. We recommend you use the Tencent Cloud SMS service with the SDK.
      • You can run this API directly in API 3.0 Explorer, which eliminates the signature calculation steps. After it is executed successfully, API Explorer can automatically generate SDK code samples.

    A maximum of 2 requests can be initiated per second for this API.

    We recommend you to use API Explorer
    Try it
    API Explorer provides a range of capabilities, including online call, signature authentication, SDK code generation, and API quick search. It enables you to view the request, response, and auto-generated examples.

    2. Input Parameters

    The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.

    Parameter Name Required Type Description
    Action Yes String Common Params. The value used for this API: AddSmsTemplate.
    Version Yes String Common Params. The value used for this API: 2021-01-11.
    Region Yes String Common Params. For more information, please see the list of regions supported by the product.
    TemplateName Yes String Template name.
    TemplateContent Yes String Template content.
    SmsType Yes Integer SMS type. 1: Marketing SMS, 2: Notification SMS, 3: OTP SMS.
    Note: The "Regular SMS" type template currently still supports submission. However, in order to further improve the quality of SMS service and increase the approval rate of SMS templates, it is recommended to apply for a new template according to the "Notification SMS" type or the "OTP SMS" type. You can Refer to Optimization of Tencent Cloud SMS Template Types.
    International Yes Integer Whether it is Global SMS:
    0: Mainland China SMS.
    1: Global SMS.
    Remark Yes String Template remarks, such as reason for application and use case.

    3. Output Parameters

    Parameter Name Type Description
    AddTemplateStatus AddTemplateStatus SMS template addition response body
    RequestId String The unique request ID, generated by the server, will be returned for every request (if the request fails to reach the server for other reasons, the request will not obtain a RequestId). RequestId is required for locating a problem.

    4. Example

    Example1 Sample request

    Input Example

    POST / HTTP/1.1
    Host: sms.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: AddSmsTemplate
    <Common request parameters>
        "SmsType": 3,
        "International": 0,
        "Remark": "xx",
        "TemplateContent": "Your verification code is {1}",
        "TemplateName": "Verification code"

    Output Example

        "Response": {
            "AddTemplateStatus": {
                "TemplateId": "1110"
            "RequestId": "f36e4f00-605e-49b1-ad0d-bfaba81c7325"

    5. Developer Resources


    TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.

    Command Line Interface

    6. Error Code

    The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.

    Error Code Description
    FailedOperation.FailResolvePacket Failed to parse the request packet. Usually, this is because that the API specification was not followed. Please see Detailed Explanation of Request Body Parsing Error 1004.
    FailedOperation.ForbidAddMarketingTemplates Individual users cannot apply for sending marketing SMS messages.
    FailedOperation.JsonParseFail Failed to parse the request body.
    FailedOperation.MissingSignature You cannot apply for a template before you apply for a signature. Please create a signature first as instructed in Creating Signature.
    FailedOperation.MissingTemplateToModify This template ID has not been submitted for approval or does not exist, so it cannot be modified. Please check whether the TemplateId is entered correctly.
    FailedOperation.NotEnterpriseCertification Individual users cannot use the APIs related to signatures and templates. You can change your account identity type to enterprise as instructed here. The change will take effect in about one hour.
    FailedOperation.OtherError Other error. Usually, this is because that the carried parameter is non-compliant. For more information, see the API description. If necessary, you can contact SMS Helper for assistance.
    FailedOperation.TemplateAlreadyPassedCheck This template has been approved and cannot be modified again.
    FailedOperation.TemplateNumberLimit The number of templates has reached the maximum value.
    InternalError.JsonParseFail Failed to parse the user parameter. You can contact SMS Helper for assistance.
    InternalError.OtherError Other error. You can contact SMS Helper and provide the failed mobile number for assistance.
    InternalError.RequestTimeException The request was initiated in an exceptional time. Usually, this is because that the difference between your server time and Tencent Cloud server time exceeds 10 minutes. Please check whether the server time and the time field in the API are correct.
    InternalError.RestApiInterfaceNotExist This RESTful API does not exist. Please check the RESTful API description.
    InternalError.SendAndRecvFail The API timed out or SMS packet sending/receiving timed out. You need to check whether your network jitters or contact SMS Helper for assistance.
    InternalError.SigVerificationFail Backend check of Sig failed.
    InternalError.Timeout The request to deliver an SMS message timed out. Please see Detailed Explanation of Error 60008.
    InternalError.UnknownError Unknown error.
    InvalidParameter.DirtyWordFound There are sensitive words.
    InvalidParameter.InvalidParameters Invalid parameter. If you have any questions, contact SMS Helper.
    InvalidParameterValue.InvalidInternational International field check failed. See the description of this field in the API description. If necessary, you can contact SMS Helper for assistance.
    InvalidParameterValue.InvalidTemplateFormat The template format is incorrect. For more information, please see Body Template Review Standards.
    InvalidParameterValue.MarketingTemplateWithoutUnsubscribe Marketing messages must include an unsubscribe method.
    UnauthorizedOperation.RequestIpNotInWhitelist The requesting IP is not in the allowlist. You have configured the verification of request source IP, but the current requesting IP is not in the configured allowlist. If necessary, you can contact SMS Helper.
    UnauthorizedOperation.RequestPermissionDeny The request does not have permission. You can contact SMS Helper.
    UnauthorizedOperation.SdkAppIdIsDisabled This SdkAppId is forbidden to provide services. If necessary, you can contact SMS Helper.
    UnauthorizedOperation.ServiceSuspendDueToArrears If the service is suspended due to outstanding fees, you can log in to Tencent Cloud to recharge and clear the debt on your own.
    UnsupportedOperation. The request is not supported.




    7x24 电话支持