Send an OTP
POST https://api.telrioz.com/api/v1/otp
Telrioz makes the code from the OTP Gateway's template (its {code}), sends it to one number and keeps it for POST /otp/verify. The code is 6 digits unless the Gateway sets another length, and it must fit in one SMS. While the account's Throttle is on, one number gets at most 5 OTPs a day (WIB).
Fallback. When the Gateway has one, and the first send ends Rejected or Error, or is not Delivered by fallbackAt, Telrioz sends the same code once more on the Gateway's second Route. It does not when the code was verified, or after 3 wrong codes. Each send is charged at its own Route's price, and the code then works for at least 5 more minutes. The second send is a message of its own: your webhook gets a message.status event for it too, with a message ID this call did not return. A slow receipt can start the second send, so one code can be paid for twice.
Authentication
Send your key in the header Authorization: Bearer YOUR_API_KEY. See Authentication.
| Name | Type | Description |
|---|---|---|
torequired | string | One number. Write it as 6281234567890, +62 812-3456-7890 or 081234567890: spaces, dashes and brackets are ignored, a leading + is dropped, a leading 0 becomes 62, and the result must be 8 to 15 digits. A number we cannot read answers 400. |
from | string | The Sender ID: 1 to 11 letters, digits, spaces or the characters . & -, or up to 15 digits. Anything else answers 400, on every Channel. Leave it out to send from the Gateway's Sender ID; it is required when the Gateway has none and its Channel takes one, and then it must be approved for the number's operator. A Channel that takes no Sender ID ignores a valid one: the upstream sends from its own number. |
gateway | string or integer | The ID of the Gateway to send through, as the dashboard shows it. Required with an API key. It must be an OTP Gateway. With a Gateway key, leave it out or give that Gateway's ID. The Gateway sets the Use case, Channel, Route and price, and must be active: a Gateway that is paused or deleted, named or behind a Gateway key, answers 400 invalid_request, |
Request examples
{
"to": "6281234567890",
"gateway": "12"
}{
"to": "6281234567890"
}Limits
- 5 OTPs a day to one number (WIB) while the account's Throttle is on.
- 10 requests a second per account, counted over all its keys.
See Limits.
Responses
200
The code went out.
Fields of the 200 answer Name Type Description idrequiredstringThe OTP's ID, for POST /otp/verify.
torequiredstringThe number the code went to, written as 62…
expiresAtrequiredstringWhen the code stops working: 5 minutes after it is sent.
messageIdrequiredstringThe message that carries the code, for GET /messages/{id}.
fallbackAtrequiredstring or nullWhen the code goes out once more on the Fallback Route if it is not Delivered by then (at once if it fails); null without a Fallback.
sent: Without a Fallback { "id": "5d0f1c9a-2b3e-4f6a-8c7d-9e0a1b2c3d4e", "to": "6281234567890", "expiresAt": "2026-11-15T03:29:10.000Z", "messageId": "c2b1f5e0-3a7e-4b8f-9d2c-1f0e6a5b4c3d", "fallbackAt": null }fallback: With a Fallback after 60 seconds { "id": "5d0f1c9a-2b3e-4f6a-8c7d-9e0a1b2c3d4e", "to": "6281234567890", "expiresAt": "2026-11-15T03:29:10.000Z", "messageId": "c2b1f5e0-3a7e-4b8f-9d2c-1f0e6a5b4c3d", "fallbackAt": "2026-11-15T03:25:10.000Z" }400
invalid_request: The body is not JSON or a field is wrong; message says which. Read message, correct that field and send again.Error codes:
invalid_requestinvalid_request: The body is not JSON or a field is wrong; message says which. { "error": "invalid_request", "message": "to: not a valid phone number" }401
unauthorized: No Bearer key, or a key we do not know. Send the header Authorization: Bearer <key> with a key from Developers → Credentials.key_disabled: The key is switched off. Switch the key on in Developers → Credentials, or use another key.key_expired: The key is past its last day (WIB). Make a new key, or ask your admin to move the key's expiry date.Error codes:
unauthorized,key_disabled,key_expiredunauthorized: No Bearer key, or a key we do not know. { "error": "unauthorized" }key_disabled: The key is switched off. { "error": "key_disabled", "message": "This key is disabled" }key_expired: The key is past its last day (WIB). { "error": "key_expired", "message": "This key expired after 2026-10-31" }402
insufficient_balance: The balance is too low to send the code. Top up the balance, then ask for a new code.Error codes:
insufficient_balanceinsufficient_balance: The balance is too low to send the code. { "error": "insufficient_balance" }403
ip_not_allowed: The request is not from one of the key's allowed IPs. Ask your admin to add this IP to the key's Allowed IPs, or remove the limit.not_active: The account is not active yet. Sign in to the portal and set your password, and finish what the welcome email asks (verify your WhatsApp number, or top up), then try again.suspended: The account is suspended. Contact Telrioz support.sender_not_allowed: The Sender ID is not approved for that number's operator. Use an approved Sender ID, or leave from out to use the Gateway's Sender ID.Error codes:
ip_not_allowed,not_active,suspended,sender_not_allowedip_not_allowed: The request is not from one of the key's allowed IPs. { "error": "ip_not_allowed", "message": "Requests from 203.0.113.7 are not allowed with this key" }not_active: The account is not active yet. { "error": "not_active" }suspended: The account is suspended. { "error": "suspended" }sender_not_allowed: The Sender ID is not approved for that number's operator. { "error": "sender_not_allowed" }409
otp_limit: Already 5 OTPs to this number today. Applies while the account's Throttle is on; it can be switched off. Wait until tomorrow (WIB), or let the user use the code already sent.Error codes:
otp_limitotp_limit: Already 5 OTPs to this number today. Applies while the account's Throttle is on; it can be switched off. { "error": "otp_limit" }412
no_route: There is no Route, or no price, for that number's operator yet. Contact Telrioz support to add the Route.Error codes:
no_routeno_route: There is no Route, or no price, for that number's operator yet. { "error": "no_route" }422
no_gateway: The Gateway was paused while the request was in flight, so the code could not go out. A Gateway that is paused or deleted before the request answers 400 invalid_request instead. Switch the Gateway on in Messaging → Gateways, or name another active OTP Gateway in gateway, then ask for a new code.Error codes:
no_gatewayno_gateway: The Gateway was paused while the request was in flight, so the code could not go out. A Gateway that is paused or deleted before the request answers 400 invalid_request instead. { "error": "no_gateway" }429
The limit is 10 requests per second per account, counted over all its keys.
rate_limited: More than 10 requests a second on this account. Wait a second and send again; space calls out, or send many numbers in one call.throttled: More messages a second than the account's speed limit. Wait a moment and try again.Error codes:
rate_limited,throttledrate_limited: More than 10 requests a second on this account. { "error": "rate_limited" }throttled: More messages a second than the account's speed limit. { "error": "throttled" }500
internal: Something failed on our side. Try again; if it keeps happening, contact Telrioz support.Error codes:
internalinternal: Something failed on our side. { "error": "internal" }503
unavailable: Telrioz could not take the message right now. Try again in a few seconds.Error codes:
unavailableunavailable: Telrioz could not take the message right now. { "error": "unavailable" }