A one-time password (OTP) is a short code sent to a customer's mobile number to confirm it is really them, for example when they sign up, log in, reset a password or approve a payment. Our OTP SMS API delivers these messages quickly. This article explains the setup, gives a sample request and lists the security practices that matter most.
Before you can send: sender ID and templates
In India, business SMS must follow the telecom regulator's commercial communication rules. In practice this means:
- Sender ID (header): the short name that appears as the sender, usually six characters, such as
PEPPLO. It must be registered. - Template: the exact wording of your OTP message, with a placeholder for the code, must be registered and approved.
- Entity registration: your business must be registered on the DLT (Distributed Ledger Technology) platform used by operators.
Our team guides you through these steps. You can also use our default approved sender and template while you wait, where your package allows. Messages that do not match an approved template will not be delivered.
A typical OTP message
Your verification code for PepploWeb is 482913. It is valid for 5 minutes. Do not share it with anyone.
Sample request
curl -X POST "https://www.pepploweb.com/api/services/v1/otp/send" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"mobile": "98XXXXXX10",
"template_id": "YOUR_TEMPLATE_ID",
"variables": { "otp": "482913" },
"reference_id": "OTP90021"
}'
The response confirms the message has been accepted for delivery. A delivery report, showing whether it reached the handset, may follow by webhook.
Generating and checking the OTP
Your server should generate the code, store a secure hash of it with an expiry time, and send it through the API. When the user enters the code, compare it on your server.
- Use a cryptographically secure random number generator, not a simple counter or timestamp.
- Use 4 to 6 digits and a short expiry, typically a few minutes.
- Allow only a small number of wrong attempts before the code is cancelled.
- Make each code usable only once.
Protecting your account from SMS abuse
Attackers sometimes trigger thousands of OTP requests to random numbers, which costs you money. Protect your forms:
- Limit how many OTPs can be sent to one number and from one IP in a period.
- Add a waiting time before "Resend OTP" becomes available.
- Use a CAPTCHA on public forms.
- Only send OTPs to Indian mobile numbers if that is your market, and validate the format.
- Set a daily spending alert on your wallet.
Delivery tips
- Keep the message short and match the approved template exactly, including spaces and punctuation.
- If many users report not receiving codes, check delivery reports for a pattern, such as one operator.
- Offer an alternative, such as email OTP, for users who repeatedly do not receive SMS.
- Numbers registered on do-not-disturb lists still receive OTPs sent through approved transactional templates.
The examples in this article are simplified to show the flow. Field names, endpoint paths and response formats can differ by service, so always follow the current reference in our API documentation.
Get started
Read more on the OTP SMS API page and check current rates on API pricing. To register a sender ID or template, open a ticket.