Chatilo
USDPrices shown in US dollars Sign in Start free trial
API reference

One-time codes

Verify a phone number from your own website or app. Ask for a code to be sent on WhatsApp or SMS, then check what the person typed. The code is made here, expires by itself and is never returned to you, so it cannot leak from your server. To send any other notification, use Send a message with an approved template.

Send a code #

POST/api/v1/otp

Needs a read-and-write key

Makes a one-time code and sends it. On WhatsApp it goes in an approved template: an authentication template (the code also fills its copy-code button), or any template whose first body variable takes the code. By SMS it goes as a short text from the workspace’s SMS account. A new code replaces the earlier one for the same number.

Body JSON

tostringrequired
The phone number with its country code.
channelstring
whatsapp (the default) or sms.
templatestring
For WhatsApp: the name of the approved template that carries the code. Required on WhatsApp.
languagestring
The template’s language code. en when left out.
number_idinteger
Which WhatsApp number sends it, when the workspace has several.
lengthinteger
Digits in the code: 4 to 8. 6 when left out.
expires_ininteger
Minutes the code is good for: 1 to 30. 10 when left out.

Returns HTTP 201

okboolean
Always true on success.
otpobject
As {"id", "to", "channel", "expires_at"}. The code itself is never returned.

Errors

401unauthorized
The Authorization header is missing, or the key is wrong or deleted.
403read_only_key
A read-only key was used for a request that changes something.
422invalid_channel
channel is not whatsapp or sms.
422invalid_phone
to has no country code or is not a phone number.
422no_number
No WhatsApp number is connected.
422no_sms_account
No SMS account is connected.
422template_not_found
No approved template with that name and language on the number.
429otp_throttled
A code went to this number in the last 30 seconds, or five in the last hour.
429rate_limited
More than 120 requests in a minute with this key. Wait for the seconds in Retry-After.
502send_failed
WhatsApp or the SMS provider refused the message.

Plus the errors any request can get.

Request
curl -X POST "https://chatilo.me/api/v1/otp" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "+919876543210",
    "channel": "whatsapp",
    "template": "login_code"
}'
<?php
$apiKey = 'YOUR_API_KEY';

$ch = curl_init('https://chatilo.me/api/v1/otp');
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $apiKey, 'Content-Type: application/json'],
    CURLOPT_POSTFIELDS => json_encode([
        'to' => '+919876543210',
        'channel' => 'whatsapp',
        'template' => 'login_code',
    ]),
]);
$result = json_decode((string) curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);

if ($status >= 400) {
    throw new RuntimeException($result['error']['code'] . ': ' . $result['error']['message']);
}
print_r($result);
const apiKey = 'YOUR_API_KEY';

const response = await fetch("https://chatilo.me/api/v1/otp", {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${apiKey}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
      "to": "+919876543210",
      "channel": "whatsapp",
      "template": "login_code"
  }),
});
const result = await response.json();

if (!response.ok) {
  throw new Error(`${result.error.code}: ${result.error.message}`);
}
console.log(result);
import requests

api_key = "YOUR_API_KEY"

response = requests.post(
    "https://chatilo.me/api/v1/otp",
    headers={"Authorization": f"Bearer {api_key}"},
    json={
        "to": "+919876543210",
        "channel": "whatsapp",
        "template": "login_code",
    },
    timeout=30,
)
result = response.json()

if not response.ok:
    raise RuntimeError(f"{result['error']['code']}: {result['error']['message']}")
print(result)
Response · HTTP 201
{
    "ok": true,
    "otp": {
        "id": 501,
        "to": "919876543210",
        "channel": "whatsapp",
        "expires_at": "2026-01-31T09:40:00Z"
    }
}

Check a code #

POST/api/v1/otp/verify

Needs a read-and-write key

Checks the code a person typed. The answer is verified true once, for the right code; after that the code is spent. A wrong or expired code is not an error: verified is false and reason says why. Five wrong tries lock the code.

Body JSON

tostringrequired
The phone number the code was sent to.
codestringrequired
The code the person typed.

Returns HTTP 200

okboolean
Always true on success.
verifiedboolean
True when the code was right.
reasonstring or null
When verified is false: wrong_code, expired, too_many_attempts or not_found.

Errors

401unauthorized
The Authorization header is missing, or the key is wrong or deleted.
403read_only_key
A read-only key was used for a request that changes something.
422invalid_phone
to has no country code or is not a phone number.
429rate_limited
More than 120 requests in a minute with this key. Wait for the seconds in Retry-After.

Plus the errors any request can get.

Request
curl -X POST "https://chatilo.me/api/v1/otp/verify" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "+919876543210",
    "code": "482913"
}'
<?php
$apiKey = 'YOUR_API_KEY';

$ch = curl_init('https://chatilo.me/api/v1/otp/verify');
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $apiKey, 'Content-Type: application/json'],
    CURLOPT_POSTFIELDS => json_encode([
        'to' => '+919876543210',
        'code' => '482913',
    ]),
]);
$result = json_decode((string) curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);

if ($status >= 400) {
    throw new RuntimeException($result['error']['code'] . ': ' . $result['error']['message']);
}
print_r($result);
const apiKey = 'YOUR_API_KEY';

const response = await fetch("https://chatilo.me/api/v1/otp/verify", {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${apiKey}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
      "to": "+919876543210",
      "code": "482913"
  }),
});
const result = await response.json();

if (!response.ok) {
  throw new Error(`${result.error.code}: ${result.error.message}`);
}
console.log(result);
import requests

api_key = "YOUR_API_KEY"

response = requests.post(
    "https://chatilo.me/api/v1/otp/verify",
    headers={"Authorization": f"Bearer {api_key}"},
    json={
        "to": "+919876543210",
        "code": "482913",
    },
    timeout=30,
)
result = response.json()

if not response.ok:
    raise RuntimeError(f"{result['error']['code']}: {result['error']['message']}")
print(result)
Response · HTTP 200
{
    "ok": true,
    "verified": true,
    "reason": null
}

Cookies on this site

We use the cookies needed to run the site and keep you signed in. With your OK we also remember choices you make here, such as the currency for prices. We don’t use advertising or tracking cookies. Cookie policy