Skip to main content
Instead of polling, give OTPBay a callback URL. When the status of a verification, SMS or Telegram code changes, OTPBay sends a POST request to that URL with the new status.

Set a callback URL

Pass callback when you send:
Or set a default callback URL for each channel in the dashboard: Messaging → Verify, SMS or Telegram. A callback in the request overrides the default. The URL must use http or https and point at a public host. localhost, private network, link-local and cloud metadata addresses are rejected with 422 INVALID_REQUEST_BODY. To test locally, use a tunnel such as ngrok.

When webhooks are sent

Verify sends only the verify webhook. The Telegram and SMS messages it sends on your behalf don’t send their own webhooks.
Telegram doesn’t push status changes, so OTPBay checks for them about 5, 15, 30, 60, 120 and 300 seconds after sending, and once more just after the code expires. A delivered webhook can arrive a little after the actual delivery.

Payload

Every channel sends the same JSON body:
string
ID of the verification (VE…), SMS (SM…) or Telegram code (TG…).
string
verify, sms or telegram.
string
The new status.
string
Destination phone number in E.164 format.
string
Current cost in US dollars, after refunds.
object
The metadata you sent with the request.
string | null
The error message when the status is a failure, otherwise null.
string
When the object was created (ISO 8601).
string
When the object last changed (ISO 8601).
The request has the headers Content-Type: application/json and User-Agent: Otpbay-Webhook/1.

Respond to webhooks

Return any 2xx status within 15 seconds. The response body is ignored.
OTPBay delivers each webhook once and doesn’t retry. If your endpoint is down, fetch the object by sid to get its latest status.

Handle webhooks safely

  • Treat webhooks as hints. Webhooks aren’t signed. Before acting on one — for example, marking a phone number verified — fetch the object from the API with its sid and check the status there.
  • Use a hard-to-guess URL. Add a secret to the path, such as /webhooks/otpbay/4f9c2a..., and reject requests to any other path.
  • Expect duplicates and any order. Key your processing on sid and status, and ignore updates you’ve already handled.
  • Respond fast. Acknowledge right away and do slow work in a background job.
Express
See the status webhook reference for the full schema.