Send a code
POST /api/v1/messages with the number and the text. The response gives you a send ID.
223 countries, from $0.0018 per SMS, no monthly feeFrom $0.0018 per SMS
Top-up guideContactOTP SMS API
Your system creates the code, and one API request sends it to the user's phone in any of 223 countries. Each country has a public price, and codes that fail are refunded to your credit.
An OTP (one-time password) SMS carries a short code that works once. It proves the person in front of the screen holds the phone number they gave you. Apps use it at sign-up, at login as a second step (2FA), and before actions such as a payment or a password change.
SMS is still the most common way to deliver these codes because every mobile phone can receive it. There is no app to install and nothing to set up on the user's side.
WorldText is the delivery part. Your backend generates the code, stores it and checks it. Our API takes the text and the number, and sends the message through a route for the user's country.
OTP SMS API
Everything is a JSON request with your API key in a Bearer header. The same endpoints work for every country.
POST /api/v1/messages with the number and the text. The response gives you a send ID.
GET /api/v1/messages/{id} returns the sent, failed and queued counts for that send, so your app can offer a resend when a code fails.
POST /api/v1/quote shows what a message will cost before you send it. GET /api/v1/countries lists every country and its price.
GET /api/v1/balance returns your credit, so you can raise an alert in your own system before it runs low.
The API key is shown once when you create it. If it leaks, make a new key and the old one stops working right away.
Each key allows 120 requests a minute. Keep your own limits per user and per number below that.
Sign up, open the API page in your account and create a key. Store it as a server secret.
Top up from $40. Codes are charged from the same credit as any other message.
When a user asks for a code, generate it, save it with an expiry time and send it with POST /api/v1/messages.
Check the status with the send ID. If it failed, let the user try again after a short wait.
Short, plain and without links. Every example below fits in one part.
[Acme] Your verification code is 604281. Enter it in the app within 10 minutes.
[Acme] 319 552 is your login code. We will never call you to ask for it.
[Acme] Code 772019 resets your password. If you didn't ask for this, ignore this message.
[Acme] Confirm sign-in on a new device with code 145830. It expires in 5 minutes.
A code message is normally one part, so its cost is the country price below. Prices are for 160 Latin characters.
The flow has three steps. The user enters a phone number, your server creates a random code with an expiry time, and your server calls the SMS API with the number and a message that contains the code. The user types the code back and your server compares it with the stored one.
The SMS API never needs to know the code is a code. It only sends the text. Keeping the code on your side means you choose the length, the expiry time and the number of attempts, and you can change them without touching the message delivery.
Always pass numbers in international format, for example +44 7400 123456. Ask for the country in your sign-up form and add the country code before you store the number. Most failed codes to other countries come from a missing or wrong country code.
Prices differ by country, so check GET /api/v1/countries before you open sign-up in a new market. The sender a user sees also differs by country and may be a number. Starting the text with [Acme] tells users who the code is from wherever they are.
Put the brand first, then the code, then how long it lasts. Leave out links: carriers filter many of them, and a link in a code message looks like phishing. A line such as "don't share this code" helps users spot a scam call.
Keep the code message in one part. In Latin text that is 160 characters, but one Unicode character, such as a Korean letter or an emoji, drops the limit to 70. If you translate the message, check the length in each language.
Every code costs money, so a sign-up form that sends codes without limits can be abused. Bots may request thousands of codes to numbers they control, often in expensive countries. Limit requests per phone number, per IP address and per session, and add a wait before a resend.
Only allow countries where you really have users. Watch your spend with GET /api/v1/balance and alert someone when it drops faster than usual. If your API key is ever exposed, create a new one at once, which turns the old key off.
No. Your system creates and checks the code. The API sends the text you give it, which keeps the code logic fully in your control.
Call GET /api/v1/messages/{id} with the id from the send response. It returns how many messages in that send were sent, failed or queued. With one number per request, that is the status of that code.
Yes. Unicode text works in every country. One part then holds 70 characters, so keep the message short.
A request can hold up to 20,000 numbers, but codes are personal, so most apps send one request per code.
Create a new key in your account. The old key stops working right away, and the new one is shown only once.
No. You pay the country price for each code sent, from prepaid credit that does not expire.
Create a free account, make an API key and send a code from your backend with one request.