Send Custom Message

POST

https://api.itniotech.com/wa/custom/sendMsg

Custom message sending is limited to sending such messages within 24 hours of receiving user messages, and custom messages can only be sent after the recipient actively replies.
 
Request Parameters
Parameters Description Required Type
appId Application id Yes String
businessPhone Business number Yes String
channelType Channel type: 0-WhatsApp, send 0 by default Yes Integer
recipient Receiving number Yes String
type Message type: text, image, audio, video, location, document, sticker, interactive, contacts;
File size limit (text: 4096 characters, audio: 16MB, document: 100MB, image: 5MB, video: 16MB, sticker: 100KB).
For specific types of parameters, please refer to the documentation below.
Yes String
 
Request parameters for sending text messages(type=text):
Parameters Description Required Type
text Required when sending a text message No Object
body Text. Required when sending a text message No String
Request Sample
Request URL:
    https://api.itniotech.com/wa/custom/sendMsg
Request Method:
    POST
Request Headers:
    Content-Type: application/json;charset=UTF-8
    Sign: 05d7a50893e22a5c4bb3216ae3396c7c
    Timestamp: 1630468800
    Api-Key: bDqJFiq9
Request Body:
{
    "appId": "DGziZf5u",
    "businessPhone": "91856321412",
    "recipient": "91856321321",
    "channelType": 0,
    "type": "text",
    "text": {
        "body": "this is body content"
    }
}
 
Request parameters for sending context messages(type=context):
Parameters Description Required Type
context Context object   Object
refMessageId Reply to upstream message id No String
Request Sample
Request URL:
    https://api.itniotech.com/wa/custom/sendMsg
Request Method:
    POST
Request Headers:
    Content-Type: application/json;charset=UTF-8
    Sign: 05d7a50893e22a5c4bb3216ae3396c7c
    Timestamp: 1630468800
    Api-Key: bDqJFiq9
Request Body:
{
    "appId": "DGziZf5u",
    "businessPhone": "17376111187",
    "recipient": "8618099900000",
    "channelType": 0,
    "type": "text",
    "text": {
        "body": "this is body content"
    },
    "context": {
        "refMessageId": "1"
    }
}
 
Request parameters for sending image messages(type=image):
Parameters Description Required Type
image Required when sending a picture message No Object
link Image link. Required when sending a picture message No String
caption title No String
Request Sample
Request URL:
    https://api.itniotech.com/wa/custom/sendMsg
Request Method:
    POST
Request Headers:
    Content-Type: application/json;charset=UTF-8
    Sign: 05d7a50893e22a5c4bb3216ae3396c7c
    Timestamp: 1630468800
    Api-Key: bDqJFiq9
Request Body:
{
    "appId": "DGziZf5u",
    "businessPhone": "91856321412",
    "recipient": "91856321321",
    "channelType": 0,
    "type": "image",
    "image": {
        "link": "https://abc.com/log.png",
        "caption": "title"
    }
}
 
Request parameters for sending document messages(type=document):
Parameters Description Required Type
document Required when sending a document message No Object
link Document link. Required when sending a document message No String
filename File name. Required when sending a document message No String
caption title No String
Request Sample
Request URL:
    https://api.itniotech.com/wa/custom/sendMsg
Request Method:
    POST
Request Headers:
    Content-Type: application/json;charset=UTF-8
    Sign: 05d7a50893e22a5c4bb3216ae3396c7c
    Timestamp: 1630468800
    Api-Key: bDqJFiq9
Request Body:
{
    "appId": "DGziZf5u",
    "businessPhone": "91856321412",
    "recipient": "91856321321",
    "channelType": 0,
    "type": "document",
    "document": {
        "link": "https://abc.com/log.png",
        "filename": "123",
        "caption": "title"
    }
}
 
Request parameters for sending audio messages(type=audio):
Parameters Description Required Type
audio Required when sending an audio message No Object
link Audio link. Required when sending an audio message No String
Request Sample
Request URL:
    https://api.itniotech.com/wa/custom/sendMsg
Request Method:
    POST
Request Headers:
    Content-Type: application/json;charset=UTF-8
    Sign: 05d7a50893e22a5c4bb3216ae3396c7c
    Timestamp: 1630468800
    Api-Key: bDqJFiq9

