OTP

OTP Auth Request

Send a one-time password (OTP) to a recipient. TextPeak generates the code, delivers it using your OTP settings, and returns a request_uuid.

Channels and fallback. Your OTP settings list the channels to try in order (SMS, WhatsApp Business, voice, Telegram). When a channel fails to deliver, the next one is tried automatically. provider pins one channel for a single attempt instead.

Resending. While a code is active, a second request for the same recipient returns 409. Send retry: true to resend on the next channel — the request_uuid stays the same. When no channels are left, retry returns 409 too.

Your end user's IP. Pass client_ip when you call from your backend, so the per-IP limit applies to your user rather than to your server.

Configured in your OTP settings (not request fields): code length (default 5 digits), how long a code stays valid (default 300 seconds), how many codes a recipient may request (default 10) and from one IP, how many wrong codes are allowed (default 5), and the cool-down that resets those counters (default 1800 seconds).

Errors. 401 invalid token · 402 balance depleted · 403 blocked · 409 code already active, or nothing left to retry · 422 invalid phone number or provider · 429 too many requests for this recipient or IP. Errors use the standard error envelope.

Authentication: OTP token (the stream token of an OTP stream) in the Authorization header (see Authentication in the API Overview).

post/otp/auth

Request

  • Base URL
    https://api.commpeak.com/textpeak/streams
  • URL
    https://api.commpeak.com/textpeak/streams/otp/auth
  • Auth
    API key in header Authorization

Request body

recipient_phonestring required

The phone number to send the code to, in international format.

client_ipstring nullable

Your end user's IP address. Used for the per-IP request limit. Defaults to the IP address of the server calling the API, so set it when you call from a backend.

retryboolean nullable

Resend while a code is still active: the code goes out again on the next channel of your OTP settings, under the same request_uuid. Without retry, a second request for the same recipient returns 409.

provider'sms' | 'whatsapp_business' | 'voice' nullable

Send on this one channel instead of the configured channel order. It must be one of your configured channels. A pinned request is a single attempt: no fallback to other channels, and it cannot be retried.

eventstring nullable

Message template for the code, by its eventKey. Defaults to the template in your OTP settings.

template_variablesobject nullable

Extra template values. When your OTP settings say you generate codes yourself, template_variables.code is the code to send and is required.

Response

Successful Response

statusboolean required

true when the code was accepted for sending.

request_uuidstring required

Identifier of this OTP request. Stays the same across retries.

codestring nullable

The code that was sent. Returned only when your OTP settings expose it.

Example response

{
  "request_uuid": "75da8aa5-7381-4947-919c-a07003f266eb",
  "status": true
}

Changes

No recorded changes to this operation across all 1 revision of this API.