MSG91

Usage Instructions

Integrate MSG91 into the workflow. Send SMS through approved DLT templates, send, verify and resend OTPs, send WhatsApp templates and session replies, check WhatsApp prepaid balance, and pull SMS delivery logs. Can also run workflows when MSG91 reports SMS delivery or a customer sends a WhatsApp message. Indian SMS must match a DLT-approved template exactly, so SMS and OTP always go through an MSG91 template. Requires an MSG91 authkey.

Actions

MSG91 Send SMS

Send an SMS to one or many numbers through an MSG91 SMS template (Flow API), filling the template's variables. In India every SMS must match a DLT-approved template exactly (TRAI rule): register the template on a DLT portal, add it in MSG91 with its DLT Template ID, and fill only its ##variables##. Free-form text is blocked by operators.

Input

ParameterTypeRequiredDescription
authKeystringYesMSG91 authkey, from the MSG91 dashboard under Authkey
templateIdstringYesMSG91 SMS template ID (from SMS > Templates). The template carries the DLT Template ID and sender ID, so its approved text is what gets sent.
mobilesstringNoRecipient numbers with country code and no "+", comma-separated (e.g. 919876543210). Required unless Recipients is set.
variablesjsonNoValues for the template variables, keyed exactly as in the template (case-sensitive), e.g. {"var1": "Asha", "var2": "10:30"}. Sent to every number in Mobile Numbers.
recipientsjsonNoPer-recipient values instead of Mobile Numbers + Variables: an array like [{"mobiles": "919876543210", "var1": "Asha"}]. Optional tracking keys such as CRQID are echoed back in delivery webhooks.
shortUrlbooleanNoShorten URLs in the message (short_url)
shortUrlExpirynumberNoShort URL expiry in seconds
realTimeResponsebooleanNoAsk MSG91 for a real-time response (realTimeResponse=1)

Output

ParameterTypeDescription
requestIdstringRequest ID of the send. Pass it to Get SMS Report to check delivery.
typestringMSG91 result type, "success" when accepted

MSG91 Send OTP

Generate and send a one-time password by SMS with an MSG91 OTP template. MSG91 stores the code and its expiry, so check it later with Verify OTP. In India the OTP template must match a DLT-approved template exactly.

Input

ParameterTypeRequiredDescription
authKeystringYesMSG91 authkey, from the MSG91 dashboard under Authkey
templateIdstringYesMSG91 OTP template ID (from the OTP section). The template must contain ##OTP## and match its DLT-approved text.
mobilestringYesMobile number with country code, e.g. 919876543210
otpLengthnumberNoOTP length, 4 to 9 digits (default 4)
otpExpirynumberNoMinutes before the OTP expires, 1 to 10080 (default 15)
otpstringNoYour own OTP value. Leave empty so MSG91 generates one.
unicodebooleanNoSet for non-English templates
templateParamsjsonNoValues for template variables other than the OTP, keyed exactly as in the template (case-sensitive), e.g. {"Param1": "Asha"}

Output

ParameterTypeDescription
requestIdstringRequest ID of the OTP send (Send OTP only)
typestringMSG91 result type, "success" when accepted
messagestringMSG91 message, e.g. "retry send successfully" (Resend OTP only)

MSG91 Verify OTP

Check the OTP a user entered against the one MSG91 sent to that number. Returns verified true only on a match; a wrong or expired code returns verified false with the reason.

Input

ParameterTypeRequiredDescription
authKeystringYesMSG91 authkey, from the MSG91 dashboard under Authkey
mobilestringYesThe mobile number the OTP was sent to, with country code
otpstringYesThe code the user entered

Output

ParameterTypeDescription
verifiedbooleanTrue only when MSG91 confirmed the OTP
typestringMSG91 result type: success or error
messagestringMSG91 message, e.g. "OTP verified success", "OTP expired" or "OTP not match"

MSG91 Resend OTP

Resend the same OTP to a number that already got one from Send OTP, by SMS or voice call. MSG91 allows at most 2 retries.

Input

ParameterTypeRequiredDescription
authKeystringYesMSG91 authkey, from the MSG91 dashboard under Authkey
mobilestringYesThe mobile number the OTP was first sent to, with country code
retryTypestringNo"text" to resend by SMS or "voice" for a voice call (MSG91 default: voice)

