← Use Cases/OTP Extraction

OTP Extraction

Our API automatically detects and extracts 4–8 digit codes and verification links from incoming emails. No regex, no template matching, no maintenance.

Plan requirements

  • Free plan: OTP detected but returns __DETECTED__ (upgrade hint)
  • Startup+ plan: Full OTP value returned via GET /v1/inboxes/{inbox}/otp
  • Growth+ plan: MCP extract_otp tool available

Via REST API

curl
# 1. Register inbox
curl -X POST https://api2.freecustom.email/v1/inboxes \
  -H "Authorization: Bearer fce_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{"inbox":"verify@ditapi.info"}'

# 2. Trigger signup/verification on the target service
# (your app code here)

# 3. Wait for email (long-poll — Developer+ plan)
curl "https://api2.freecustom.email/v1/inboxes/verify@ditapi.info/wait?timeout=30" \
  -H "Authorization: Bearer fce_your_api_key"

# 4. Extract OTP
curl "https://api2.freecustom.email/v1/inboxes/verify@ditapi.info/otp" \
  -H "Authorization: Bearer fce_your_api_key"
json
{
  "success": true,
  "data": {
    "inbox": "verify@ditapi.info",
    "otp": "847291",
    "verification_link": "https://acme.com/verify?token=abc123xyz",
    "from": "noreply@acme.com",
    "subject": "Your verification code is 847291",
    "message_id": "msg_01jqz3k4m5n6",
    "received_at": "2026-03-04T09:55:00.000Z"
  }
}

Node.js SDK

typescript
import { FreecustomEmailClient } from "freecustom-email";

const client = new FreecustomEmailClient({ apiKey: process.env.FCE_API_KEY! });

// Register inbox
await client.inboxes.register("verify@ditapi.info");

// Trigger your signup flow here...

// Wait for and extract OTP automatically
const otp = await client.otp.waitFor("verify@ditapi.info");
console.log("OTP:", otp); // "847291"

// Or get OTP + verification link together (without waiting)
const result = await client.otp.get("verify@ditapi.info");
console.log(result.otp, result.verification_link);

Python SDK

python
import asyncio, os
from freecustom_email import FreeCustomEmail

client = FreeCustomEmail(api_key=os.environ["FCE_API_KEY"])

async def main():
    await client.inboxes.register("verify@ditapi.info")
    
    # Trigger your signup flow here...
    
    # Wait for and extract OTP automatically
    otp = await client.otp.wait_for("verify@ditapi.info")
    print("OTP:", otp)

asyncio.run(main())

Some services send a click-to-verify link instead of a numeric OTP. The API and SDKs extract both:

typescript
const result = await client.otp.waitFor("verify@ditapi.info");

if (result.verification_link) {
  // Navigate to the link in Playwright
  await page.goto(result.verification_link);
} else if (result.otp) {
  // Enter the code in the form
  await page.fill('[name="otp"]', result.otp);
  await page.click('[type="submit"]');
}