Use Case
Send magic link emails with Postkit
Passwordless authentication via magic links. Postkit delivers the link email fast enough that users don't even switch tabs.
Get Started FreeThe problem
Magic links only work if they arrive within seconds. Slow delivery means users assume it failed and try again, generating multiple active tokens. You need speed and deduplication.
The Postkit solution
Postkit's sub-second delivery and idempotency keys keep magic link auth seamless. One token, one email, delivered fast.
magic-link.ts
await fetch("https://api.postkit.eu/v1/emails", {
method: "POST",
headers: {
Authorization: "Bearer pk_live_...",
"Content-Type": "application/json",
"Idempotency-Key": `magic-${sessionToken}`,
},
body: JSON.stringify({
from: "auth@yourapp.eu",
to: email,
subject: "Sign in to YourApp",
html: `<p>Click to sign in:</p>
<a href="${magicLinkUrl}">Sign in</a>
<p>This link expires in 10 minutes.</p>`,
}),
});