DhokoAuthaz
DocumentationAPI Reference
  • Get Started

    • Authaz
    • Core Concepts
    • Set up your app
    • Quickstart — cURL
  • Authentication

    • Authentication Settings
    • Signup
    • Invitations
    • Password Authentication
    • Multi-Factor Auth
    • Magic Link
    • OAuth / Social Login
    • Passkey (WebAuthn)
    • SAML SSO
    • Machine-to-Machine (M2M)
    • API Keys
  • Authorization

    • Authorization
    • Resources
    • Policies
    • Roles
    • Access Explorer
  • Tenancy

    • Multi-tenancy
    • Tenancy Customization
  • Brand & Host

    • Branding
    • Custom Domains
    • Communications & Email Templates
  • Operate

    • Users
    • Analytics
    • Audit Logs
    • Application Settings
  • SDK Quickstarts

    • Quickstart — Next.js
    • Quickstart — React SPA
    • Quickstart — Hono
    • Quickstart — .NET (Authaz.Sdk)
  • Recipes

    • Recipes & Cookbook
    • Next.js — first integration
    • Next.js — B2B SaaS (multi-tenant)
    • Hono — first integration
    • Hono — B2B SaaS (multi-tenant)
    • React SPA — first integration
    • React SPA — B2B SaaS (multi-tenant)
    • .NET — first integration
    • .NET — B2B SaaS (multi-tenant)
  • Reference

    • Tokens
    • API Reference
    • Errors & Troubleshooting
  • Documentation

    • How Authaz is Built
  1. Authaz
  2. Docs
  3. Authentication
  4. Magic Link

Authentication

Magic Link

3 min read·Updated May 7, 2026

Magic Link is the simplest authentication method to integrate and the easiest for users. They enter an email, Authaz sends a code, they paste it in. No password to remember, no app to install.

Use it in your app. Once enabled, Magic Link appears as a sign-in option on Authaz Sign-In automatically — your app code doesn't change. The standard sign-in flow (Next.js · React · Hono · cURL) routes the user through whichever method they pick.

# Enable magic link for an application
curl -X PUT https://your-app.authaz.io/api/v1/applications/{appId}/auth/magic-link \
  -H "X-API-Key: $AUTHAZ_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "enabled": true,
    "expirationMinutes": 10
  }'

The button shows up on Authaz Sign-In automatically.

How it works

Previous
Multi-Factor Auth
Next
OAuth / Social Login
#
  1. User enters their email on Authaz Sign-In.
  2. Authaz emails them a code with a link.
  3. User clicks the link (or pastes the code into the input on the same browser tab).
  4. Authaz verifies the code, creates a session, redirects back to your app with an authorization code.
  5. Your backend exchanges the code for tokens — same as every other flow.

The link can be opened on any device — useful for desktop signup where the email arrives on the user's phone.

Configuration#

SettingDefaultWhat it controls
enabledfalseTurns the provider on.
expirationMinutes10How long a code stays valid after Authaz emails it.
rateLimit.maxRequests3Codes per email per windowMinutes.
rateLimit.windowMinutes15Sliding window for the rate limit.

The codes themselves are 32-byte URL-safe random tokens. They are single-use and rotate on each request — there's no separate "code length" or "alphanumeric vs numeric" knob; the format is fixed for security.

Triggering a code from your backend#

Most apps let Authaz Sign-In own the form, but you can request a code directly:

curl -X POST https://your-app.authaz.io/auth/magic-link/request \
  -H "Content-Type: application/json" \
  -d '{
    "applicationId": "app_01h...",
    "email": "user@example.com",
    "redirectUri": "https://yourapp.com/auth/callback"
  }'

The response is 200 OK whether or not the email exists. Like password reset, treating "unknown email" as a hint would leak account existence.

Verifying a code#

When the user clicks the link, Authaz handles verification in Authaz Sign-In. If you've built your own UI:

curl -X POST https://your-app.authaz.io/auth/magic-link/verify \
  -H "Content-Type: application/json" \
  -d '{
    "applicationId": "app_01h...",
    "email": "user@example.com",
    "code": "the-code-from-the-email"
  }'

Successful verification returns an authorization code. From there it's the standard OAuth 2.0 token exchange — see the cURL quickstart Step 3.

Brand the email#

The magic link email pulls subject, greeting, and CTA copy from your application's email template. Edit it in Dashboard → Application → Communications → Email Templates → Magic Link (see the Communications page), or programmatically:

curl -X PUT https://your-app.authaz.io/api/v1/applications/{appId}/email-templates/magic-link \
  -H "X-API-Key: $AUTHAZ_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "subject": "Your sign-in link to {{appName}}",
    "html": "<p>Hello {{userEmail}},</p><p>Click <a href=\"{{magicLink}}\">here</a> to sign in.</p>",
    "text": "Hello {{userEmail}}, sign in: {{magicLink}}"
  }'

Available variables: {{appName}}, {{userEmail}}, {{magicLink}}, {{code}}, {{expirationMinutes}}.

Multi-tenant: per-tenant settings#

In multi-tenant apps, you can override the rate limit and expiration per tenant — handy when one tenant has stricter security needs:

curl -X PUT https://your-app.authaz.io/api/v1/applications/{appId}/tenants/{tenantId}/auth/magic-link \
  -H "X-API-Key: $AUTHAZ_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "enabled": true, "expirationMinutes": 5 }'

If a tenant has no override, the application-level config applies.

When to use Magic Link#

  • Onboarding-first products where typing a password is friction.
  • Low-frequency apps users sign into a few times a year — they'd reset their password anyway.
  • Mobile-first signup where the email naturally arrives on the same device.
  • Backup method alongside password or passkey — if a user's primary method fails, Magic Link still works as long as they control their email.

It's not a great fit for high-security workflows where someone with email access shouldn't be able to assume the user's identity. Pair it with MFA, or use Passkey instead.

Next steps#

  • Password — the more traditional alternative.
  • Passkey — phishing-resistant, no email round-trip required.
  • cURL quickstart — see the surrounding OAuth flow.