OTP and alerts

The code goes out the moment you ask.

A login code, a payment notice, a delivery update: one API call from your own system, handed to the carrier as the API answers. No queue, no sending window, and no extra charge for being quick.

As it arrives

NORTHWIND

Your Northwind code is 482193. It is valid for 5 minutes. Do not share it with anyone.

11:04 AM

Parts
1
Sending window
24 h
Extra for speed
None
Rate, Bangladesh
0.40

No queue

Nothing of ours stands between your request and the carrier.

A verification code that arrives late is worse than none: by then the user has tapped resend twice. So there is no queue to wait in. The API checks the request, charges it and answers; the message is handed to the carrier right behind that answer, every hour of the day.

Sent with the answer

The message leaves as the API responds. A big list being sent at the same second does not hold a code back.

No window

Someone logging in at 2 am gets their code at 2 am. Nothing is held for the morning.

The same rate

A code costs what any message costs: 0.40 credits a part from a number, the masking rate under your sender ID. Nothing on top for speed.

Status by ID

Ask for any message by its ID and see whether it was delivered, and when. A failed one has already given its credits back.

Send and verify

You own the code. We carry it.

We do not generate or check verification codes, on purpose. You make the code, you decide how long it lives, and you compare it on the way back in. We are the delivery layer, so nothing on our side can hand anyone a working code for your application.

The whole integration is the pattern on the right: generate, store with an expiry, send, compare.

  • Six digits is the norm and fits one part with room for your name
  • Keep the digits and the text in plain Latin characters, so the message stays within 160 characters for one part
  • Store a hash of the code rather than the code
  • Keep the returned message ID against the attempt, so you can look it up
Full API reference
PHP
// 1. Make the code and keep a hash of it, with an expiry
$code = str_pad((string) random_int(0, 999999), 6, '0', STR_PAD_LEFT);
Cache::put("otp:{$phone}", hash('sha256', $code), now()->addMinutes(5));

// 2. Send it
$curl = curl_init('https://www.sms.rayenda.com.anjumanara.com/api/v1/sms');
curl_setopt_array($curl, [
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer rs_live_YOUR_KEY',
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => json_encode([
        'to' => $phone,
        'sender_id' => 'NORTHWIND',
        'message' => "Your Northwind code is {$code}. It is valid for 5 minutes.",
    ]),
]);
$sms = json_decode(curl_exec($curl), true);   // $sms['id'] is the message ID

// 3. Compare on the way back in, once
if (hash_equals(Cache::pull("otp:{$phone}") ?? '', hash('sha256', $input))) {
    // verified
}
Node.js
// 1. Make the code and keep a hash of it, with an expiry
const code = String(crypto.randomInt(0, 1000000)).padStart(6, '0');
await redis.setex(`otp:${phone}`, 300, sha256(code));

// 2. Send it
const response = await fetch('https://www.sms.rayenda.com.anjumanara.com/api/v1/sms', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer rs_live_YOUR_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    to: phone,
    sender_id: 'NORTHWIND',
    message: `Your Northwind code is ${code}. It is valid for 5 minutes.`,
  }),
});
const sms = await response.json();   // sms.id is the message ID

// 3. Compare on the way back in, once
const stored = await redis.getdel(`otp:${phone}`);
if (stored && timingSafeEqual(stored, sha256(input))) {
  // verified
}
Request
curl -X POST https://www.sms.rayenda.com.anjumanara.com/api/v1/sms \
  -H "Authorization: Bearer rs_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "8801712345678",
    "sender_id": "NORTHWIND",
    "message": "Your Northwind code is 482193. It is valid for 5 minutes."
  }'
Response · 201
{
  "id": "SMS-7KQ2M9XB4TRW",
  "status": "queued",
  "to": "8801712345678",
  "sender_id": "NORTHWIND",
  "encoding": "gsm",
  "parts": 1,
  "cost": "0.55"
}

Wording

Keep it to one part.

A second part doubles the cost and the phone has to join the two before it shows anything. These three fit in one, counted by the same rule the API uses.

Verification code

Your Northwind code is 482193. It is valid for 5 minutes. Do not share it with anyone.

86 characters · GSM-7 · 1 part

Payment notice

Northwind: a payment of USD 120.00 was received on account 4471 at 11:04. Balance USD 380.00.

93 characters · GSM-7 · 1 part

Delivery update

Northwind: your order #4821 is out for delivery today and should reach you by 6 pm.

83 characters · GSM-7 · 1 part

Good practice

Three habits that save codes and credits.

Resend the same code first

If the first code has not expired, send it again rather than making a new one. It costs the same, and the user never types a code you have already thrown away because the first message arrived after the second.

Cap attempts per number

A few sends per number per hour stops both an impatient user and someone using your sign-up form to bill you for messages to a number they control. Count wrong codes separately and lock after a few.

Act on the error code

invalid_number was never going to work: ask for the number again. rate_limited means more than 600 requests in a minute on one key: wait. insufficient_credits is for your monitoring, not your user.

Security

What we hold, and what we do not.

SMS is not an encrypted channel, and nobody should tell you otherwise. What we can do is keep as little of your verification flow as possible dependent on trusting us.

We never make your codes

There is no endpoint that creates or checks a code. It exists in your system; we only carry the text.

A key tied to your server

Give a key the one IP it may be used from, and it works from nowhere else. Keys are stored as a hash; a revoked one is gone for good.

The text stays in your account

Every message is kept with its text in your Messages page, as it was sent, so you can see what went out. Give a code a short life, not a long one.

SIM swap is still real

A code proves control of a number, not identity. For anything of value, pair it with something else. We would rather say so than let you over-trust the channel.

OTP questions.

Moving a verification flow across? Write to contact@rayenda.com with what it looks like now.

Do I need a sender ID for codes?

No, but it helps. A code that arrives under your own name is harder to imitate, and people hesitate less before typing it. Ask for a sender ID in the panel; it is free, and the message is charged at the masking rate.

How fast does it arrive?

The message is handed to the carrier in the same moment the API answers you; there is no queue of ours in between. From there the time is the carrier's and the handset's, so we do not print a number we cannot keep.

What if my credits run out?

The request is refused with insufficient_credits and nothing is charged, so your program knows at once. The dashboard shows the balance and its date, and we email you before the credits reach it.

Does a code that fails cost anything?

No. A message the carrier cannot deliver gives its credits back on its own, and the refund shows against it in Messages and in your ledger.

Your first code can go out today.

Open an account, get verified, make a key, and send. The pattern above is the whole integration.