Protect your online identity with TempPhoneNumber. Use our free temporary non-VoIP phone numbers to verify accounts on WhatsApp, Telegram, Google, and 3,000+ services without exposing your private info.
Live SMS Feed
Protect your online identity with TempPhoneNumber. Use our free temporary non-VoIP phone numbers to verify accounts on WhatsApp, Telegram, Google, and 3,000+ services without exposing your private info.
Live SMS Feed
Stay informed on account verification safety tips, telecom protocols, developer MCP integrations, and digital identity defense strategies.
Comprehensive step-by-step masterclass explaining how real non-VoIP temporary numbers protect you from spam calls, targeted ads, and data broker profiling.
Learn how to integrate the temphonenumber MCP server with Claude Desktop, Cursor, and local LLMs to automate SMS verification workflows programmatically.
An in-depth telecom engineering breakdown of Home Location Register (HLR) pings, SS7 signaling, and carrier lookup databases used by verification systems.
How to register Telegram accounts securely without leaking your primary SIM number or exposing your contact book to data scraping.
Best practices for software engineers provisioning international temporary numbers for automated testing of AI platform signups and API access.
The architectural difference between physical tier-1 cellular routing and virtual PBX numbers, explaining why banks and secure apps reject VoIP.
Subscribe to our newsletter for country stock updates, feature announcements, and API changes.
Join 15,000+ privacy-conscious users. Unsubscribe at any time.
To automate SMS 2FA verification in Playwright or Cypress without flaky shared inboxes, create a small helper that acquires a fresh Non-VoIP number via POST /api/buyNumbers, enters the phone number into your signup form, polls GET /api/getNumber/{orderId} for the incoming code, and flags any failed run with POST /api/flagNumber/{orderId}.