//Example of sending text messages
Request Body:
{
    "appId": "DGziZf5u",
    "businessPhone": "91856321412",
    "recipient": "91856321321",
    "channelType": 0,
    "type": "audio",
    "audio": {
        "link": "https://abc.com/log.png"
    }
}
 
Request parameters for sending video messages(type=video):
Parameters Description Required Type
video Required when sending a video message No Object
link Video link. Required when sending a video message No String
caption title No String
Request Sample
Request URL:
    https://api.itniotech.com/wa/custom/sendMsg
Request Method:
    POST
Request Headers:
    Content-Type: application/json;charset=UTF-8
    Sign: 05d7a50893e22a5c4bb3216ae3396c7c
    Timestamp: 1630468800
    Api-Key: bDqJFiq9
Request Body:
{
    "appId": "DGziZf5u",
    "businessPhone": "91856321412",
    "recipient": "91856321321",
    "channelType": 0,
    "type": "video",
    "video": {
        "link": "https://abc.com/log.png",
        "caption": "title"
    }
}
 
Request parameters for sending sticker messages(type=sticker):
Parameters Description Required Type
sticker Required when sending a sticker message No Object
link Sticker link. Required when sending a sticker message No String
Request Sample
Request URL:
    https://api.itniotech.com/wa/custom/sendMsg
Request Method:
    POST
Request Headers:
    Content-Type: application/json;charset=UTF-8
    Sign: 05d7a50893e22a5c4bb3216ae3396c7c
    Timestamp: 1630468800
    Api-Key: bDqJFiq9
Request Body:
{
    "appId": "DGziZf5u",
    "businessPhone": "91856321412",
    "recipient": "91856321321",
    "channelType": 0,
    "type": "sticker",
    "sticker": {
        "link": "https://abc.com/log.webp"
    }
}
 
Request parameters for sending location messages(type=location):
Parameters Description Required Type
location Required when sending a location message No Object
longitude Longitude. Required when sending a location message No String
latitude Latitude. Required when sending a location message No String
name Location name. Required when sending a location message No String
address Address description. Required when sending a location message No String
Request Sample
Request URL:
    https://api.itniotech.com/wa/custom/sendMsg
Request Method:
    POST
Request Headers:
    Content-Type: application/json;charset=UTF-8
    Sign: 05d7a50893e22a5c4bb3216ae3396c7c
    Timestamp: 1630468800
    Api-Key: bDqJFiq9
Request Body:
{
    "appId": "DGziZf5u",
    "businessPhone": "91856321412",
    "recipient": "91856321321",
    "channelType": 0,
    "type": "location",
    "location": {
        "address": "Longgang District, Shenzhen City",
        "latitude": "62.636152267456",
        "link": "https://123",
        "name": "shenzhen",
        "longitude": "104.056640625"
    }
}
 
Request parameters for sending interactive messages(type=interactive):
Parameters Description Required Type
interactive Send an interactive list message   Object
type Interactive message types, list Yes String
header The header for list messages No  
type interactive Yes String
text Content No String
body The body of the list message Yes  
text Body content Yes String
footer The footer of the list message No  
text Footer content No String
action action    
button Actions users take after reading the message Yes String
sections   Yes Array
title title Yes String
rows rows Yes Array
id Row number, 200 characters Yes String
title Row title, 24 characters Yes String
description Description of row, 72 characters No String
Request Sample
Request URL:
    https://api.itniotech.com/wa/custom/sendMsg
Request Method:
    POST
Request Headers:
    Content-Type: application/json;charset=UTF-8
    Sign: 05d7a50893e22a5c4bb3216ae3396c7c
    Timestamp: 1630468800
    Api-Key: bDqJFiq9
