Identity & SSOvendor:clerkEmail OTPUnwrapped Magic LinkCarrier SMS DIDCloud KMS TOTP
Automate Clerk Magic Links (__clerk_ticket) & Email OTPs in Playwright
Automate Clerk Email OTPs, __clerk_ticket magic links (including SendGrid/Postmark click-tracker unwrapping), and SMS sign-ins in E2E & agent workflows.
1. 60-Second Gmail & Outlook Auto-Forwarding Filter
Don't want to change your existing account email on Clerk? Keep your corporate inbox on Clerk and forward only verification emails to <identity-slug>@in.sentryrelay.com. Sentry Relay's Stage 2 unwrapper preserves the original Clerk sender header automatically (full setup guide).
# Paste into Gmail -> Settings -> Filters -> Create a new filter ("Has the words")
from:(clerk.com OR clerk.dev OR accounts.dev) ("verification code" OR "one-time code" OR "sign in")
# Action: Forward it to -> <your-identity-slug>@in.sentryrelay.com2. Copy-Paste Clerk 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('Complete Clerk magic link or 6-digit Email OTP login', async ({ page }) => {
const email = 'clerk-e2e@in.sentryrelay.com';
await page.goto('https://your-app.accounts.dev/sign-in');
await page.fill('input[name="identifier"]', email);
await page.click('button[type="submit"]');
// Clerk sends either a 6-digit OTP or a __clerk_ticket magic link
const auth = await relay.wait('clerk-e2e', { timeout: 30 });
if (auth.event?.magicLink) {
await page.goto(auth.event.magicLink);
} else if (auth.event?.otpCode) {
await page.fill('input[name="code"]', auth.event.otpCode);
}
await expect(page).toHaveURL(/dashboard/);
});3. Clerk Production Gotchas
Custom Production Domains Still Match via __clerk_ticket
Production apps using Clerk send emails from their own custom domain (e.g., `auth@acme.com`). Stage 4 matches `__clerk_ticket=` URLs and Stage 5 heuristics extract custom-domain Clerk OTPs seamlessly.
ESP Click-Tracker Unwrapping
When an app routes Clerk emails through SendGrid or Postmark click-tracking, Stage 3 unwraps the redirect URL in memory so your Playwright `page.goto()` lands cleanly without double-consuming tokens.
Parallel Worker Isolation in CI
Give each Playwright worker its own Identity slug or wait with `since: Date.now()` so parallel CI shards never steal each other's Clerk OTPs.