{"id":18004,"date":"2026-11-18T23:44:34","date_gmt":"2026-11-18T18:14:34","guid":{"rendered":"https:\/\/www.fast2sms.com\/help\/flutter-otp-sms-api\/"},"modified":"2026-11-19T00:49:07","modified_gmt":"2026-11-18T19:19:07","slug":"flutter-otp-sms-api","status":"publish","type":"post","link":"https:\/\/www.fast2sms.com\/help\/flutter-otp-sms-api\/","title":{"rendered":"Flutter OTP verification with Fast2SMS (and React Native): keep the API key on your server"},"content":{"rendered":"<p>To verify phone numbers with OTP in a Flutter app using Fast2SMS, the app calls your own backend and the backend calls the Fast2SMS API. The <a href=\"\/help\/api-key-find-reset\/\">API key<\/a> never goes into the Flutter build. This guide gives you the backend endpoints, the Dart code for the app (send, verify, resend with a countdown), OTP autofill on Android and iPhone, DLT SMS alerts, delivery reports and error handling. The same backend works for React Native, with a short example at the end.<\/p>\n<aside class=\"f2s-cta\" aria-label=\"Get started with Fast2SMS\"><div class=\"f2s-cta__copy\"><strong class=\"f2s-cta__title\">Add OTP login to your Flutter app<\/strong><p>Create a Smart OTP template, keep the key on your server and verify users on 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<h2>How the pieces fit<\/h2>\n<ol>\n<li>The Flutter app posts the mobile number to <strong>your backend<\/strong>, for example <code>\/api\/otp\/send<\/code>.<\/li>\n<li>Your backend calls Fast2SMS <code>\/dev\/otp\/send<\/code> with the API key and your <a href=\"\/help\/smart-otp-setup-guide-fast2sms\/\">Smart OTP<\/a> <strong>OTP ID<\/strong>.<\/li>\n<li>The user enters or autofills the code. The app posts it to <code>\/api\/otp\/verify<\/code>.<\/li>\n<li>Your backend calls Fast2SMS <code>\/dev\/otp\/verify<\/code>. If it passes, the backend returns a session token to the app.<\/li>\n<\/ol>\n<p>A key placed in Dart code, <code>.env<\/code> assets or <code>--dart-define<\/code> ends up inside the APK or IPA and can be extracted. That is why the backend step is not optional.<\/p>\n<h2>Before you start<\/h2>\n<ul>\n<li><strong>A backend:<\/strong> Node.js, PHP, Python, Java, .NET or a serverless function. It only needs to make HTTPS calls.<\/li>\n<li><strong>API key<\/strong> from <strong>API Key<\/strong> under UTILITY, with <strong>API Access<\/strong> on, stored on the backend.<\/li>\n<li><strong>Smart OTP template<\/strong> and its <strong>OTP ID<\/strong> from <strong>OTP Template List<\/strong>.<\/li>\n<li><strong>Wallet balance.<\/strong> Each OTP send and resend is charged.<\/li>\n<li><strong>Flutter 3<\/strong> with the <code>http<\/code> package.<\/li>\n<\/ul>\n<h2>Set up in the panel<\/h2>\n<ol class=\"f2s-steps\">\n<li>\n<h3>Create or pick a Smart OTP template<\/h3>\n<p>Open Smart OTP, <strong>OTP Template List<\/strong>. Copy the <strong>OTP ID<\/strong> from an SMS or WhatsApp OTP card. To add one, click <strong>Add OTP Template<\/strong> and link your approved DLT or WhatsApp authentication template.<\/p>\n<figure class=\"f2s-shot\"><img src=\"https:\/\/www.fast2sms.com\/help\/wp-content\/uploads\/2026\/11\/smart-otp-template-list-hd-6-scaled.webp\" width=\"1440\" height=\"900\" loading=\"lazy\" decoding=\"async\" alt=\"OTP Template List showing WhatsApp and SMS OTP template cards with OTP ID, number or sender, template ID and fallback\"><figcaption>Keep the OTP ID on your backend with the API key.<\/figcaption><\/figure>\n<\/li>\n<li>\n<h3>Check the OTP settings<\/h3>\n<p>Open <strong>OTP Settings<\/strong>. Note the <strong>SMS Resend \/ Time Limit<\/strong> in seconds; your Resend button countdown should use the same number. <strong>Max Verify OTP Limit<\/strong> sets how many wrong codes are allowed.<\/p>\n<figure class=\"f2s-shot\"><img src=\"https:\/\/www.fast2sms.com\/help\/wp-content\/uploads\/2026\/11\/smart-otp-settings-hd-4-scaled.webp\" width=\"1440\" height=\"900\" loading=\"lazy\" decoding=\"async\" alt=\"OTP Settings with Max Verify OTP Limit 5 and SMS Resend \/ Time Limit 30 seconds\"><figcaption>Use the resend time for the app&#8217;s timer.<\/figcaption><\/figure>\n<\/li>\n<li>\n<h3>Copy the API key to the backend<\/h3>\n<p>In <strong>Account Setting<\/strong>, <strong>API Key<\/strong>, click <strong>View<\/strong>, enter the OTP sent to your account mobile and copy the key into your backend&#8217;s environment variables.<\/p>\n<figure class=\"f2s-shot\"><img src=\"https:\/\/www.fast2sms.com\/help\/wp-content\/uploads\/2026\/11\/api-key-hd-9-scaled.webp\" width=\"1440\" height=\"900\" loading=\"lazy\" decoding=\"async\" alt=\"API Key page with masked Authorization Key, View, Reset and the API Access switch\"><figcaption>The key stays on the server.<\/figcaption><\/figure>\n<\/li>\n<\/ol>\n<h2>Backend endpoints (Node.js example)<\/h2>\n<p>This Express server is enough for the app. The same three calls in PHP, Python, Java or C# are in the language guides linked at the end.<\/p>\n<pre><code class=\"language-javascript\">import express from \"express\";\n\nconst app = express();\napp.use(express.json());\n\nconst KEY = process.env.FAST2SMS_API_KEY;\nconst OTP_ID = process.env.FAST2SMS_OTP_ID;\n\nasync function fast2sms(path, body) {\n  const res = await fetch(\"https:\/\/www.fast2sms.com\" + path, {\n    method: \"POST\",\n    headers: { authorization: KEY, \"Content-Type\": \"application\/json\" },   \/\/ bare key\n    body: JSON.stringify(body),\n    signal: AbortSignal.timeout(15000),\n  });\n  const data = await res.json();\n  return { ok: res.ok &amp;&amp; data.return === true, message: data.message };\n}\n\nconst clean = (m = \"\") =&gt; String(m).replace(\/\\D\/g, \"\").slice(-10);\n\napp.post(\"\/api\/otp\/send\", async (req, res) =&gt; {\n  const mobile = clean(req.body.mobile);\n  if (&#33;\/^[6-9]\\d{9}$\/.test(mobile)) return res.status(400).json({ error: \"Enter a valid mobile number\" });\n  \/\/ Add your own rate limits here (per IP, per device, per mobile)\n  const r = await fast2sms(\"\/dev\/otp\/send\", { mobile, otp_id: OTP_ID, otp_expiry: 5 });\n  r.ok ? res.json({ sent: true }) : res.status(400).json({ error: r.message });\n});\n\napp.post(\"\/api\/otp\/verify\", async (req, res) =&gt; {\n  const r = await fast2sms(\"\/dev\/otp\/verify\", { mobile: clean(req.body.mobile), otp: String(req.body.otp || \"\").trim() });\n  if (&#33;r.ok) return res.status(400).json({ error: r.message });\n  res.json({ verified: true, token: \"create-your-session-token-here\" });\n});\n\napp.post(\"\/api\/otp\/resend\", async (req, res) =&gt; {\n  const r = await fast2sms(\"\/dev\/otp\/resend\", { mobile: clean(req.body.mobile) });\n  r.ok ? res.json({ sent: true }) : res.status(400).json({ error: r.message });\n});\n\napp.listen(3000);<\/code><\/pre>\n<ul>\n<li>Verify checks the latest unverified OTP for that mobile. Each new send cancels older OTPs.<\/li>\n<li>Resend sends the same code again and is charged. It works for 10 minutes after the first send, with up to 5 sends in all, counting the first.<\/li>\n<li>Requests inside the wait time get &#8220;Please wait N seconds before requesting a new OTP&#8221;.<\/li>\n<\/ul>\n<h2>Flutter: call the backend from Dart<\/h2>\n<pre><code class=\"language-bash\">flutter pub add http<\/code><\/pre>\n<pre><code class=\"language-dart\">import 'dart:convert';\nimport 'package:http\/http.dart' as http;\n\nclass OtpResult {\n  final bool ok;\n  final String? error;\n  final String? token;\n  OtpResult(this.ok, {this.error, this.token});\n}\n\nclass OtpApi {\n  OtpApi({this.baseUrl = 'https:\/\/api.yourapp.com'});\n  final String baseUrl;\n\n  Future&lt;OtpResult&gt; _post(String path, Map&lt;String, String&gt; body) async {\n    try {\n      final res = await http\n          .post(Uri.parse('$baseUrl$path'),\n              headers: {'Content-Type': 'application\/json'}, body: jsonEncode(body))\n          .timeout(const Duration(seconds: 20));\n      final data = res.body.isEmpty ? &lt;String, dynamic&gt;{} : jsonDecode(res.body) as Map&lt;String, dynamic&gt;;\n      if (res.statusCode == 200) return OtpResult(true, token: data['token'] as String?);\n      return OtpResult(false, error: (data['error'] ?? 'Something went wrong. Try again.').toString());\n    } catch (_) {\n      return OtpResult(false, error: 'No internet connection. Try again.');\n    }\n  }\n\n  Future&lt;OtpResult&gt; send(String mobile) =&gt; _post('\/api\/otp\/send', {'mobile': mobile});\n  Future&lt;OtpResult&gt; resend(String mobile) =&gt; _post('\/api\/otp\/resend', {'mobile': mobile});\n  Future&lt;OtpResult&gt; verify(String mobile, String otp) =&gt; _post('\/api\/otp\/verify', {'mobile': mobile, 'otp': otp});\n}<\/code><\/pre>\n<h2>OTP autofill in Flutter<\/h2>\n<ul>\n<li><strong>iPhone:<\/strong> set <code>autofillHints: const [AutofillHints.oneTimeCode]<\/code> and <code>keyboardType: TextInputType.number<\/code> on the code field. iOS then offers the code from the SMS above the keyboard.<\/li>\n<li><strong>Android:<\/strong> use a pub.dev package that wraps Google&#8217;s SMS Retriever API (needs your 11-character app hash in the SMS) or the SMS User Consent API (no hash, the user taps Allow). In India the SMS must match your DLT template, so a hash must be fixed text in the approved template.<\/li>\n<\/ul>\n<p>Whatever reads the code, the app only passes it to <code>\/api\/otp\/verify<\/code>. The backend makes the decision.<\/p>\n<aside class=\"f2s-cta\" aria-label=\"Get started with Fast2SMS\"><div class=\"f2s-cta__copy\"><strong class=\"f2s-cta__title\">Faster sign-ups in your Flutter app<\/strong><p>Smart OTP sends on SMS or WhatsApp, checks the code and can fall back to the other channel when one fails.<\/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>Full copy-paste example: OTP login screen<\/h2>\n<pre><code class=\"language-dart\">import 'dart:async';\nimport 'package:flutter\/material.dart';\nimport 'otp_api.dart';\n\nclass OtpLoginPage extends StatefulWidget {\n  const OtpLoginPage({super.key, this.resendWaitSeconds = 30}); \/\/ same as OTP Settings\n  final int resendWaitSeconds;\n  @override\n  State&lt;OtpLoginPage&gt; createState() =&gt; _OtpLoginPageState();\n}\n\nclass _OtpLoginPageState extends State&lt;OtpLoginPage&gt; {\n  final _api = OtpApi();\n  final _mobile = TextEditingController();\n  final _code = TextEditingController();\n  bool _sent = false, _busy = false;\n  int _resendIn = 0;\n  String? _error;\n  Timer? _timer;\n\n  String get _digits {\n    final d = _mobile.text.replaceAll(RegExp(r'\\D'), '');\n    return d.length &gt; 10 ? d.substring(d.length - 10) : d;\n  }\n\n  void _startTimer() {\n    _timer?.cancel();\n    setState(() =&gt; _resendIn = widget.resendWaitSeconds);\n    _timer = Timer.periodic(const Duration(seconds: 1), (t) {\n      if (_resendIn &lt;= 1) t.cancel();\n      setState(() =&gt; _resendIn = _resendIn &gt; 0 ? _resendIn - 1 : 0);\n    });\n  }\n\n  Future&lt;void&gt; _send({bool resend = false}) async {\n    if (&#33;RegExp(r'^[6-9]\\d{9}$').hasMatch(_digits)) {\n      setState(() =&gt; _error = 'Enter a valid 10-digit mobile number');\n      return;\n    }\n    setState(() { _busy = true; _error = null; });\n    final r = resend ? await _api.resend(_digits) : await _api.send(_digits);\n    setState(() { _busy = false; _error = r.error; if (r.ok) _sent = true; });\n    if (r.ok) _startTimer();\n  }\n\n  Future&lt;void&gt; _verify() async {\n    setState(() { _busy = true; _error = null; });\n    final r = await _api.verify(_digits, _code.text.trim());\n    setState(() { _busy = false; _error = r.error; });\n    if (r.ok &amp;&amp; mounted) {\n      \/\/ Save r.token securely (e.g. flutter_secure_storage) and open the home screen\n      ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('Verified')));\n    }\n  }\n\n  @override\n  void dispose() { _timer?.cancel(); _mobile.dispose(); _code.dispose(); super.dispose(); }\n\n  @override\n  Widget build(BuildContext context) {\n    return Scaffold(\n      appBar: AppBar(title: const Text('Login with OTP')),\n      body: Padding(\n        padding: const EdgeInsets.all(16),\n        child: Column(crossAxisAlignment: CrossAxisAlignment.stretch, children: [\n          TextField(\n            controller: _mobile,\n            enabled: &#33;_sent,\n            keyboardType: TextInputType.phone,\n            decoration: const InputDecoration(labelText: 'Mobile number', prefixText: '+91 '),\n          ),\n          if (_sent)\n            TextField(\n              controller: _code,\n              keyboardType: TextInputType.number,\n              autofillHints: const [AutofillHints.oneTimeCode],\n              maxLength: 6,\n              decoration: const InputDecoration(labelText: 'Enter OTP'),\n            ),\n          if (_error &#33;= null) Padding(\n            padding: const EdgeInsets.symmetric(vertical: 8),\n            child: Text(_error&#33;, style: TextStyle(color: Theme.of(context).colorScheme.error)),\n          ),\n          const SizedBox(height: 12),\n          FilledButton(\n            onPressed: _busy ? null : (_sent ? _verify : () =&gt; _send()),\n            child: Text(_sent ? 'Verify' : 'Send OTP'),\n          ),\n          if (_sent)\n            TextButton(\n              onPressed: _busy || _resendIn &gt; 0 ? null : () =&gt; _send(resend: true),\n              child: Text(_resendIn &gt; 0 ? 'Resend in $_resendIn s' : 'Resend OTP'),\n            ),\n        ]),\n      ),\n    );\n  }\n}<\/code><\/pre>\n<h2>React Native: same backend<\/h2>\n<pre><code class=\"language-javascript\">async function sendOtp(mobile) {\n  const res = await fetch(\"https:\/\/api.yourapp.com\/api\/otp\/send\", {\n    method: \"POST\",\n    headers: { \"Content-Type\": \"application\/json\" },\n    body: JSON.stringify({ mobile }),\n  });\n  const data = await res.json();\n  if (&#33;res.ok) throw new Error(data.error || \"Could not send OTP\");\n}\n\/\/ On the code input: textContentType=\"oneTimeCode\" (iOS) and autoComplete=\"sms-otp\" (Android)<\/code><\/pre>\n<h2>DLT SMS alerts and delivery reports<\/h2>\n<ul>\n<li><strong>Alerts<\/strong> such as order confirmed or booking reminder should be sent by your backend when the event happens, with <code>\/dev\/bulkV2<\/code>, <code>route=dlt<\/code>, your sender ID, the template&#8217;s <strong>Message ID<\/strong> and the variable values.<\/li>\n<li><strong>Delivery status<\/strong> goes to your backend too: add an OTP or SMS <a href=\"\/help\/fast2sms-webhooks-setup-delivery-reports\/\">webhook<\/a> under <strong>Webhook<\/strong> in the panel, or call <code>GET \/dev\/dlr\/{request_id}<\/code> from the server for SMS. Use one of the two, not both. The app can ask your backend if it needs to show the status.<\/li>\n<\/ul>\n<h2>Error handling<\/h2>\n<div class=\"f2s-facts\">\n<table>\n<thead>\n<tr>\n<th>Message your backend gets<\/th>\n<th>Show in the app<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Please wait N seconds before requesting a new OTP<\/td>\n<td>Keep the countdown running.<\/td>\n<\/tr>\n<tr>\n<td>Invalid OTP<\/td>\n<td>&#8220;Wrong code. Try again.&#8221;<\/td>\n<\/tr>\n<tr>\n<td>OTP expired<\/td>\n<td>&#8220;Code expired. Tap Resend OTP.&#8221;<\/td>\n<\/tr>\n<tr>\n<td>Maximum verification attempts reached. OTP is no longer valid.<\/td>\n<td>&#8220;Too many tries. Request a new code.&#8221;<\/td>\n<\/tr>\n<tr>\n<td>OTP not found or already verified<\/td>\n<td>&#8220;Please request a new code.&#8221;<\/td>\n<\/tr>\n<tr>\n<td>OTP resend window (10 minutes) has expired \/ Maximum resend limit (5 times) reached<\/td>\n<td>Restart with a fresh send, or ask the user to try later.<\/td>\n<\/tr>\n<tr>\n<td>Invalid authorization key \/ Invalid OTP ID \/ 413 \/ 414 \/ low balance<\/td>\n<td>A general error. Fix it on the server side.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>On the backend, never retry a send automatically after a timeout, because it can send and charge twice. Verify can be retried once.<\/p>\n<h2>Common problems and fixes<\/h2>\n<ul>\n<li><strong>Works on emulator, fails on device:<\/strong> the app points to <code>localhost<\/code> or <code>10.0.2.2<\/code>. Use your public HTTPS backend URL.<\/li>\n<li><strong>Android blocks HTTP:<\/strong> cleartext traffic is off by default. Use HTTPS.<\/li>\n<li><strong>Two OTPs arrive:<\/strong> the send function runs twice (double tap or rebuild). Disable the button while <code>_busy<\/code> is true.<\/li>\n<li><strong>iOS does not suggest the code:<\/strong> check <code>autofillHints<\/code> on the field and that the SMS shows the code clearly.<\/li>\n<li><strong>Bots ask for thousands of OTPs:<\/strong> add rate limits on the send endpoint and app attestation (Play Integrity, App Attest).<\/li>\n<\/ul>\n<section class=\"f2s-faq\">\n<h2>Frequently asked questions<\/h2>\n<h3>Is there a Fast2SMS Flutter package?<\/h3>\n<p>You do not need one. The app talks to your backend with the <code>http<\/code> package, and the backend calls the Fast2SMS HTTP API.<\/p>\n<h3>Can I use a serverless cloud function as the backend?<\/h3>\n<p>Yes. Any server-side code that can make HTTPS requests and keep a secret works. Store the key in the function&#8217;s secret settings.<\/p>\n<h3>Can the OTP go on WhatsApp?<\/h3>\n<p>Yes. Use the OTP ID of a WhatsApp Smart OTP template on the backend. The Flutter code stays the same.<\/p>\n<h3>Does resend give a new code?<\/h3>\n<p>No. It sends the same code again. Calling send again creates a new code and cancels the old one.<\/p>\n<h3>Is verify charged?<\/h3>\n<p>No. Only sends and resends are charged.<\/p>\n<h3>How long is the OTP valid?<\/h3>\n<p>Your backend sets <code>otp_expiry<\/code> in minutes (1 to 10080, default 15).<\/p>\n<\/section>\n<aside class=\"f2s-cta\" aria-label=\"Get started with Fast2SMS\"><div class=\"f2s-cta__copy\"><strong class=\"f2s-cta__title\">Ship OTP login in Flutter<\/strong><p>Sign up, create a Smart OTP template and connect your app through a small backend.<\/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\/nodejs-sms-api\/\">Send SMS and OTP in Node.js with Fast2SMS API<\/a><\/li>\n<li><a href=\"\/help\/android-otp-sms-api\/\">OTP verification in an Android app (Kotlin)<\/a><\/li>\n<li><a href=\"\/help\/otp-autofill-android-ios-sms-retriever\/\">OTP autofill on Android, iPhone and websites<\/a><\/li>\n<li><a href=\"\/help\/smart-otp-verify-otp-api\/\">Fast2SMS Verify OTP API: how verification works<\/a><\/li>\n<li><a href=\"\/help\/smart-otp-best-practices\/\">OTP security best practices with Fast2SMS<\/a><\/li>\n<li><a href=\"https:\/\/www.fast2sms.com\/otp-sms\">Fast2SMS OTP SMS<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>To verify phone numbers with OTP in a Flutter app using Fast2SMS, the app calls your own backend and the backend calls the Fast2SMS API. The API key never goes into the Flutter build. This guide gives you the backend endpoints, the Dart code for the app (send, verify, resend with a countdown), OTP autofill [&hellip;]<\/p>\n","protected":false},"featured_media":17997,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,5],"tags":[],"class_list":["post-18004","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>Flutter OTP Verification with SMS API | Fast2SMS<\/title>\n<meta name=\"description\" content=\"Add OTP login to a Flutter or React Native app with Fast2SMS Smart OTP. Backend endpoints, Dart code, resend timer, autofill and error handling.\" \/>\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\/flutter-otp-sms-api\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Flutter OTP Verification with SMS API | Fast2SMS\" \/>\n<meta property=\"og:description\" content=\"Add OTP login to a Flutter or React Native app with Fast2SMS Smart OTP. Backend endpoints, Dart code, resend timer, autofill and error handling.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.fast2sms.com\/help\/flutter-otp-sms-api\/\" \/>\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-18T18:14:34+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-11-18T19:19:07+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.fast2sms.com\/help\/wp-content\/uploads\/2026\/11\/smart-otp-template-list-hd-6-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\\\/flutter-otp-sms-api\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/flutter-otp-sms-api\\\/\"},\"author\":{\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/#organization\"},\"headline\":\"Flutter OTP verification with Fast2SMS (and React Native): keep the API key on your server\",\"datePublished\":\"2026-11-18T18:14:34+00:00\",\"dateModified\":\"2026-11-18T19:19:07+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/flutter-otp-sms-api\\\/\"},\"wordCount\":1149,\"publisher\":{\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/flutter-otp-sms-api\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/smart-otp-template-list-hd-6-scaled.webp\",\"articleSection\":[\"API\",\"OTP\"],\"inLanguage\":\"en-IN\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/flutter-otp-sms-api\\\/\",\"url\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/flutter-otp-sms-api\\\/\",\"name\":\"Flutter OTP Verification with SMS API | Fast2SMS\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/flutter-otp-sms-api\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/flutter-otp-sms-api\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/smart-otp-template-list-hd-6-scaled.webp\",\"datePublished\":\"2026-11-18T18:14:34+00:00\",\"dateModified\":\"2026-11-18T19:19:07+00:00\",\"description\":\"Add OTP login to a Flutter or React Native app with Fast2SMS Smart OTP. Backend endpoints, Dart code, resend timer, autofill and error handling.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/flutter-otp-sms-api\\\/#breadcrumb\"},\"inLanguage\":\"en-IN\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/flutter-otp-sms-api\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-IN\",\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/flutter-otp-sms-api\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/smart-otp-template-list-hd-6-scaled.webp\",\"contentUrl\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/smart-otp-template-list-hd-6-scaled.webp\",\"width\":2560,\"height\":1600,\"caption\":\"OTP Template List showing WhatsApp and SMS OTP template cards with OTP ID, number or sender, template ID and fallback\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.fast2sms.com\\\/help\\\/flutter-otp-sms-api\\\/#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\":\"Flutter OTP verification with Fast2SMS (and React Native): keep the API key on your server\"}]},{\"@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":"Flutter OTP Verification with SMS API | Fast2SMS","description":"Add OTP login to a Flutter or React Native app with Fast2SMS Smart OTP. Backend endpoints, Dart code, resend timer, autofill and error handling.","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\/flutter-otp-sms-api\/","og_locale":"en_US","og_type":"article","og_title":"Flutter OTP Verification with SMS API | Fast2SMS","og_description":"Add OTP login to a Flutter or React Native app with Fast2SMS Smart OTP. Backend endpoints, Dart code, resend timer, autofill and error handling.","og_url":"https:\/\/www.fast2sms.com\/help\/flutter-otp-sms-api\/","og_site_name":"Fast2SMS","article_publisher":"https:\/\/www.facebook.com\/Fast2SMS\/","article_published_time":"2026-11-18T18:14:34+00:00","article_modified_time":"2026-11-18T19:19:07+00:00","og_image":[{"width":2560,"height":1600,"url":"https:\/\/www.fast2sms.com\/help\/wp-content\/uploads\/2026\/11\/smart-otp-template-list-hd-6-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\/flutter-otp-sms-api\/#article","isPartOf":{"@id":"https:\/\/www.fast2sms.com\/help\/flutter-otp-sms-api\/"},"author":{"@id":"https:\/\/www.fast2sms.com\/#organization"},"headline":"Flutter OTP verification with Fast2SMS (and React Native): keep the API key on your server","datePublished":"2026-11-18T18:14:34+00:00","dateModified":"2026-11-18T19:19:07+00:00","mainEntityOfPage":{"@id":"https:\/\/www.fast2sms.com\/help\/flutter-otp-sms-api\/"},"wordCount":1149,"publisher":{"@id":"https:\/\/www.fast2sms.com\/#organization"},"image":{"@id":"https:\/\/www.fast2sms.com\/help\/flutter-otp-sms-api\/#primaryimage"},"thumbnailUrl":"https:\/\/www.fast2sms.com\/help\/wp-content\/uploads\/2026\/11\/smart-otp-template-list-hd-6-scaled.webp","articleSection":["API","OTP"],"inLanguage":"en-IN"},{"@type":"WebPage","@id":"https:\/\/www.fast2sms.com\/help\/flutter-otp-sms-api\/","url":"https:\/\/www.fast2sms.com\/help\/flutter-otp-sms-api\/","name":"Flutter OTP Verification with SMS API | Fast2SMS","isPartOf":{"@id":"https:\/\/www.fast2sms.com\/help\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.fast2sms.com\/help\/flutter-otp-sms-api\/#primaryimage"},"image":{"@id":"https:\/\/www.fast2sms.com\/help\/flutter-otp-sms-api\/#primaryimage"},"thumbnailUrl":"https:\/\/www.fast2sms.com\/help\/wp-content\/uploads\/2026\/11\/smart-otp-template-list-hd-6-scaled.webp","datePublished":"2026-11-18T18:14:34+00:00","dateModified":"2026-11-18T19:19:07+00:00","description":"Add OTP login to a Flutter or React Native app with Fast2SMS Smart OTP. Backend endpoints, Dart code, resend timer, autofill and error handling.","breadcrumb":{"@id":"https:\/\/www.fast2sms.com\/help\/flutter-otp-sms-api\/#breadcrumb"},"inLanguage":"en-IN","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.fast2sms.com\/help\/flutter-otp-sms-api\/"]}]},{"@type":"ImageObject","inLanguage":"en-IN","@id":"https:\/\/www.fast2sms.com\/help\/flutter-otp-sms-api\/#primaryimage","url":"https:\/\/www.fast2sms.com\/help\/wp-content\/uploads\/2026\/11\/smart-otp-template-list-hd-6-scaled.webp","contentUrl":"https:\/\/www.fast2sms.com\/help\/wp-content\/uploads\/2026\/11\/smart-otp-template-list-hd-6-scaled.webp","width":2560,"height":1600,"caption":"OTP Template List showing WhatsApp and SMS OTP template cards with OTP ID, number or sender, template ID and fallback"},{"@type":"BreadcrumbList","@id":"https:\/\/www.fast2sms.com\/help\/flutter-otp-sms-api\/#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":"Flutter OTP verification with Fast2SMS (and React Native): keep the API key on your server"}]},{"@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\/18004","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=18004"}],"version-history":[{"count":1,"href":"https:\/\/www.fast2sms.com\/help\/wp-json\/wp\/v2\/posts\/18004\/revisions"}],"predecessor-version":[{"id":19329,"href":"https:\/\/www.fast2sms.com\/help\/wp-json\/wp\/v2\/posts\/18004\/revisions\/19329"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.fast2sms.com\/help\/wp-json\/wp\/v2\/media\/17997"}],"wp:attachment":[{"href":"https:\/\/www.fast2sms.com\/help\/wp-json\/wp\/v2\/media?parent=18004"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.fast2sms.com\/help\/wp-json\/wp\/v2\/categories?post=18004"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.fast2sms.com\/help\/wp-json\/wp\/v2\/tags?post=18004"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}