Skip to content
Documentation menu

Documentation

Code examples

Send a code from your backend, in the language you already use.

Drop one of these into your backend to send a code. You only pass the recipient; your account routing picks the channel. Replace otp_live_YOUR_API_KEY with a key from the API Keys screen in your dashboard.

curl -X POST https://api.otp.com/api/v1/otp/send \
  -H "Authorization: Bearer otp_live_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"recipient":"+14155552671","locale":"en","client_ip":"81.2.69.142"}'

Every snippet calls the same endpoint, POST /otp/send, with recipient (a phone number in E.164 form, or an email address) and client_ip, the IP of the end user who triggered the OTP; pass it from your request context (for example req.ip), never your server's address. It is optional on the wire, but requests without it share a much tighter rate limit. The response includes an otp_id you pass to verify once the user enters their code. If routing picks WhatsApp, the response also carries an action_url (a wa.me link) the user opens to receive the code over chat, then enters it and you verify it the same way. See WhatsApp verification.

Prefer a typed client?

Official SDKs for Node.js, Python, Go, and PHP wrap the same API with typed methods for send, verify, resend, and status.

Building with an AI agent?

The MCP server exposes the same actions as agent tools, so an assistant can send and verify codes for you. Point it at the llms.txt index, or paste the prompt from the homepage, and it will write and test the integration in one pass.