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.

Curated Stage 4 Extractor Profile (vendor:clerk)

Detects Clerk 6-digit verification codes across `clerk.com`, `clerk.dev`, and `accounts.dev` (plus custom domains via `smsOrSubjectIdentifiers` and `__clerk_ticket=` URL patterns), and unwraps ESP click-trackers automatically.

Matched Sender Domains
clerk.comclerk.devaccounts.dev
Login URL example: https://your-app.accounts.dev/sign-in
Filtered Non-Auth Noise
  • General product newsletters (filtered by auth context check)

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.com

2. 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

Frequently Asked Questions

Does Sentry Relay work when a SaaS uses Clerk on a custom sender domain?
Yes. Beyond clerk.com/accounts.dev, our Stage 4 rule matches __clerk_ticket links across any domain and Stage 5 proximity heuristics catch custom Clerk email templates.
Why did my Playwright script fail with "magic link already consumed"?
Email security scanners or prefetching proxies can pre-visit links, or two workers might grab the same link. Sentry Relay's Lua claim script ensures atomic single-worker consumption.
Can Clerk SMS OTPs be tested without VoIP rejections?
Yes. Paid Sentry Relay Identities provision real US carrier DIDs via Telnyx that pass Clerk phone verification checks.
Provision an Isolated Identity for Clerk

Start free in 3 minutes with @in.sentryrelay.com email + Simulated SMS, or attach a dedicated US carrier Telnyx SMS DID starting on Builder ($29/mo) and Growth/Pro ($79/mo).