Everything worth knowing, nothing that isn't.
Generate and store securely
Create a 4–8 digit code server-side, store only a hash of it with a short TTL (5–10 minutes), and bind it to the user and channel. Never send the code to the client for comparison — verify on the server. See /answers/what-is-otp.
Send with a fallback
Deliver over a direct, high-priority route and configure a fallback channel (flash call, WhatsApp, or voice) so a delayed SMS does not block the user. See /answers/best-channel-for-otp and /answers/sms-fallback-strategy.
Verify with limits
Check the user's input against the stored hash, cap attempts before forcing a resend, invalidate on success, and expire quickly. See /answers/sms-otp-best-practices.
Rate-limit and monitor
Limit requests per number and per IP to resist SMS pumping, and watch for spikes to unusual destinations. Consider silent network authentication to avoid sending a billable code at all. See /answers/what-is-sms-pumping and /answers/what-is-silent-network-auth.