# MSG91 Send OTP API Documentation Summary ## Overview MSG91 provides an OTP service that allows sending One-Time Passwords (OTPs) via SMS, WhatsApp, and Voice calls. Channel selection and fallback behavior are configured inside the OTP Template created in the MSG91 control panel. --- ## 1. Send OTP Endpoint - **URL**: `https://control.msg91.com/api/v5/otp` - **HTTP Method**: `POST` --- ## 2. Headers | Header Name | Type | Required | Description | |---|---|---|---| | `authkey` | String | Yes | User authentication key (unique for every MSG91 user account). Can also be passed as query parameter. | | `content-type` | String | Yes | `application/json` (when passing JSON payload for template parameters). | --- ## 3. Query Parameters ### Required Parameters | Parameter | Type | Description | |---|---|---| | `template_id` | String | OTP Template ID generated in the MSG91 Dashboard (OTP section). Configures the message template and delivery channels (SMS, WhatsApp, Voice). | | `mobile` | String | Recipient mobile number in international format with country code (e.g. `919876543210`). | | `authkey` | String | User authentication key. | ### Optional Parameters | Parameter | Type | Default | Description | |---|---|---|---| | `otp` | String / Integer | Auto-generated | Custom OTP value to send. If omitted, MSG91 generates the OTP automatically. | | `unicode` | Integer | `0` | Pass `1` for non-English SMS content, `0` for English. | | `invisible` | Integer | `0` | Mobile App verification (1 = ON, 0 = OFF). Auto-verifies if mobile network is ON. | | `otp_expiry` | Integer | `15` | OTP expiry in minutes (Min: 1 min, Max: 10080 mins / 7 days). | | `otp_length` | Integer | `4` | Number of digits in generated OTP (Min: 4, Max: 9). | | `realTimeResponse` | Integer | - | Pass `1` to receive real-time API response handling error codes via caching. | --- ## 4. Request Body Parameters (JSON) - **Content-Type**: `application/json` - Pass dynamic variables defined in your MSG91 OTP template as JSON key-value pairs. - Variable names are **case-sensitive**. **Example JSON Payload**: ```json { "Param1": "Value1", "Param2": "Value2", "company_name": "MyCompany" } ``` --- ## 5. WhatsApp & Multi-Channel OTP Setup - **Template-Based Routing**: Delivery channels (SMS vs WhatsApp) are configured within the MSG91 Dashboard under the OTP Template (`template_id`). - When creating or editing an OTP template in MSG91, you can set WhatsApp as the primary or secondary fallback channel. - **Resend OTP API**: - **Endpoint**: `GET https://control.msg91.com/api/v5/otp/retry` - **Query Parameters**: - `mobile`: Mobile number in international format. - `authkey`: User authentication key. - `retrytype`: Delivery type for resending OTP (`text` for SMS/WhatsApp text, `voice` for voice call; Default: `voice`).