From $0.0018 per SMS

Top-up guideContact

OTP SMS API

OTP SMS service and API for sign-up codes, login and 2FA

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.

  • Codes to 223 countries
  • REST API with JSON
  • 120 requests a minute per key

What OTP SMS is for

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.

  • 223CountriesMobile numbers in every listed country
  • $0.0018Lowest price per SMSPublic price for every country
  • 20,000Numbers per sendWeb console and each API request
  • $40Minimum top-upBonus credit up to 20%

OTP SMS API

API features for verification codes

Everything is a JSON request with your API key in a Bearer header. The same endpoints work for every country.

Send a code

POST /api/v1/messages with the number and the text. The response gives you a send ID.

Check the status

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.

Know the price first

POST /api/v1/quote shows what a message will cost before you send it. GET /api/v1/countries lists every country and its price.

Watch your credit

GET /api/v1/balance returns your credit, so you can raise an alert in your own system before it runs low.

Key handling

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.

Rate limit you can plan for

Each key allows 120 requests a minute. Keep your own limits per user and per number below that.

Adding SMS verification to your app

  1. Create a key

    Sign up, open the API page in your account and create a key. Store it as a server secret.

  2. Add credit

    Top up from $40. Codes are charged from the same credit as any other message.

  3. Send from your backend

    When a user asks for a code, generate it, save it with an expiry time and send it with POST /api/v1/messages.

  4. Handle the result

    Check the status with the send ID. If it failed, let the user try again after a short wait.

Verification code SMS examples

Short, plain and without links. Every example below fits in one part.

  • Sign-up

    [Acme] Your verification code is 604281. Enter it in the app within 10 minutes.

  • 2FA login

    [Acme] 319 552 is your login code. We will never call you to ask for it.

  • Password reset

    [Acme] Code 772019 resets your password. If you didn't ask for this, ignore this message.

  • New device

    [Acme] Confirm sign-in on a new device with code 145830. It expires in 5 minutes.

Guide to OTP SMS and two-factor authentication

01How does an OTP SMS API work?

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.

02How to send international OTP SMS

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.

03Writing a verification code SMS users trust

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.

04How to protect your OTP flow from abuse

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.

OTP SMS API questions

Does WorldText create the code for me?

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.

How do I know if a code reached the carrier?

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.

Can I send codes in Korean, Japanese or other languages?

Yes. Unicode text works in every country. One part then holds 70 characters, so keep the message short.

Can I send several codes in one request?

A request can hold up to 20,000 numbers, but codes are personal, so most apps send one request per code.

What happens if my API key leaks?

Create a new key in your account. The old key stops working right away, and the new one is shown only once.

Is there a monthly fee for the OTP API?

No. You pay the country price for each code sent, from prepaid credit that does not expire.

All questions

Send your first verification code

Create a free account, make an API key and send a code from your backend with one request.