Skip to main content
POST
Send a Telegram code

Authorizations

Authorization
string
header
required

Your project API key, sent as Authorization: Bearer otp_live_.... Create keys on the API Keys page of the dashboard.

Body

application/json
to
string
required

Destination phone number in international format. OTPBay normalizes it to E.164, so +1 (415) 555-2671 becomes +14155552671.

Example:

"+14155552671"

code
string

Code to send, 4–8 digits. Leave it out and Telegram generates a code with the code length from your Telegram settings; then check it with Verify a Telegram code.

Pattern: ^\d{4,8}$
Example:

"482913"

metadata
object

Your own key-value data, returned in responses and webhooks. At most 32 keys of 1–64 characters. Values are strings (up to 512 characters), numbers or booleans.

Example:
callback
string<uri>

Public http or https URL that receives status webhooks. Localhost, private and link-local addresses are rejected. Defaults to the channel's default callback from project settings.

Maximum string length: 2048
Example:

"https://example.com/webhooks/otpbay"

Response

The code was handed to Telegram.

sid
string
required

Unique Telegram code ID.

Pattern: ^TG[a-f0-9]{24}$
Example:

"TG6650c52ad3e4f5a6b7c8d9e0"

status
enum<string>
required

Delivery status reported by Telegram. failed means the code never reached Telegram.

Available options:
sending,
sent,
delivered,
read,
expired,
revoked,
failed
verification_status
enum<string> | null
required

Result of the latest code check, or null before the first check.

Available options:
code_valid,
code_invalid,
code_max_attempts_exceeded,
expired,
null
to
string
required

Destination phone number in international format. OTPBay normalizes it to E.164, so +1 (415) 555-2671 becomes +14155552671.

Example:

"+14155552671"

code_length
integer
required

Number of digits in the code.

Example:

6

cost
string
required

What this code currently costs. 0.00 after a refund.

Pattern: ^\d+\.\d{2}$
Example:

"0.02"

date_created
string<date-time>
required
expires_at
string<date-time>
required
delivered_at
string<date-time> | null
required
verified_at
string<date-time> | null
required
metadata
object
required

Your own key-value data, returned in responses and webhooks. At most 32 keys of 1–64 characters. Values are strings (up to 512 characters), numbers or booleans.

Example:
last_error
string

Why the code couldn't be sent. Only present when there is one.