# 1. Pre-fetch Links in Background (Zero-Delay) Secretly pre-fetch verification links with zero delay before the user clicks login. --- **ReOTP** is designed to deliver a "Zero-Type Auth" experience. Simply request the verification links and we will magically capture the user's phone number directly from their message! ### Request Body Parameters: - `apiKey` (string - Required): Your project's API Key. - `phoneNumber` (string - Optional): The user's phone number. If omitted, we will automatically capture it from the sender. - `method` (string - Required): Must be `"WHATSAPP"` or `"TELEGRAM"`. - `returnUrl` (string - Optional): Redirect URL for Telegram bot completion. ### Response Body Parameters: - `requestId` (string): Unique identifier for the verification session. - **UI Best Practices:** We highly recommend displaying a countdown timer in your UI to guide the user to complete the verification before it times out. Send a POST request to the endpoint shown in the code panel to initialize the session. ## Code Examples ### cURL (WhatsApp) ```javascript curl -X POST https://[your-domain.com]/api/verify/init \ -H "Content-Type: application/json" \ -d '{ "apiKey": "YOUR_API_KEY", "method": "WHATSAPP" }' ``` ### cURL (Telegram) ```javascript curl -X POST https://[your-domain.com]/api/verify/init \ -H "Content-Type: application/json" \ -d '{ "apiKey": "YOUR_API_KEY", "method": "TELEGRAM", "returnUrl": "https://your-app.com/success" }' ``` ### JavaScript ```javascript const initVerification = async () => { const res = await fetch("https://[your-domain.com]/api/verify/init", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ apiKey: "YOUR_API_KEY", method: "WHATSAPP", // Or "TELEGRAM" returnUrl: "https://your-app.com/success" // Optional for Telegram }) }); const data = await res.json(); if (data.requestId) { console.log("Success! Session ID:", data.requestId); // Redirect or open the link const destinationLink = data.waLink || data.tgLink; window.open(destinationLink, "_blank"); } }; ``` ### Node.js ```javascript const axios = require('axios'); axios.post('https://[your-domain.com]/api/verify/init', { apiKey: 'YOUR_API_KEY', method: 'WHATSAPP', // or 'TELEGRAM' returnUrl: 'https://your-app.com/success' }) .then(response => { console.log('Session ID:', response.data.requestId); console.log('Verification Link:', response.data.waLink || response.data.tgLink); }) .catch(error => { console.error('Error starting verification:', error); }); ``` ### Python ```javascript import requests payload = { "apiKey": "YOUR_API_KEY", "method": "WHATSAPP", # or "TELEGRAM" "returnUrl": "https://your-app.com/success" } response = requests.post( "https://[your-domain.com]/api/verify/init", json=payload ) data = response.json() print("Session ID:", data.get("requestId")) print("Link:", data.get("waLink") or data.get("tgLink")) ``` ## Interactive Demo Demo type: init Title: Interactive Verification Demo See the live demo at: https://reotp.com/hi/docs/api-init