Send OTP
generate_otpSend a one-time password (OTP) to a phone number via SMS, WhatsApp, or Telegram. MyOTP.App generates the code, formats the message, picks the best carrier route, and delivers it. Returns a message_id (UUID) — keep it; you'll pass it to verify_otp, check_otp_status, or extend_otp later. Each call deducts credits from the account balance; the per-message cost varies by destination country and channel and is returned in the cost field. Use this whenever an app needs to verify someone's phone — signup, login 2FA, password reset, transaction confirmation, etc.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| brand | No | Sender brand name shown to the recipient (3-16 alphanumeric characters plus dots). Defaults to the brand registered against the API key, or 'MyOTP.App' if none. | |
| channel | No | Delivery channel. 'sms' (default) works in 190+ countries. 'whatsapp' is best for India/Brazil/Indonesia/Mexico/Nigeria/Turkey. 'telegram' is best for privacy-focused users. Same API for all three. | |
| otp_code | No | Provide your own pre-generated numeric OTP code (3-8 digits, 4-8 for telegram) instead of letting MyOTP generate one. Useful when you already have a code from another system. | |
| force_send | No | If true, send a new OTP even if one is already active for this phone number. By default the API returns 409 in that case. Use sparingly — repeated sends to the same number can hit carrier-level spam filters. | |
| otp_length | No | Number of digits in the auto-generated OTP. Range 3-8 (4-8 for telegram). Default 6. Requires CUSTOM_OTP_LENGTH entitlement (Business plan or above). | |
| return_otp | No | If true, the API response will include the generated OTP code in plain text. Useful for testing or when you want to deliver the OTP via your own channel. Defaults to false. SECURITY: never enable this in production user flows. | |
| otp_validity | No | How long the OTP stays valid, in seconds. Range 30-14400 (30-3600 for telegram). Default 300 (5 minutes). Requires CUSTOM_OTP_EXPIRY entitlement (Business plan or above). | |
| phone_number | Yes | Destination phone number in international format with NO leading + or 0. Must be 7-15 digits and start with a non-zero digit. Example: '14155551234' for a US number, '447911123456' for a UK number. | |
| template_order | No | Pick a specific message template by its order number (1-99). Requires ACCESS_TO_TEMPLATES entitlement. Not supported on telegram (Telegram generates its own message text). |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| otp | No | The OTP value, present only when return_otp was true. | |
| cost | Yes | Credits charged for this send. | |
| status | Yes | Always 'accepted' on success; delivery state comes from check_otp_status. | |
| message | Yes | Message describing the status of the request. | |
| date_sent | Yes | ISO 8601 date-time the OTP was sent. | |
| expires_at | Yes | ISO 8601 date-time the OTP expires. | |
| message_id | Yes | ID of the message sent. Pass it to verify_otp, check_otp_status and extend_otp. |