Cloud & Infravendor:cloudflareEmail OTPUnwrapped Magic LinkCloud KMS TOTP
Automate Cloudflare Dashboard 2FA & OTP in Playwright & Stagehand
Automate Cloudflare Dashboard 2FA authentication codes, verification links, and KMS TOTP while filtering out billing and DDoS alert digests.
1. 60-Second Gmail & Outlook Auto-Forwarding Filter
Don't want to change your existing account email on Cloudflare? Keep your corporate inbox on Cloudflare and forward only verification emails to <identity-slug>@in.sentryrelay.com. Sentry Relay's Stage 2 unwrapper preserves the original Cloudflare sender header automatically (full setup guide).
# Paste into Gmail -> Settings -> Filters -> Create a new filter ("Has the words")
from:(cloudflare.com OR notify.cloudflare.com) ("authentication code" OR "verification code" OR "login code")
# Action: Forward it to -> <your-identity-slug>@in.sentryrelay.com2. Copy-Paste Cloudflare 2FA Automation Snippets
Choose your browser automation stack below. All snippets resolve codes in <200ms with Upstash Redis 15-second lookback protection so arrived-before-wait race conditions never fail a run.
import { test, expect } from '@playwright/test';
import { SentryRelay } from '@sentryrelay/sdk';
const relay = new SentryRelay({ apiKey: process.env.SENTRY_RELAY_API_KEY! });
test('Cloudflare Dashboard login with Email OTP or TOTP', async ({ page }) => {
await page.goto('https://dash.cloudflare.com/login');
await page.fill('input[name="email"]', process.env.CF_EMAIL!);
await page.fill('input[name="password"]', process.env.CF_PASSWORD!);
await page.click('button[type="submit"]');
// Check if Cloudflare requires Email Auth Code (new IP/device) or TOTP
const emailCodeInput = page.locator('input[name="emailCode"]');
if (await emailCodeInput.isVisible({ timeout: 5000 }).catch(() => false)) {
const auth = await relay.wait('cf-infra-bot', {
channel: 'email',
sender: 'cloudflare.com',
timeout: 30,
});
await emailCodeInput.fill(auth.event!.otpCode!);
await page.click('button[type="submit"]');
}
const totpInput = page.locator('input[name="twoFactorToken"]');
if (await totpInput.isVisible({ timeout: 4000 }).catch(() => false)) {
const token = await relay.totp.get('cf-infra-bot', 'cloudflare_totp');
await totpInput.fill(token.code);
await page.click('button[type="submit"]');
}
await expect(page).toHaveURL(/dash\.cloudflare\.com/);
});3. Cloudflare Production Gotchas
Different Sender Subdomain (`notify.cloudflare.com`)
Cloudflare sends dashboard verification emails from `notify.cloudflare.com` as well as `cloudflare.com`. Querying `sender: "cloudflare.com"` matches both automatically.
Dual Challenge: Email Device Code + TOTP
Cloudflare frequently asks for an email authentication code on first cloud-browser login followed by TOTP. Keep both your forwarded email and TOTP secret under the same Identity.
Weekly Analytics & DDoS Digests Ignored
Numbers inside weekly Cloudflare analytics or mitigated attack digests are explicitly disqualified by the `vendor:cloudflare` rule.