Guides

Phone Verification for Browser Automation

Use temporary phone numbers to bypass "verify your phone" prompts during automated sign-ups and logins.

Get a real US mobile number, receive an SMS verification code, and enter it programmatically — all via API or MCP.

Find the target service

List available services to get the exact serviceName for your target.

curl https://api.trunx.ai/api/verifications/services \
  -H "Authorization: Bearer $TRUNX_API_KEY"
const { services } = await fetch("https://api.trunx.ai/api/verifications/services", {
  headers: { Authorization: "Bearer tk_live_..." },
}).then((r) => r.json());

const google = services.find((s) => s.serviceName === "google");
import requests

services = requests.get(
    "https://api.trunx.ai/api/verifications/services",
    headers={"Authorization": "Bearer tk_live_..."},
).json()["services"]

google = next(s for s in services if s["serviceName"] == "google")

Use serviceName exactly as returned (e.g. google, not Google). The description field has the human-readable name.

Request a phone number

Create a verification for the target service. You'll get a real US mobile number.

curl -X POST https://api.trunx.ai/api/verifications \
  -H "Authorization: Bearer $TRUNX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"serviceName": "google"}'
const verification = await fetch("https://api.trunx.ai/api/verifications", {
  method: "POST",
  headers: {
    Authorization: "Bearer tk_live_...",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ serviceName: "google" }),
}).then((r) => r.json());

console.log(verification.number); // +17755551234
verification = requests.post(
    "https://api.trunx.ai/api/verifications",
    headers={"Authorization": "Bearer tk_live_..."},
    json={"serviceName": "google"},
).json()

print(verification["number"])  # +17755551234

Enter verification.number into the phone verification prompt on the target site.

Poll for the OTP code

After submitting the number on the target site, poll for the verification code. The endpoint waits up to 15 seconds server-side before returning.

curl https://api.trunx.ai/api/verifications/$VERIFICATION_ID/code \
  -H "Authorization: Bearer $TRUNX_API_KEY"
async function waitForCode(verificationId) {
  for (let i = 0; i < 4; i++) {
    const { status, otpCode } = await fetch(
      `https://api.trunx.ai/api/verifications/${verificationId}/code`,
      { headers: { Authorization: "Bearer tk_live_..." } }
    ).then((r) => r.json());

    if (status === "completed") return otpCode;
    // Each call already waits up to 15s, retry if still pending
  }
  throw new Error("Timeout waiting for OTP");
}

const code = await waitForCode(verification.id);
console.log("OTP:", code); // 123456
import time

def wait_for_code(verification_id):
    for _ in range(4):
        data = requests.get(
            f"https://api.trunx.ai/api/verifications/{verification_id}/code",
            headers={"Authorization": "Bearer tk_live_..."},
        ).json()

        if data["status"] == "completed":
            return data["otpCode"]
        # Each call already waits up to 15s, retry if still pending

    raise TimeoutError("Timeout waiting for OTP")

code = wait_for_code(verification["id"])
print("OTP:", code)  # 123456

Enter the returned otpCode into the verification form on the target site.

Each /code call polls the provider for up to 15 seconds. With 4 retries, you get ~60 seconds of total wait time. Most codes arrive within 30 seconds.

Clean up (optional)

If you no longer need the verification (e.g. the code was wrong or you want to abort), cancel it to release the number.

curl -X POST https://api.trunx.ai/api/verifications/$VERIFICATION_ID/cancel \
  -H "Authorization: Bearer $TRUNX_API_KEY"

Using with MCP

AI agents can use the same flow via MCP tools — no REST calls needed.

1. verify_list_services        → find the service name
2. verify_get_number(service)  → get a temp phone number
3. [enter number on target site]
4. verify_get_code(id)         → retrieve the OTP
5. [enter code on target site]
6. verify_cancel(id)           → clean up if needed

See MCP Setup for connecting your agent to the Trunx MCP endpoint.

On this page