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
Passcallback when you send:
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.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).
Content-Type: application/json and User-Agent: Otpbay-Webhook/1.
Respond to webhooks
Return any2xx status within 15 seconds. The response body is ignored.
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
sidand 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
sidandstatus, and ignore updates you’ve already handled. - Respond fast. Acknowledge right away and do slow work in a background job.
Express