{"id":19640,"date":"2026-11-19T01:27:50","date_gmt":"2026-11-18T19:57:50","guid":{"rendered":"https:\/\/www.fast2sms.com\/help\/otp-widget-html-website-fast2sms\/"},"modified":"2026-11-19T01:27:50","modified_gmt":"2026-11-18T19:57:50","slug":"otp-widget-html-website-fast2sms","status":"publish","type":"post","link":"https:\/\/www.fast2sms.com\/help\/otp-widget-html-website-fast2sms\/","title":{"rendered":"Add OTP verification to an HTML form in 2 lines (Fast2SMS OTP widget)"},"content":{"rendered":"<p>You can add OTP verification to any HTML website or form with two lines: one script tag and one <code>&lt;div data-f2s-otp&gt;<\/code>. Visitors type their mobile number, get a code by SMS or WhatsApp through Fast2SMS <strong>Smart OTP<\/strong>, and your page gets a signed token once the number is verified. This guide shows the log-in box, the <code>data-f2s-protect<\/code> mode that makes an existing form wait for OTP, and the one server check (<code>f2s_token<\/code>) you must not skip.<\/p>\n<aside class=\"f2s-cta\" aria-label=\"Get started with Fast2SMS\"><div class=\"f2s-cta__copy\"><strong class=\"f2s-cta__title\">Add OTP to your website form<\/strong><p>Create a Smart OTP template, run a small backend and verify numbers by SMS or WhatsApp.<\/p><\/div><div class=\"f2s-cta__actions\"><a class=\"f2s-cta__btn f2s-cta__btn--primary\" href=\"https:\/\/www.fast2sms.com\/\"><span>Sign up free<\/span> <span class=\"f2sh-btn__arrow\" aria-hidden=\"true\">&rarr;<\/span><\/a><a class=\"f2s-cta__btn f2s-cta__btn--ghost\" href=\"https:\/\/www.fast2sms.com\/meet\/\" target=\"_blank\" rel=\"noopener\">Book a free meeting<\/a><\/div><\/aside>\n<p class=\"f2s-kit-wrap\"><a class=\"f2s-kit\" href=\"https:\/\/www.fast2sms.com\/help\/wp-content\/uploads\/2026\/11\/fast2sms-otp-widget-plain-html.zip\" download><svg class=\"f2s-kit__icon\" width=\"28\" height=\"28\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path fill=\"#7F56D9\" d=\"M6 2h8l6 6v12a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2z\"\/><path fill=\"#FFFFFF\" d=\"M14 2v6h6\"\/><path fill=\"#FFFFFF\" d=\"M9 6h2v2H9zm2 2h2v2h-2zM9 10h2v2H9zm2 2h2v2h-2zm-2 2h4v4H9z\"\/><rect x=\"10\" y=\"15.4\" width=\"2\" height=\"1.6\" fill=\"#7F56D9\"\/><\/svg><span class=\"f2s-kit__text\"><strong>Download the plain HTML OTP widget example (zip)<\/strong><span class=\"f2s-kit__meta\">fast2sms-otp-widget-plain-html.zip &middot; 27 KB<\/span><\/span><span class=\"f2s-kit__btn\">Download .zip<\/span><\/a><\/p>\n<p class=\"f2s-kit-wrap\"><a class=\"f2s-kit\" href=\"https:\/\/www.fast2sms.com\/help\/wp-content\/uploads\/2026\/11\/fast2sms-otp-widget-all.zip\" download><svg class=\"f2s-kit__icon\" width=\"28\" height=\"28\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path fill=\"#7F56D9\" d=\"M6 2h8l6 6v12a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2z\"\/><path fill=\"#FFFFFF\" d=\"M14 2v6h6\"\/><path fill=\"#FFFFFF\" d=\"M9 6h2v2H9zm2 2h2v2h-2zM9 10h2v2H9zm2 2h2v2h-2zm-2 2h4v4H9z\"\/><rect x=\"10\" y=\"15.4\" width=\"2\" height=\"1.6\" fill=\"#7F56D9\"\/><\/svg><span class=\"f2s-kit__text\"><strong>Download the complete OTP widget kit (zip)<\/strong><span class=\"f2s-kit__meta\">fast2sms-otp-widget-all.zip &middot; 1 MB<\/span><\/span><span class=\"f2s-kit__btn\">Download .zip<\/span><\/a><\/p>\n<h2>How the OTP widget works<\/h2>\n<ol>\n<li>Your page loads <code>f2s-otp-widget.min.js<\/code> (one file, no other libraries).<\/li>\n<li>The widget posts the mobile number to <strong>your own backend<\/strong>, for example <code>\/f2s-otp<\/code>.<\/li>\n<li>Your backend checks its limits and then calls Fast2SMS Smart OTP with your API key and OTP ID.<\/li>\n<li>The visitor types the code. The backend verifies it and gives the page a signed, one-time token.<\/li>\n<li>Your form handler checks that token before it trusts the number.<\/li>\n<\/ol>\n<p>The Fast2SMS API key never reaches the browser. Anything in a web page can be read by any visitor, so the key stays in the backend&#8217;s settings.<\/p>\n<h2>Before you start<\/h2>\n<ul>\n<li>A Fast2SMS account with wallet balance.<\/li>\n<li>An approved DLT OTP template (for SMS) or an approved WhatsApp Authentication or Utility template.<\/li>\n<li>Somewhere to run one backend file: normal PHP hosting is enough, or Node.js, Python or a serverless host.<\/li>\n<li>Indian mobile numbers. Smart OTP sends to 10-digit numbers starting with 6 to 9.<\/li>\n<\/ul>\n<h2>Set up OTP verification on an HTML page<\/h2>\n<ol class=\"f2s-steps\">\n<li>\n<h3>Create a Smart OTP template and copy its OTP ID<\/h3>\n<p>In the Fast2SMS panel, open <strong>Smart OTP<\/strong> &gt; <strong>OTP Template List<\/strong> and click <strong>Add OTP Template<\/strong>. Pick <strong>SMS Channel<\/strong> with your approved DLT OTP template, or <strong>WhatsApp Channel<\/strong> with an approved Authentication or Utility template. You can add a fallback on the other channel. Then copy the 10-character <strong>OTP ID<\/strong> from the card. It decides the channel, the template and the fallback for every code the widget sends.<\/p>\n<figure class=\"f2s-shot\"><img src=\"https:\/\/www.fast2sms.com\/help\/wp-content\/uploads\/2026\/11\/smart-otp-template-list-hd-28-scaled.webp\" width=\"1440\" height=\"900\" loading=\"lazy\" decoding=\"async\" alt=\"Smart OTP Template page with WhatsApp and SMS OTP template cards, each showing its OTP ID, sender or number, template ID and fallback\"><figcaption>Copy the OTP ID from the template card.<\/figcaption><\/figure>\n<\/li>\n<li>\n<h3>Run a backend that holds your API key<\/h3>\n<p>The widget never calls Fast2SMS. It calls a small backend that you run, and only that backend knows your API key. The full kit has ready backends for PHP hosting (one file), Node.js with Express, Python Flask, Django, Laravel, Cloudflare Workers, Vercel or Netlify functions and Google Apps Script (see the OTP widget overview). Copy the key from <strong>API Key<\/strong> under UTILITY in the panel, and give the backend these three settings:<\/p>\n<pre><code class=\"language-bash\">FAST2SMS_API_KEY=YOUR_API_KEY\nF2S_OTP_ID=YOUR_OTP_ID\nF2S_TOKEN_SECRET=at-least-32-random-characters<\/code><\/pre>\n<p><code>F2S_TOKEN_SECRET<\/code> is any random text of 32 or more characters. The backend will not start (or, on PHP and serverless hosts, refuses every request) if one of these is missing or wrong.<\/p>\n<figure class=\"f2s-shot\"><img src=\"https:\/\/www.fast2sms.com\/help\/wp-content\/uploads\/2026\/11\/api-key-hd-30-scaled.webp\" width=\"1440\" height=\"900\" loading=\"lazy\" decoding=\"async\" alt=\"API Key page with the masked Authorization Key, View and Reset buttons and the API Access switch turned on\"><figcaption>The key goes into your backend settings only.<\/figcaption><\/figure>\n<\/li>\n<li>\n<h3>Add the two lines to your page<\/h3>\n<p>Copy <code>f2s-otp-widget.min.js<\/code> next to your page and add:<\/p>\n<pre><code class=\"language-html\">&lt;script src=\"f2s-otp-widget.min.js\" defer&gt;&lt;\/script&gt;\n&lt;div data-f2s-otp data-endpoint=\"\/f2s-otp\" data-on-verified=\"onLogin\"&gt;&lt;\/div&gt;<\/code><\/pre>\n<p><code>data-endpoint<\/code> is your backend URL, never fast2sms.com. With the PHP kit it is <code>\/f2s-otp.php<\/code>, on Vercel or Netlify <code>\/api\/f2s-otp<\/code>, and with the Cloudflare Worker kit the full Worker URL. The box shows a mobile field with +91 and a <strong>Send OTP<\/strong> button.<\/p>\n<figure class=\"f2s-shot\"><img src=\"https:\/\/www.fast2sms.com\/help\/wp-content\/uploads\/2026\/11\/otp-widget-phone-step-2x.webp\" width=\"520\" height=\"800\" loading=\"lazy\" decoding=\"async\" alt=\"Web page with the OTP widget: a mobile number field with +91 and a Send OTP button, and below it a sign-up form with a Verify mobile number button\"><figcaption>Top: the log-in box. Bottom: a form that needs a verified number.<\/figcaption><\/figure>\n<\/li>\n<li>\n<h3>Send the token to your server<\/h3>\n<p>When the number is verified, the widget calls the function named in <code>data-on-verified<\/code> with <code>token<\/code>, <code>mobile<\/code>, <code>masked<\/code> and <code>expiresIn<\/code>. Post the token to your own log-in or sign-up route:<\/p>\n<pre><code class=\"language-html\">&lt;script&gt;\n  function onLogin(d) {\n    fetch('\/login', {\n      method: 'POST',\n      headers: { 'Content-Type': 'application\/json' },\n      body: JSON.stringify({ f2s_token: d.token })\n    });\n  }\n&lt;\/script&gt;<\/code><\/pre>\n<figure class=\"f2s-shot\"><img src=\"https:\/\/www.fast2sms.com\/help\/wp-content\/uploads\/2026\/11\/otp-widget-code-step-2x.webp\" width=\"520\" height=\"860\" loading=\"lazy\" decoding=\"async\" alt=\"OTP widget after Send OTP: six code boxes, a Verify button, a Resend code countdown and the text Code sent\"><figcaption>After Send OTP: six code boxes and a Resend countdown.<\/figcaption><\/figure>\n<\/li>\n<\/ol>\n<h2>Make an existing form wait for OTP (data-f2s-protect)<\/h2>\n<p>If you already have a sign-up, enquiry or order form, you do not need a separate box. Add <code>data-f2s-protect<\/code> and <code>data-endpoint<\/code> to the <code>&lt;form&gt;<\/code> tag. The form then cannot be submitted until the number is verified, and the widget adds a hidden field named <code>f2s_token<\/code>.<\/p>\n<pre><code class=\"language-html\">&lt;form action=\"\/signup\" method=\"post\" data-f2s-protect data-endpoint=\"\/f2s-otp\" data-mobile-field=\"phone\"&gt;\n  &lt;input name=\"name\" required&gt;\n  &lt;input name=\"phone\" type=\"tel\" required&gt;\n  &lt;div data-f2s-slot&gt;&lt;\/div&gt;\n  &lt;button type=\"submit\"&gt;Create account&lt;\/button&gt;\n&lt;\/form&gt;<\/code><\/pre>\n<ul>\n<li><code>data-mobile-field<\/code> points at your own phone input. Without it, the widget shows its own phone field.<\/li>\n<li><code>data-f2s-slot<\/code> marks where the OTP box goes. Without it, the box goes just before the submit button.<\/li>\n<li>If the visitor edits the phone field after verifying, the token is cleared and they verify again.<\/li>\n<li><code>data-auto-submit<\/code> submits the form right after verification.<\/li>\n<\/ul>\n<h2>Check f2s_token on the server<\/h2>\n<p>This step is the one that actually protects you. The hidden field stops normal visitors who skip the OTP, but a bot can post your form directly. Your form handler must check the token with the kit&#8217;s helper and reject the request if it fails. Use the number the helper returns, not the posted field.<\/p>\n<pre><code class=\"language-js\">\/\/ Node.js \/ Express backend kit\nconst v = await otp.verifyToken(req.body.f2s_token, { mobile: req.body.phone });\nif (&#33;v) return res.status(403).send('Mobile number not verified.');\n\/\/ v.mobile is the verified 10-digit number. A token works only once.<\/code><\/pre>\n<pre><code class=\"language-php\">&lt;?php\n\/\/ PHP single-file backend kit\nrequire __DIR__ . '\/f2s-otp.php';\n$v = \\F2sOtp\\verify_token($_POST['f2s_token'] ?? '', $_POST['phone'] ?? null);\nif ($v === null) { http_response_code(403); exit('Mobile number not verified.'); }\n\/\/ $v['mobile'] is the verified 10-digit number.<\/code><\/pre>\n<p>The helper checks the signature, the expiry (10 minutes by default) and that the token belongs to that number. A token works only once.<\/p>\n<aside class=\"f2s-cta\" aria-label=\"Get started with Fast2SMS\"><div class=\"f2s-cta__copy\"><strong class=\"f2s-cta__title\">Verify mobile numbers on your site<\/strong><p>Sign up for Fast2SMS, create your OTP ID and stop fake numbers on your forms.<\/p><\/div><div class=\"f2s-cta__actions\"><a class=\"f2s-cta__btn f2s-cta__btn--primary\" href=\"https:\/\/www.fast2sms.com\/\"><span>Sign up free<\/span> <span class=\"f2sh-btn__arrow\" aria-hidden=\"true\">&rarr;<\/span><\/a><a class=\"f2s-cta__btn f2s-cta__btn--ghost\" href=\"https:\/\/www.fast2sms.com\/meet\/\" target=\"_blank\" rel=\"noopener\">Book a free meeting<\/a><\/div><\/aside>\n<h2>Useful attributes<\/h2>\n<div class=\"f2s-facts\">\n<table>\n<thead>\n<tr>\n<th>Attribute<\/th>\n<th>What it does<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>data-endpoint<\/code><\/td>\n<td>Your backend URL (required).<\/td>\n<\/tr>\n<tr>\n<td><code>data-otp-id<\/code><\/td>\n<td>Use another OTP ID, for example a WhatsApp-only template. The backend accepts it only if it is in its <code>F2S_OTP_IDS<\/code> list.<\/td>\n<\/tr>\n<tr>\n<td><code>data-title<\/code><\/td>\n<td>A heading above the box.<\/td>\n<\/tr>\n<tr>\n<td><code>data-send-text<\/code>, <code>data-verify-text<\/code><\/td>\n<td>Button texts (default <strong>Send OTP<\/strong> and <strong>Verify<\/strong>).<\/td>\n<\/tr>\n<tr>\n<td><code>data-token-name<\/code><\/td>\n<td>Name of the hidden field on a protected form (default <code>f2s_token<\/code>).<\/td>\n<\/tr>\n<tr>\n<td><code>data-captcha<\/code>, <code>data-captcha-sitekey<\/code><\/td>\n<td>Turnstile or reCAPTCHA, when the backend has <code>F2S_CAPTCHA<\/code> on.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Colours and sizes are CSS variables, for example <code>.f2s-otp { --f2s-primary: #0f766e; --f2s-radius: 4px; }<\/code>. The first code box has <code>autocomplete=\"one-time-code\"<\/code>, so phone keyboards can offer the code from the SMS, and a pasted code fills all the boxes.<\/p>\n<h2>Where to paste it on a site builder<\/h2>\n<ul>\n<li><strong>Webflow:<\/strong> the script in Page settings &gt; Custom code (before <code>&lt;\/body&gt;<\/code>), the <code>&lt;div&gt;<\/code> in an Embed element.<\/li>\n<li><strong>Wix:<\/strong> put the script and the <code>&lt;div&gt;<\/code> in the same Embed HTML element, and use the full <code>https:\/\/<\/code> backend URL.<\/li>\n<li><strong>Backend on another domain:<\/strong> add your site&#8217;s origin to the backend&#8217;s <code>F2S_ALLOWED_ORIGINS<\/code>, for example <code>https:\/\/www.example.com<\/code>.<\/li>\n<\/ul>\n<h2>Limits and cost<\/h2>\n<p>The backend checks these limits before it makes any paid call. Change them with settings, not code.<\/p>\n<div class=\"f2s-facts\">\n<table>\n<thead>\n<tr>\n<th>Backend setting<\/th>\n<th>Default<\/th>\n<th>What it does<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>F2S_RESEND_WAIT<\/code><\/td>\n<td>30 seconds<\/td>\n<td>Wait between two sends to one number.<\/td>\n<\/tr>\n<tr>\n<td><code>F2S_LIMIT_PER_NUMBER<\/code><\/td>\n<td>5 per hour<\/td>\n<td>Sends to one mobile number.<\/td>\n<\/tr>\n<tr>\n<td><code>F2S_LIMIT_PER_IP<\/code><\/td>\n<td>20 per hour<\/td>\n<td>Sends from one IP address.<\/td>\n<\/tr>\n<tr>\n<td><code>F2S_LIMIT_VERIFY_PER_IP<\/code><\/td>\n<td>60 per hour<\/td>\n<td>Verify calls from one IP address.<\/td>\n<\/tr>\n<tr>\n<td><code>F2S_MAX_VERIFY<\/code><\/td>\n<td>5<\/td>\n<td>Wrong codes allowed for one code.<\/td>\n<\/tr>\n<tr>\n<td><code>F2S_TOKEN_TTL<\/code><\/td>\n<td>600 seconds<\/td>\n<td>How long the verified token lasts.<\/td>\n<\/tr>\n<tr>\n<td><code>F2S_CAPTCHA<\/code><\/td>\n<td>off<\/td>\n<td><code>turnstile<\/code> or <code>recaptcha<\/code>, with <code>F2S_CAPTCHA_SECRET<\/code>.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p><strong>Resend sends the same code again.<\/strong> Fast2SMS allows it within 10 minutes of the first send, up to 5 sends in total. Sending a fresh code for a number cancels the older code. If the template has a fallback and the first channel fails, Fast2SMS sends the same code once on the other channel.<\/p>\n<p>Each send and each resend is charged at your Smart OTP rate. Verify is free. If a fallback message goes out on the second channel, that message is charged too, and so is a <strong>Test OTP<\/strong> from the template card, because it is a real send. See the current rates on the <a href=\"https:\/\/www.fast2sms.com\/otp-sms\">Smart OTP page<\/a>.<\/p>\n<div class=\"f2s-note f2s-volume\"><p><strong>Sending in bulk?<\/strong> For high OTP volumes our team offers discounted rates. <a href=\"https:\/\/www.fast2sms.com\/meet\/\" target=\"_blank\" rel=\"noopener\">Talk to our team<\/a> or see <a href=\"https:\/\/www.fast2sms.com\/bulk-sms-pricing\">OTP pricing<\/a>.<\/p><\/div>\n<h2>How this example was tested<\/h2>\n<p>This page is the demo page of every backend in the kit. It was run in headless Chrome against the PHP, Node.js, Python Flask, Django, Cloudflare Worker, Vercel and Netlify backends, 47 checks each, against a test server that answers like Fast2SMS. No real SMS was sent in these tests, so do one live send with your own template before you go live.<\/p>\n<h2>Common problems and fixes<\/h2>\n<div class=\"f2s-facts\">\n<table>\n<thead>\n<tr>\n<th>What the visitor sees<\/th>\n<th>Why<\/th>\n<th>Fix<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>&#8220;This page is not allowed to use this OTP service.&#8221;<\/td>\n<td>The page is not on the backend&#8217;s domain or in <code>F2S_ALLOWED_ORIGINS<\/code>.<\/td>\n<td>Add the exact origin (<code>https:\/\/<\/code> plus domain, no path).<\/td>\n<\/tr>\n<tr>\n<td>&#8220;We could not send the code right now.&#8221;<\/td>\n<td>An account problem: API key, OTP ID, wallet balance or template.<\/td>\n<td>Read the backend log. It names the real reason.<\/td>\n<\/tr>\n<tr>\n<td>&#8220;Could not reach the server.&#8221;<\/td>\n<td>Wrong <code>data-endpoint<\/code>, backend down, or CORS.<\/td>\n<td>Open the endpoint URL and check the browser console.<\/td>\n<\/tr>\n<tr>\n<td>Nothing shows<\/td>\n<td>The script did not load, or <code>data-f2s-otp<\/code> is missing.<\/td>\n<td>Check the script path. For a div added later, call <code>Fast2smsOtp.init()<\/code>.<\/td>\n<\/tr>\n<tr>\n<td>&#8220;Code sent&#8221; but no SMS<\/td>\n<td>Sent means Fast2SMS accepted it, not that the phone got it.<\/td>\n<td>Check <strong>Smart OTP<\/strong> &gt; <strong>Delivery Report<\/strong>.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<section class=\"f2s-faq\">\n<h2>Frequently asked questions<\/h2>\n<h3>Can I add OTP verification to a website without a backend?<\/h3>\n<p>No. Some server has to hold the API key, because a key in a web page can be copied by anyone. If you have no server, the kit&#8217;s Cloudflare Worker backend works on Cloudflare&#8217;s free tier, a Vercel or Netlify function is another option, and the Google Apps Script backend gives you a hosted form.<\/p>\n<h3>Does the widget work with WhatsApp OTP?<\/h3>\n<p>Yes. The channel comes from your OTP ID. If its template is on WhatsApp, or has a WhatsApp fallback, the same widget is used and the visitor gets the code on WhatsApp.<\/p>\n<h3>What is f2s_token?<\/h3>\n<p>It is a hidden field the widget adds to a protected form after verification. It holds a signed token that proves the number was verified a moment ago. Your server checks it with the kit&#8217;s helper; the token works once and lasts 10 minutes by default.<\/p>\n<h3>Is the OTP widget free?<\/h3>\n<p>The kit is free under the MIT license. You pay only for the OTPs you send from your Fast2SMS wallet. Verify calls are free.<\/p>\n<h3>Does Resend send a new code?<\/h3>\n<p>No. Resend sends the same code again, within 10 minutes of the first send and up to 5 sends in total. Each resend is charged.<\/p>\n<h3>Can I change the look of the OTP box?<\/h3>\n<p>Yes. Every colour and size is a CSS variable such as <code>--f2s-primary<\/code> and <code>--f2s-box-size<\/code>. You can also change any text with the JavaScript API.<\/p>\n<h3>Will the code fill in by itself on phones?<\/h3>\n<p>Phone keyboards usually offer the code from the SMS because the first box has <code>autocomplete=\"one-time-code\"<\/code>. Chrome on Android can fill it alone only when the SMS ends with a line for your domain, which most DLT templates do not have.<\/p>\n<\/section>\n<aside class=\"f2s-cta\" aria-label=\"Get started with Fast2SMS\"><div class=\"f2s-cta__copy\"><strong class=\"f2s-cta__title\">Start verifying numbers today<\/strong><p>Sign up, recharge your wallet and add the OTP widget to your first form.<\/p><\/div><div class=\"f2s-cta__actions\"><a class=\"f2s-cta__btn f2s-cta__btn--primary\" href=\"https:\/\/www.fast2sms.com\/\"><span>Sign up free<\/span> <span class=\"f2sh-btn__arrow\" aria-hidden=\"true\">&rarr;<\/span><\/a><a class=\"f2s-cta__btn f2s-cta__btn--ghost\" href=\"https:\/\/www.fast2sms.com\/meet\/\" target=\"_blank\" rel=\"noopener\">Book a free meeting<\/a><\/div><\/aside>\n<h2>Related guides<\/h2>\n<ul>\n<li><a href=\"\/help\/smart-otp-setup-guide-fast2sms\/\">Smart OTP in Fast2SMS: set up OTP on SMS and WhatsApp with fallback<\/a><\/li>\n<li><a href=\"\/help\/otp-verification-signup-form\/\">OTP verification for signup forms: verify mobile numbers before creating accounts<\/a><\/li>\n<li><a href=\"\/help\/otp-sms-pumping-fraud-protection\/\">OTP fraud and SMS pumping: how to protect your OTP form and wallet<\/a><\/li>\n<li><a href=\"\/help\/smart-otp-resend-otp-api\/\">Fast2SMS Resend OTP API: same OTP, 10-minute window, 5 sends<\/a><\/li>\n<li><a href=\"\/help\/api-key-find-reset\/\">How to find, view and reset your Fast2SMS API key<\/a><\/li>\n<li><a href=\"https:\/\/www.fast2sms.com\/otp-sms\">Fast2SMS Smart OTP<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>You can add OTP verification to any HTML website or form with two lines: one script tag and one &lt;div data-f2s-otp&gt;. Visitors type their mobile number, get a code by SMS or WhatsApp through Fast2SMS Smart OTP, and your page gets a signed token once the number is verified. This guide shows the log-in box, [&hellip;]<\/p>\n","protected":false},"featured_media":19636,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,5],"tags":[],"class_list":["post-19640","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-api","category-otp"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>OTP Verification for HTML Forms in 2 Lines | Fast2SMS<\/title>\n<meta name=\"description\" content=\"Add OTP verification to any HTML website or form with 2 lines: the Fast2SMS OTP widget, data-f2s-protect and a server check of f2s_token. Free example.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.fast2sms.com\/help\/otp-widget-html-website-fast2sms\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"OTP Verification for HTML Forms in 2 Lines | Fast2SMS\" \/>\n<meta property=\"og:description\" content=\"Add OTP verification to any HTML website or form with 2 lines: the Fast2SMS OTP widget, data-f2s-protect and a server check of f2s_token. Free example.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.fast2sms.com\/help\/otp-widget-html-website-fast2sms\/\" \/>\n<meta property=\"og:site_name\" content=\"Fast2SMS\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/Fast2SMS\/\" \/>\n<meta property=\"article:published_time\" content=\"2026-11-18T19:57:50+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.fast2sms.com\/help\/wp-content\/uploads\/2026\/11\/smart-otp-template-list-hd-28-scaled.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"2560\" \/>\n\t<meta property=\"og:image:height\" content=\"1600\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@fast2sms\" \/>\n<meta name=\"twitter:site\" content=\"@fast2sms\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/otp-widget-html-website-fast2sms\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/otp-widget-html-website-fast2sms\\\/\"},\"author\":{\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/#organization\"},\"headline\":\"Add OTP verification to an HTML form in 2 lines (Fast2SMS OTP widget)\",\"datePublished\":\"2026-11-18T19:57:50+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/otp-widget-html-website-fast2sms\\\/\"},\"wordCount\":1741,\"publisher\":{\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/otp-widget-html-website-fast2sms\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/smart-otp-template-list-hd-28-scaled.webp\",\"articleSection\":[\"API\",\"OTP\"],\"inLanguage\":\"en-IN\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/otp-widget-html-website-fast2sms\\\/\",\"url\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/otp-widget-html-website-fast2sms\\\/\",\"name\":\"OTP Verification for HTML Forms in 2 Lines | Fast2SMS\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/otp-widget-html-website-fast2sms\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/otp-widget-html-website-fast2sms\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/smart-otp-template-list-hd-28-scaled.webp\",\"datePublished\":\"2026-11-18T19:57:50+00:00\",\"description\":\"Add OTP verification to any HTML website or form with 2 lines: the Fast2SMS OTP widget, data-f2s-protect and a server check of f2s_token. Free example.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/otp-widget-html-website-fast2sms\\\/#breadcrumb\"},\"inLanguage\":\"en-IN\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/otp-widget-html-website-fast2sms\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-IN\",\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/otp-widget-html-website-fast2sms\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/smart-otp-template-list-hd-28-scaled.webp\",\"contentUrl\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/smart-otp-template-list-hd-28-scaled.webp\",\"width\":2560,\"height\":1600,\"caption\":\"Smart OTP Template page with WhatsApp and SMS OTP template cards, each showing its OTP ID, sender or number, template ID and fallback\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/otp-widget-html-website-fast2sms\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"API\",\"item\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/api\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Add OTP verification to an HTML form in 2 lines (Fast2SMS OTP widget)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/#website\",\"url\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/\",\"name\":\"Fast2SMS\",\"description\":\"Help\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/#organization\"},\"inLanguage\":\"en-IN\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/#organization\",\"name\":\"Fast2SMS\",\"url\":\"https:\\\/\\\/www.fast2sms.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/#logo\",\"url\":\"https:\\\/\\\/www.fast2sms.com\\\/Fast2SMS.png\",\"contentUrl\":\"https:\\\/\\\/www.fast2sms.com\\\/Fast2SMS.png\",\"caption\":\"Fast2SMS\"},\"image\":{\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/#logo\"},\"email\":\"support@fast2sms.com\",\"telephone\":\"+91-6262778822\",\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/Fast2SMS\",\"https:\\\/\\\/www.instagram.com\\\/fast2sms\",\"https:\\\/\\\/x.com\\\/fast2sms\",\"https:\\\/\\\/www.youtube.com\\\/Fast2SMSofficial\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/fast2sms\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"OTP Verification for HTML Forms in 2 Lines | Fast2SMS","description":"Add OTP verification to any HTML website or form with 2 lines: the Fast2SMS OTP widget, data-f2s-protect and a server check of f2s_token. Free example.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.fast2sms.com\/help\/otp-widget-html-website-fast2sms\/","og_locale":"en_US","og_type":"article","og_title":"OTP Verification for HTML Forms in 2 Lines | Fast2SMS","og_description":"Add OTP verification to any HTML website or form with 2 lines: the Fast2SMS OTP widget, data-f2s-protect and a server check of f2s_token. Free example.","og_url":"https:\/\/www.fast2sms.com\/help\/otp-widget-html-website-fast2sms\/","og_site_name":"Fast2SMS","article_publisher":"https:\/\/www.facebook.com\/Fast2SMS\/","article_published_time":"2026-11-18T19:57:50+00:00","og_image":[{"width":2560,"height":1600,"url":"https:\/\/www.fast2sms.com\/help\/wp-content\/uploads\/2026\/11\/smart-otp-template-list-hd-28-scaled.webp","type":"image\/webp"}],"twitter_card":"summary_large_image","twitter_creator":"@fast2sms","twitter_site":"@fast2sms","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.fast2sms.com\/help\/otp-widget-html-website-fast2sms\/#article","isPartOf":{"@id":"https:\/\/www.fast2sms.com\/help\/otp-widget-html-website-fast2sms\/"},"author":{"@id":"https:\/\/www.fast2sms.com\/#organization"},"headline":"Add OTP verification to an HTML form in 2 lines (Fast2SMS OTP widget)","datePublished":"2026-11-18T19:57:50+00:00","mainEntityOfPage":{"@id":"https:\/\/www.fast2sms.com\/help\/otp-widget-html-website-fast2sms\/"},"wordCount":1741,"publisher":{"@id":"https:\/\/www.fast2sms.com\/#organization"},"image":{"@id":"https:\/\/www.fast2sms.com\/help\/otp-widget-html-website-fast2sms\/#primaryimage"},"thumbnailUrl":"https:\/\/www.fast2sms.com\/help\/wp-content\/uploads\/2026\/11\/smart-otp-template-list-hd-28-scaled.webp","articleSection":["API","OTP"],"inLanguage":"en-IN"},{"@type":"WebPage","@id":"https:\/\/www.fast2sms.com\/help\/otp-widget-html-website-fast2sms\/","url":"https:\/\/www.fast2sms.com\/help\/otp-widget-html-website-fast2sms\/","name":"OTP Verification for HTML Forms in 2 Lines | Fast2SMS","isPartOf":{"@id":"https:\/\/www.fast2sms.com\/help\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.fast2sms.com\/help\/otp-widget-html-website-fast2sms\/#primaryimage"},"image":{"@id":"https:\/\/www.fast2sms.com\/help\/otp-widget-html-website-fast2sms\/#primaryimage"},"thumbnailUrl":"https:\/\/www.fast2sms.com\/help\/wp-content\/uploads\/2026\/11\/smart-otp-template-list-hd-28-scaled.webp","datePublished":"2026-11-18T19:57:50+00:00","description":"Add OTP verification to any HTML website or form with 2 lines: the Fast2SMS OTP widget, data-f2s-protect and a server check of f2s_token. Free example.","breadcrumb":{"@id":"https:\/\/www.fast2sms.com\/help\/otp-widget-html-website-fast2sms\/#breadcrumb"},"inLanguage":"en-IN","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.fast2sms.com\/help\/otp-widget-html-website-fast2sms\/"]}]},{"@type":"ImageObject","inLanguage":"en-IN","@id":"https:\/\/www.fast2sms.com\/help\/otp-widget-html-website-fast2sms\/#primaryimage","url":"https:\/\/www.fast2sms.com\/help\/wp-content\/uploads\/2026\/11\/smart-otp-template-list-hd-28-scaled.webp","contentUrl":"https:\/\/www.fast2sms.com\/help\/wp-content\/uploads\/2026\/11\/smart-otp-template-list-hd-28-scaled.webp","width":2560,"height":1600,"caption":"Smart OTP Template page with WhatsApp and SMS OTP template cards, each showing its OTP ID, sender or number, template ID and fallback"},{"@type":"BreadcrumbList","@id":"https:\/\/www.fast2sms.com\/help\/otp-widget-html-website-fast2sms\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.fast2sms.com\/help\/"},{"@type":"ListItem","position":2,"name":"API","item":"https:\/\/www.fast2sms.com\/help\/api\/"},{"@type":"ListItem","position":3,"name":"Add OTP verification to an HTML form in 2 lines (Fast2SMS OTP widget)"}]},{"@type":"WebSite","@id":"https:\/\/www.fast2sms.com\/help\/#website","url":"https:\/\/www.fast2sms.com\/help\/","name":"Fast2SMS","description":"Help","publisher":{"@id":"https:\/\/www.fast2sms.com\/#organization"},"inLanguage":"en-IN"},{"@type":"Organization","@id":"https:\/\/www.fast2sms.com\/#organization","name":"Fast2SMS","url":"https:\/\/www.fast2sms.com\/","logo":{"@type":"ImageObject","@id":"https:\/\/www.fast2sms.com\/#logo","url":"https:\/\/www.fast2sms.com\/Fast2SMS.png","contentUrl":"https:\/\/www.fast2sms.com\/Fast2SMS.png","caption":"Fast2SMS"},"image":{"@id":"https:\/\/www.fast2sms.com\/#logo"},"email":"support@fast2sms.com","telephone":"+91-6262778822","sameAs":["https:\/\/www.facebook.com\/Fast2SMS","https:\/\/www.instagram.com\/fast2sms","https:\/\/x.com\/fast2sms","https:\/\/www.youtube.com\/Fast2SMSofficial","https:\/\/www.linkedin.com\/company\/fast2sms"]}]}},"_links":{"self":[{"href":"https:\/\/www.fast2sms.com\/help\/wp-json\/wp\/v2\/posts\/19640","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.fast2sms.com\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.fast2sms.com\/help\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/www.fast2sms.com\/help\/wp-json\/wp\/v2\/comments?post=19640"}],"version-history":[{"count":0,"href":"https:\/\/www.fast2sms.com\/help\/wp-json\/wp\/v2\/posts\/19640\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.fast2sms.com\/help\/wp-json\/wp\/v2\/media\/19636"}],"wp:attachment":[{"href":"https:\/\/www.fast2sms.com\/help\/wp-json\/wp\/v2\/media?parent=19640"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.fast2sms.com\/help\/wp-json\/wp\/v2\/categories?post=19640"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.fast2sms.com\/help\/wp-json\/wp\/v2\/tags?post=19640"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}