Request Body:
{
  "appId": "7WY0BQ7W",
  "businessPhone": 6282299953162,
  "channelType": 0,
  "recipient": "8614718004557",
  "type": "interactive",
  "interactive": {
    "type": "list",
    "header": {
      "type": "text",
      "text": "HEADER_TEXT"
    },
    "body": {
      "text": "BODY_TEXT"
    },
    "footer": {
      "text": "FOOTER_TEXT"
    },
    "action": {
      "button": "BUTTON_TEXT",
      "sections": [
        {
          "title": "SECTION_1_TITLE",
          "rows": [
            {
              "id": "SECTION_1_ROW_1_ID",
              "title": "SECTION_1_ROW_1_TITLE",
              "description": "SECTION_1_ROW_1_DESCRIPTION"
            },
            {
              "id": "SECTION_1_ROW_2_ID",
              "title": "SECTION_1_ROW_2_TITLE",
              "description": "SECTION_1_ROW_2_DESCRIPTION"
            }
          ]
        },
        {
          "title": "SECTION_2_TITLE",
          "rows": [
            {
              "id": "SECTION_2_ROW_1_ID",
              "title": "SECTION_2_ROW_1_TITLE",
              "description": "SECTION_2_ROW_1_DESCRIPTION"
            },
            {
              "id": "SECTION_2_ROW_2_ID",
              "title": "SECTION_2_ROW_2_TITLE",
              "description": "SECTION_2_ROW_2_DESCRIPTION"
            }
          ]
        }
      ]
    }
  }
}
 
Interactive - Quickly reply to messages(type=interactive):
Parameters Description Required Type
interactive Send an interactive list message   Object
type Interactive message types, list Yes String
header The header for list messages No  
type interactive Yes String
text Content No String
body The body of the list message Yes  
text Body content Yes String
footer The footer of the list message No  
text Footer content No String
action action    
buttons   Yes  
type   Yes String
reply Supported types of reply buttons: reply. Supports up to three buttons. Yes Object
id The unique identifier of the button. This ID will be returned in the webhook when the user clicks the button. Maximum length: 256 characters. Yes String
title Button title. It cannot be an empty string and must be unique within the message (tested). 20 characters. Yes String
Request Sample
Request URL:
    https://api.itniotech.com/wa/custom/sendMsg
Request Method:
    POST
Request Headers:
    Content-Type: application/json;charset=UTF-8
    Sign: 05d7a50893e22a5c4bb3216ae3396c7c
    Timestamp: 1630468800
    Api-Key: bDqJFiq9
Request Body:
{
  "appId": "7WY0BQ7W",
  "businessPhone": 6282299953162,
  "channelType": 0,
  "recipient": "8614718004557",
  "type": "interactive",
  "interactive": {
    "type": "button",
    "body": {
      "text": "BUTTON_TEXT"
    },
    "action": {
      "buttons": [
        {
          "type": "reply",
          "reply": {
            "id": "22",
            "title": "one"
          }
        },
        {
          "type": "reply",
          "reply": {
            "id": "33",
            "title": "two"
          }
        }
      ]
    }
  }
}
 
Interactive - Requesting geographic location messages(type=interactive):
Parameters Description Required Type
interactive Send an interactive list message   Object
type location_request_message Yes String
body The body of the message Yes  
text Body content Yes String
action action    
name send_location(Fixed value) Yes String
Request Sample
Request URL:
    https://api.itniotech.com/wa/custom/sendMsg
Request Method:
    POST
Request Headers:
    Content-Type: application/json;charset=UTF-8
    Sign: 05d7a50893e22a5c4bb3216ae3396c7c
    Timestamp: 1630468800
    Api-Key: bDqJFiq9

//Example of sending an interactive list message
Request Body:
{
    "appId": "zRTc00Vs",
    "businessPhone": 6282292229952762,
    "channelType": 0,
    "recipient": "86173333376738687",
    "type": "interactive",
    "interactive": { // the text object
        "type": "location_request_message",
        "body":{
            "text":"Shenzhen City, Guangdong Province"
        },
        "action":{
            "name":"send_location"
        }
    }
}
 
Request parameters for sending contacts messages(type=contacts):
Parameters Description Required Type
contacts Contacts   Object
birthday birthday, YYYY-MM-DD No String
addresses   No Array
street Street name No String
city City name No String
state State No String
zip Postal code No String
country Full country name No String
country_code Country abbreviation No String
type Address type: HOME (home), WORK (work) No String
emails   No Array
email Email address No String
type Type: HOME (home), WORK (work) No String
name   Yes Object
formatted_name Full name Yes String
first_name First name No String
last_name Last name No String
middle_name Middle name No String
suffix Suffix No String
prefix Prefix No String
org   No Object
company Company name No String
department Department name No String
title Title No String
phones   No Array
phone Phone No String
type Type:CELL、MAIN、IPHONE、HOME、WORK No String
urls   No Array
url Url No String
type Type: HOME, WORK No String
Request Sample
Request URL:
    https://api.itniotech.com/wa/custom/sendMsg