TEMPHONENUMBER_CLIENT_ID, TEMPHONENUMBER_CLIENT_SECRET) and perform HTTP polling in Node/TypeScript helpers (cy.task() in Cypress).finally blocks so unresponsive lines trigger flagNumber refunds automatically.Automated end-to-end tests usually cruise right through email, password, and form validation—until a test hits a phone verification or SMS 2FA step.
At that moment, many teams either skip E2E coverage on onboarding altogether or wire every pull request to one shared test phone—which breaks immediately as soon as two CI jobs run at once.
Using Playwright or Cypress alongside the TempPhoneNumber REST API solves this cleanly: each test rents an isolated Non-VoIP phone number on demand, waits for its own code, completes the UI flow, and cleans up afterward.
| Layer | Responsibility | Where It Runs |
|---|---|---|
| 1. Auth & Line Helper | Exchanges OAuth token, calls /api/buyNumbers & /api/getNumber/{id} | Node.js test helper / Cypress cy.task() |
| 2. Browser Runner | Fills phone input, clicks "Send Code", submits OTP code | Playwright page or Cypress cy commands |
| 3. Cleanup / Refund | Calls POST /api/flagNumber/{id} if no SMS arrives in time | try / finally block in test spec |
Why not call the SMS API from browser window.fetch? Your client_secret should never enter browser context. Running API calls inside Node (Playwright test workers or Cypress setupNodeEvents tasks) keeps secrets secure and avoids CORS issues.
tests/helpers/sms-otp.ts)Create one small reusable TypeScript helper shared by Playwright or Cypress Node tasks. If you have not checked the full endpoint parameters yet, review our Python & TypeScript API quickstart first.
const BASE_URL = 'https://api.temphonenumber.com'
let cachedToken: { token: string; expiresAt: number } | null = null
async function getBearerToken(): Promise<string> {
if (cachedToken && Date.now() < cachedToken.expiresAt - 60_000) {
return cachedToken.token
}
const res = await fetch(`${BASE_URL}/oauth/token`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
client_id: process.env.TEMPHONENUMBER_CLIENT_ID!,
client_secret: process.env.TEMPHONENUMBER_CLIENT_SECRET!,
grant_type: 'client_credentials',
}),
})
if (!res.ok) throw new Error(`Auth error: ${res.status}`)
const json = await res.json()
cachedToken = {
token: json.access_token,
expiresAt: Date.now() + (Number(json.expires_in) || 86400) * 1000,
}
return cachedToken.token
}
export async function leaseTestPhoneNumber(websiteId: string) {
const token = await getBearerToken()
const headers = { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' }
const buyRes = await fetch(`${BASE_URL}/api/buyNumbers`, {
method: 'POST',
headers,
body: JSON.stringify({ services: [{ websiteId, quantity: 1 }] }),
})
if (!buyRes.ok) throw new Error(`buyNumbers failed: ${buyRes.status}`)
const parentId: string = (await buyRes.json()).data
const listUrl = `${BASE_URL}/api/getNumbers?limit=5&filter=${encodeURIComponent(JSON.stringify({ parentId }))}`
const listRes = await fetch(listUrl, { headers })
const order = (await listRes.json())?.data?.edges?.[0]
if (!order?.orderId || !order?.number) throw new Error('Allocated order missing')
return { orderId: String(order.orderId), phone: String(order.number) }
}
export async function waitForSmsOtp(orderId: string, timeoutMs = 90_000): Promise<string> {
const token = await getBearerToken()
const headers = { Authorization: `Bearer ${token}` }
const deadline = Date.now() + timeoutMs
while (Date.now() < deadline) {
await new Promise((r) => setTimeout(r, 5000))
const res = await fetch(`${BASE_URL}/api/getNumber/${orderId}`, { headers })
if (!res.ok) continue
const record = (await res.json())?.data
const firstMsg = Array.isArray(record?.messages) ? record.messages[0] : null
if (firstMsg?.otp) return String(firstMsg.otp)
if (typeof firstMsg?.text === 'string') {
const match = firstMsg.text.match(/\b(\d{4,8})\b/)
if (match?.[1]) return match[1]
}
}
throw new Error(`Timed out waiting for OTP on order ${orderId}`)
}
export async function flagUnresponsiveNumber(orderId: string): Promise<void> {
const token = await getBearerToken()
await fetch(`${BASE_URL}/api/flagNumber/${orderId}`, {
method: 'POST',
headers: { Authorization: `Bearer ${token}` },
}).catch(() => undefined)
}In Playwright, wrap the test body in try / finally so any timeout or UI failure before receiving an SMS calls flagUnresponsiveNumber(orderId) cleanly:
import { test, expect } from '@playwright/test'
import {
leaseTestPhoneNumber,
waitForSmsOtp,
flagUnresponsiveNumber,
} from './helpers/sms-otp'
test('completes SMS 2FA signup cleanly', async ({ page }) => {
test.setTimeout(150_000) // Allow realistic SMS carrier delivery window
const websiteId = process.env.QA_TEST_WEBSITE_ID!
const { orderId, phone } = await leaseTestPhoneNumber(websiteId)
let otpReceived = false
try {
await page.goto('/signup')
await page.getByLabel('Phone number').fill(phone)
await page.getByRole('button', { name: 'Send Verification Code' }).click()
const otp = await waitForSmsOtp(orderId, 90_000)
otpReceived = true
await page.getByLabel('Verification code').fill(otp)
await page.getByRole('button', { name: 'Verify' }).click()
await expect(page).toHaveURL(/\/dashboard/)
} finally {
if (!otpReceived) {
await flagUnresponsiveNumber(orderId)
}
}
})Because Cypress browser commands cannot read server secrets or wait safely on raw polling loops directly inside browser context, register two Node tasks in cypress.config.ts:
import { defineConfig } from 'cypress'
import {
leaseTestPhoneNumber,
waitForSmsOtp,
flagUnresponsiveNumber,
} from './tests/helpers/sms-otp'
export default defineConfig({
e2e: {
setupNodeEvents(on) {
on('task', {
leasePhone: (websiteId: string) => leaseTestPhoneNumber(websiteId),
waitForOtp: (orderId: string) => waitForSmsOtp(orderId, 90_000),
flagPhone: (orderId: string) => flagUnresponsiveNumber(orderId).then(() => null),
})
},
},
})Then invoke those tasks inside your Cypress spec:
describe('Phone Verification Flow', () => {
it('verifies a new user with an isolated Non-VoIP line', () => {
cy.task<{ orderId: string; phone: string }>('leasePhone', Cypress.env('QA_WEBSITE_ID')).then(
({ orderId, phone }) => {
cy.visit('/signup')
cy.findByLabelText(/phone/i).type(phone)
cy.findByRole('button', { name: /send code/i }).click()
cy.task<string>('waitForOtp', orderId, { timeout: 100_000 }).then((otp) => {
cy.findByLabelText(/code/i).type(otp)
cy.findByRole('button', { name: /verify/i }).click()
cy.url().should('include', '/dashboard')
})
}
)
})
})taskTimeout / test.setTimeout explicitly: Default 30-second test timeouts will kill valid SMS deliveries before a carrier finishes routing. Give OTP tests at least 120–150 seconds total.websiteId across US, UK, and EU regions in parameterized tests—see our multi-country signup QA testing guide.Debugging a failing test locally? Connect your IDE assistant (Cursor, Claude Code, or VS Code) via our MCP Server guide so your agent can inspect active orders and test messages interactively while you tweak selectors.
자주 묻는 질문
cy.task() for SMS API polling?cy.task() executes inside Node.js rather than the browser sandbox, which protects your TEMPHONENUMBER_CLIENT_SECRET, avoids browser CORS restrictions, and lets Cypress wait cleanly while polling for incoming SMS messages.
Call leaseTestPhoneNumber() inside each isolated test (or beforeEach) so every parallel Playwright worker receives its own unique orderId and phone number rather than sharing one inbox.
Calling POST /api/flagNumber/{orderId} inside your finally cleanup block cancels the pending line and returns credits to your wallet automatically—saving money across failed or canceled CI builds.
Set the OTP wait helper to 90 seconds and the overall test timeout to 120–150 seconds. Most texts arrive quickly, but giving a comfortable buffer eliminates intermittent network spikes in CI.
Yes. Verify any test number's Mobile vs. VoIP classification beforehand using our free Carrier Lookup tool so your negative fraud-filter assertions test genuine VoIP lines while happy-path tests use Non-VoIP numbers.
Testing phone verification in Playwright or Cypress does not require fake backdoors or physical SIM drawers. With one 50-line Node helper, per-test number isolation, and automatic flagNumber refunds on failures, your E2E suites validate real user SMS journeys on every release.