Skip to main content
POST
Generate secure authentication links for users. This endpoint allows administrators to create magic links, recovery links, or invitation links that can be sent to users via custom channels.
This endpoint requires service role authentication. Only use the service role key on your backend servers, never in client-side code.

Request Body

string
required
The type of link to generate.Options:
  • signup - Email confirmation link for new users
  • magiclink - Passwordless authentication link
  • recovery - Password recovery link
  • invite - User invitation link
  • email_change - Email change confirmation link
string
required
Email address of the user for whom to generate the link.
string
URL to redirect to after the link is used. If not provided, uses the default redirect URL.
object
Additional data to include with the link (for invitations or user creation).
string
Password for the user (required for some link types like recovery).

Response

The generated authentication link that can be sent to the user
string
One-time password for email verification (when applicable)
string
Hashed version of the token for verification purposes
string
Type of verification this link performs
string
The redirect URL that will be used after verification

Error Responses

Generate a passwordless authentication link:
Generate a password recovery link:
Generate an email confirmation link for new users:
Generate an invitation link for new users:

Email Change Confirmation

Generate a link to confirm email address changes:

Implementation Examples

Node.js Backend Handler

Use Cases

Custom Email Templates

Generate links for use in custom email templates:

Integration with External Systems

Generate links for integration with CRM or marketing tools:

Security Considerations

  • Service Role Protection: Never expose service role keys in client-side code
  • Link Expiration: Generated links expire after 1 hour by default
  • Single Use: Links can only be used once for security
  • Rate Limiting: Implement rate limits for link generation
  • Audit Logging: Log all link generation activities

Best Practices

  • Validate all input parameters
  • Use HTTPS for all redirect URLs
  • Implement proper access controls
  • Monitor for suspicious link generation patterns
  • Provide clear instructions with generated links
  • Use descriptive redirect URLs
  • Handle expired links gracefully
  • Offer alternative authentication methods

Testing

Unit Tests

Create User

Create new user accounts

Update User

Update user information

Invite User

Send user invitations

Verify Link

Verify generated links