Request Method:
    POST
Request Headers:
    Content-Type: application/json;charset=UTF-8
    Sign: 05d7a50893e22a5c4bb3216ae3396c7c
    Timestamp: 1630468800
    Api-Key: bDqJFiq9
Request Body:
{
  "appId": "7WY0BQ7W",
  "businessPhone": 6282299953162,
  "channelType": 0,
  "recipient": "8614718004557",
  "type": "contacts",
  "contacts": [
    {
      "addresses": [
        {
          "street": "STREET",
          "city": "CITY",
          "state": "STATE",
          "zip": "ZIP",
          "country": "COUNTRY",
          "country_code": "COUNTRY_CODE",
          "type": "HOME"
        },
        {
          "street": "STREET",
          "city": "CITY",
          "state": "STATE",
          "zip": "ZIP",
          "country": "COUNTRY",
          "country_code": "COUNTRY_CODE",
          "type": "WORK"
        }
      ],
      "birthday": "1995-01-11",
      "emails": [
        {
          "email": "EMAIL",
          "type": "WORK"
        },
        {
          "email": "EMAIL",
          "type": "HOME"
        }
      ],
      "name": {
        "formatted_name": "NAME",
        "first_name": "FIRST_NAME",
        "last_name": "LAST_NAME",
        "middle_name": "MIDDLE_NAME",
        "suffix": "SUFFIX",
        "prefix": "PREFIX"
      },
      "org": {
        "company": "COMPANY",
        "department": "DEPARTMENT",
        "title": "TITLE"
      },
      "phones": [
        {
          "phone": "PHONE_NUMBER",
          "type": "HOME"
        },
        {
          "phone": "PHONE_NUMBER",
          "type": "WORK",
          "wa_id": "PHONE_OR_WA_ID"
        }
      ],
      "urls": [
        {
          "url": "URL",
          "type": "WORK"
        },
        {
          "url": "URL",
          "type": "HOME"
        }
      ]
    }
  ]
}
 
Response Parameters
Parameters Description Type
status Status code, 0 is successful, other failures refer to the interface response code String
reason Success or failure description String
data Result Object
messageId Message id String
imestamp Timestamp (second level) Long
channelType Channel type: 0-WhatsApp, default 0 String
 
Response Status Code
status Description
-68 Insufficient balance
-69 The rate does not exist
-70 The recipient number is too long
-71 The recipient number is too short
-72 The recipient number format is incorrect. It must be a number
-93 The businessPhone number is too long
-94 The businessPhone number is too short
-95 The businessPhone number format is incorrect. It must be a number
-96 Business number does not exist
-97 Business number status is abnormal
-112 The channelType only can be 0 in param
-114 Required for text parameter
-115 Required for body parameter
-116 Required for image parameter
-117 Required for link parameter
-118 Required for audio parameter
-119 Required for link parameter
-120 Required for video parameter
-121 Required for link parameter
-122 Required for sticker parameter
-123 Required for link parameter
-124 Required for document parameter
-125 Required for link parameter
-127 Required for location parameter
-128 Required for longitude parameter
-129 Required for latitude parameter
-132 Unknown message type
-133 The link format is incorrect
-134 The param of parameters type error
-135 Required for variable parameters
 

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 sendCustomMsg() {
    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 url = baseUrl.concat("custom/sendMsg");

    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);


    final int channelType = 0;
    final String businessPhone = "business phone"; //the business phone
    final String recipient = "accept phone"; //accept phone
    final String type = "text";

    Map<String, String> buildMap = MapUtil.builder("body", "this is body content").build();

    String body = JSONUtil.createObj()
            .set("appId", appId)
            .set("businessPhone", businessPhone)
            .set("channelType", channelType)
            .set("recipient", recipient)
            .set("type", type)
            .set("text", buildMap)
            .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/sendMsg";

$dataArr["appId"] = $appId;
$dataArr["businessPhone"] = "business phone";
$dataArr["recipient"] = "accept phone";
$dataArr["channelType"] = 0;
$dataArr["type"] = "text";
$dataArr["text"] = array(
    "body" => "this is body content"
);

$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": {
        "channelType": 0,
		"messageId": "10415ecbd0c848ebb7d5a3fe53269df6",
		"timestamp": 1693813991
	}
}