Query Message Template

POST

https://api.itniotech.com/wa/template/query

Dynamically query all template situations according to incoming conditions
 
Request Parameters
Parameters Description Required Type
appId Application id Yes String
templateId Template id No String
languageCode Template language, see Country Enumeration for details No String
 
Request Sample
Request URL:
    https://api.itniotech.com/wa/template/query
Request Method:
    POST
Request Headers:
    Content-Type: application/json;charset=UTF-8
    Sign: 05d7a50893e22a5c4bb3216ae3396c7c
    Timestamp: 1630468800
    Api-Key: bDqJFiq9
Request Body:
{
    "appId":"xJdRmKR3ff",
    "templateId":"e66a5e3780d54b02adf1c280c10e90dd",
    "languageCode":"zh_CN"
}
 
Response Parameters
Parameters Description Type
status Status code, 0 is successful, other failures refer to the interface response code String
reason Reason String
data Send result Object
appId Application id String
templateId Template id String
templateName Template name String
templateCategory Template type: 0-AUTHENTICATION (authentication); 1-MARKETING (marketing); 2-UTILITY (transaction class) Integer
templateLanList Template list, which contains a variety of different language templates List
status Template status: PENDING (under review), REJECTED (not passed the review), APPROVED (passed the review), DELETED (deleted), DISABLED (disabled),PENDING_DELETION (pending deletion), IN_APPEAL (appeal filed), PAUSED (temporarily suspended), LIMIT_EXCEEDED (limit exceeded), FLAGGED (planned to be disabled), REINSTATED (reinstated) String
reason Denial Reason String
footer Footer content String
language   Object
code Language code String
nameEn English description String
nameCn Chinese description String
header   Object
type Header type, 0-TEXT Integer
text When format=1, it is the text content of the header String
example Header variable example Array
body   Object
type Body body type, 0-TEXT String
text Text content String
exampleParams Corresponding variable array Array
buttons   Object
type Button type: 3-OTP (optional when the template type is authentication) currently only supports otp type, default 3 Integer
text Content String
otp_type Indicates the button type, type is 3 required, verification code button type: copyCode (copy verification code), if you want the template to use the copy verification code button, please set this placeholder to "COPY_CODE" String
 
Response Status Code
status Description
0 success
-1 Authentication error
-2 Incorrect template status
-4 Timestamp expires
-5 System exception !
-6 Restricted IP access
-7 json parse exception, plase check you param's type and json format
-8 Abnormal parameter verification
-10 Application does not exist
-11 The application name already exists
-12 Network exception or parameter error
-14 Account not authenticated
 

language

Java

PHP

REQUEST

package com.itniotech.api.demo.im;

import cn.hutool.core.map.MapUtil;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.http.Header;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

private static void queryTemplateInfo() {
    final String baseUrl = "https://api.itniotech.com/wa/";
    final String apiKey = "your api key";
    final String apiPwd = "your api secret";
    final String appId = "your appid";

    final String templateId = "template id"; //the template id
    final String url = baseUrl.concat("template/query");

    HttpRequest request = HttpRequest.post(url);

    final String datetime = String.valueOf(LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().getEpochSecond());

    final String sign = SecureUtil.md5(apiKey.concat(apiPwd).concat(datetime));
    request.header(Header.CONNECTION, "Keep-Alive")
            .header(Header.CONTENT_TYPE, "application/json;charset=UTF-8")
            .header("Sign", sign)
            .header("Timestamp", datetime)
            .header("Api-Key", apiKey);

    String body = JSONUtil.createObj()
            .set("appId", appId)
            .set("templateId", templateId)
            .toString();

    HttpResponse response = request.body(body).execute();
    if (response.isOk()) {
        String result = response.body();
        System.out.println(result);
    }
}        
                

REQUEST

header('content-type:text/html;charset=utf8');

$apiKey = "your api key";
$apiSecret = "your api secret";
$appId = "your appid";
$timeStamp = time();
$sign = md5($apiKey.$apiSecret.$timeStamp);
$headers = array('Content-Type:application/json;charset=UTF-8',"Sign:$sign","Timestamp:$timeStamp","Api-Key:$apiKey");

$url = "https://api.itniotech.com/wa/template/query";

$dataArr["appId"] = $appId;
$dataArr["templateId"] = "template id";

$data = json_encode($dataArr);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 600);
curl_setopt($ch, CURLOPT_HTTPHEADER,$headers);
curl_setopt($ch, CURLOPT_POSTFIELDS , $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);

$output = curl_exec($ch);
curl_close($ch);
var_dump($output);
        
                
 

RESPONSEEXAMPLE

{
    "status": "0",
    "reason": "success",
    "data": [
        {
            "appId": "xJdRmKR3ff",
            "templateId": "3654e6b0218548a3ae20e4f9db7f5a4d",
            "templateName": "discount_promotion",
            "templateCategory": 1,
            "templateLanList": [
                {
                    "language": {
                        "nameCn": "英语",
                        "nameEn": "English",
                        "code": "en"
                    },
                    "header": {
                        "type": 0,
                        "text": "New Zhengde supermarket"
                    },
                    "body": {
                        "type": 0,
                        "text": "The new Zhengde supermarket has started a crazy sale, all the products are {{#}}% off...",
                        "exampleParams": [
                            "50"
                        ]
                    },
                    "footer": "Zhengde Business",
                    "status": "APPROVED",
                    "reason": "APPROVED"
                }
            ]
        }
    ]
}