Output

ParameterTypeDescription
requestIdstringRequest ID of the OTP send (Send OTP only)
typestringMSG91 result type, "success" when accepted
messagestringMSG91 message, e.g. "retry send successfully" (Resend OTP only)

MSG91 Send WhatsApp Template

Send an approved WhatsApp template message from your MSG91 WhatsApp number to one or many customers. Templates start a conversation; free-form replies need Send WhatsApp Message inside the 24-hour session.

Input

ParameterTypeRequiredDescription
authKeystringYesMSG91 authkey, from the MSG91 dashboard under Authkey
integratedNumberstringYesYour WhatsApp number integrated with MSG91, with country code
templateNamestringYesName of an approved WhatsApp template on that number
languageCodestringYesTemplate language code, e.g. en or en_US
recipientsstringNoRecipient numbers with country code, comma-separated. Required unless To and Components is set.
componentsjsonNoTemplate variable values, e.g. {"body_1": {"type": "text", "value": "Asha"}, "header_1": {"type": "image", "value": "https://..."}}
toAndComponentsjsonNoPer-recipient values instead of Recipients + Components: [{"to": ["919876543210"], "components": {"body_1": {"type": "text", "value": "Asha"}}}]

Output

ParameterTypeDescription
requestIdstringRequest ID of the bulk template send
statusstringRequest status, "success" when accepted
messagestringMSG91 note, e.g. "Your request is in process, check delivery reports for status"

MSG91 Send WhatsApp Message

Send a free-form WhatsApp text reply from your MSG91 WhatsApp number. Works only inside the 24-hour session that starts when the customer messages you; otherwise send a template.

Input

ParameterTypeRequiredDescription
authKeystringYesMSG91 authkey, from the MSG91 dashboard under Authkey
integratedNumberstringYesYour WhatsApp number integrated with MSG91, with country code
recipientNumberstringYesCustomer number with country code, e.g. 919876543210
textstringYesMessage text, up to 4096 characters

Output

ParameterTypeDescription
messageUuidstringMSG91 message UUID
statusstringRequest status, "success" when accepted
messagestringMSG91 note, e.g. "Your request is in process, please check delivery report for status"

MSG91 Get WhatsApp Balance

Get the prepaid WhatsApp balance and plan status of an MSG91 WhatsApp number. Use it before a large template send to make sure the balance covers it.

Input

ParameterTypeRequiredDescription
authKeystringYesMSG91 authkey, from the MSG91 dashboard under Authkey
integratedNumberstringYesYour WhatsApp number integrated with MSG91, with country code

Output

ParameterTypeDescription
statusstringRequest status, "success" when found
planStatusstringWhatsApp plan status, e.g. active
numberstringThe integrated WhatsApp number
prepaidBalancenumberPrepaid WhatsApp balance left on the number

MSG91 Get SMS Report

Get SMS delivery logs (status, number, delivery time) for a date range, or for one send by its request ID. The range can be at most 3 days and must start within the last 3 days.

Input

ParameterTypeRequiredDescription
authKeystringYesMSG91 authkey, from the MSG91 dashboard under Authkey
startDatestringYesStart date, YYYY-MM-DD, within the last 3 days
endDatestringYesEnd date, YYYY-MM-DD, at most 3 days after the start date
requestIdstringNoRequest ID returned by Send SMS, to get only that send
fieldsstringNoComma-separated fields to return (no spaces), e.g. status,telNum,deliveryDate,deliveryTime,requestId,failureReason,credit,DLT_TE_ID
limitnumberNoMaximum rows to return, up to 10000 (MSG91 default 1000)

Output

ParameterTypeDescription
logsarrayOne row per message. By default each row has status, telNum, requestDate, deliveryDate, deliveryTime and sentDateTime; Fields changes which keys are returned.
↳ statusstringDelivery status, e.g. Delivered
↳ telNumstringRecipient number
↳ requestDatestringWhen the send was requested
↳ deliveryDatestringDelivery date (YYYY-MM-DD)
↳ deliveryTimestringDelivery time (HH:mm:ss)
↳ sentDateTimestringWhen the SMS was sent to the operator
totalnumberTotal rows matching the query
paginationTokenstringToken MSG91 returns for large result sets