post https://api.imiconnect.io/resources/v1/messaging
Following are the limitations from WeChat when uploading multimedia files:
- Image (image): 128K, supports for JPG
- Audio (voice): 256K, no more than 60s play time, and supports for AMR
- Video (video): 1MB, supports for MP4
- Thumb (thumb): 64KB, supports for JPG
Info
To send an attachment, you can upload it using Service > template in IMIconnect or you can upload by other means without using IMIconnect and use the id in the API.
Headers
Request Header | Description |
---|---|
Content-Type | application/json |
key | Service Key |
Response
Response Code | Message | Description |
---|---|---|
1001 | Queued | Returned when the request is accepted by IMIconnect. |
7000 | Invalid JSON | Returned when an invalid JSON request is sent. |
7001 | Authentication failed | Returned when an invalid service key or profile key is provided in the request. |
7002 | Service key missing | Returned when the parameter key is missing in the message request. |
7003 | Mandatory parameters missing | Returned when the mandatory parameters configured in custom event are missing. |
7004 | Invalid parameters | Returned when the parameters are invalid. |
7006 | Internal error occurred | Returned when an internal error occurs. |
7007 | Service inactive | Returned when the service is in inactive state. |
7009 | Max number of destinations | Returned when an API request exceeds the limit (1000) to send messages using messaging API. |
##Request Body
{
"appid":"<your_app_id>",
"deliverychannel":"wechat",
"channels":{
"OTT-Messaging":{
"wechat":{
"text":"hi",
"attachment":{
"type":"media",
"media":{
"id":"1057943604868669445"
}
}
}
}
},
"destination":[
{
"wechatID":["1577568001"]
}]
}
Body Parameters
The following are the parameters of the request body:
Parameter | Type | Mandatory | Description |
---|---|---|---|
deliverychannel | String | Yes | wa for WhatsApp |
destination | JSONArray | Yes | The destination parameter is an array of up to 1,000 entries. Messages can be sent to single or multiple recipients in a single request. For more details, refer to destination array. |
channels | JSONArray | Yes | For more details, refer to channels array. |
expiry | String | No | Expiry time in UTC format, after which messages will not be pushed. For example, 2015-04-12T13:00:19.456Z or 2015-04-12T18:30:19.456+5:30. |
correlationid | String | No | A client-side identifier chosen by the Service Provider to correlate requests and their subsequent responses. The correlationid can be up to 50 bytes long. |
notifyurl | String | No | The IMIconnect platform will send notifications to the URL specified in the notifyurl parameter. The URL is used to retrieve the status of the message sent. The notifyurl can also be configured while creating a service. If the URL is specified in both the service and the messaging API, preference will be given to the messaging API request. More information on notify URL formats, click Message Receipts. |
callbackData | String | No | An identifier or data that will be sent alongside notifications to the notifyurl. This can serve as identifying notifications. |
Channels
The channels parameter block configures channel communication parameters for channel-specific features
Parameter | Type | Mandatory | Description |
---|---|---|---|
text | String | Yes | Message text |
attachment | JSONObject | Yes - if template is not passed | Specifies the attachment details that is uploaded by other means without using IMIconnect. |
- attachment object
Parameter | Type | Mandatory | Description |
---|---|---|---|
type | String | Yes | Specifies the media type. Following the supported types:
|
media_id | String | Yes | Specifies the media id that is received for the uploaded file. |
thumb_media_id | String | Yes - if type is video | Specifies the preview image media id for the video. |
smartlinks
An array that contains the parameters of Smartlink. This is optional. To use Smartlinks, you must create a smartlink and use the link id in messaging API.
Following are the parameters of smartlinks:
Parameter | Type | Mandatory | Description |
---|---|---|---|
linkid | Number | Yes | This parameter is mandatory when the smartlinks parameter is configured in Messaging. The link id gets generated when a Smartlink is created in IMIconnect. |
validity | Number | No | Specifies the time in minutes after which the link will expire. |
{
"smartlinks":[
{
"linkid": "<specifies the link id that is generated for a Smartlink using IMIconnect. >",
"validity": "<Specifies the time in minutes after which the link will expire>"
}
]
}
{
"response": [
{
"code": "1001",
"description": "Queued",
"transid": "f9793c83-f0b7-4200-99d9-20111c507baf",
"correlationid": "cid"
}
]
}