STEP 1. Login to MSG91 panel -> Click on SMS.
STEP 2. Go to the Webhook section and enter your Webhook URL in the box given and select the version of Webhook (v2, v3 or v4). Details of the response received on your Webhook URL in different version is mentioned below and will also be visible in your MSG91 account.
Webhook Version 2 (v2):
The response is sent with content-type: application/x-www-form-urlencoded
Sample response v2:
{
"data": "[{\"senderId\":\"uXXXXm\",\"requestId\":\"346XXXXXXXXXXXX130\",\"report\":[{\"date\":\"2024-05-22 10:06:20\",\"amount\":\"0.01\",\"clientid\":\"\",\"INMSID\":\"0\",\"CRQID\":\"0\",\"ctCode\":\"900\",\"number\":\"9195XXXX6558\",\"credit\":\"1\",\"status\":\"1\",\"desc\":\"DELIVERED\",\"failedReason\":\"\"}],\"userId\":\"27XXXX\",\"campaignName\":\"Sendhttp\"}]"
}
Webhook Version 3 (v3):
The response is sent with content-type: application/json, this version is generally used if you are using platforms like Moengage, Webengage etc, to send messages.
Sample response v3:
{
"date": "2024-05-22 09:58:16",
"number": "9195XXXX6558",
"senderId": "uXXXXm",
"amount": "0.01",
"requestId": "346XXXXXXXXXXXX130",
"INMSID": "0",
"CRQID": "0",
"credit": "1",
"userId": "27XXXX",
"campaignName": "Sendhttp",
"status": "1",
"desc": "DELIVERED"
}
Webhook Version 4 (v4)
This version is generally selected if you are using Clevertap platform to send messages. The response is sent with content-type: application/json
Sample response v4:
[{"data":[{"meta":"0","INMSID":"0","description":"DELIVERED","ts":1726729500}],"event":"delivered"}]
STEP 3. Now our system will automatically push the delivery report to the saved URL on a real-time basis.
STEP 4. On your Webhook URL, we will push the description as well as the status of the Request ID(s). Please find below the description with the status.
Status | Description |
1 | Delivered |
2 | Failed |
9 | NDNC (In case of Promotional SMS only) |
16 & 25 | Rejected |
17 | Blocked number |
Note:-
For debugging or demo purposes you can use https://public.requestbin.com/ or https://httpdump.app to have a testing callback URL.
1. To obtain additional values in the webhook response, you have the option to include a custom parameter named "CRQID" in the API. However, please note that the "CRQID" parameter only allows alphanumeric values and does not support spaces or special characters.
It is applicable for all versions of SMS API.
Note: Maximum characters allowed in CRQID: 52 characters.
Sample Payloads V5 or FLOW API:
{
"flow_id": "60b07XXXXXXXXXXXXXXX",
"sender": "TESTIN",
"recipients": [
{
"mobiles": "919999999999",
"var": "XYZ",
"CRQID": "Beta1"
},
{
"mobiles": "91888888888",
"var": "XYZ",
"CRQID": "Beta2"
}
]
}
Output:
data= [{"senderId":"TESTIN", "requestId": "33666c73574c303830353738", "report": [{"date": "2023-06-12 19:49:39", "number": "919999999999", "clientid":''12345", "CRQID": "Beta1", "status": "1", "desc" :"DELIVERED"}], "userId": "12345", "campaignName": "API"'}]
data= [{"senderId":"TESTIN", "requestId": "33666c73574c303830353738", "report": [{"date": "2023-06-12 19:49:39", "number": "91888888888", "clientid":''12345", "CRQID": "Beta2", "status": "1", "desc" :"DELIVERED"}], "userId": "12345", "campaignName": "API"'}]
Note: Different CRQID values will only be received in the case of custom messages, meaning different messages for different numbers.
2. We started showing the failure reason of any SMS request on Webhook. The sample response will look like below:
data= [{"senderId":"TESTIN","requestId":"33666d73756c393431393033","report":[{"date":"2023-06-13 19:21:13","number":"91888888888","clientid":"12345","CRQID":"Beta2","status":"2","desc":"FAILED", "failedReason":"Template Inactive on DLT"}],"userId":"12345","campaignName":"API"}]
Please note : Webhook will not be sent for following API failure error codes
- 301 : Insufficient Balance
- 203 : Invalid Sender ID
- 211 : Empty DLT ID (Template ID or PE ID)