Magic Link APIs
Overview
The Magic Link APIs enable users to sign in by clicking a link delivered to their email or phone.
Read about Magic Link implementation types here.
This authentication method has two phases:
- Initiate the process and send the magic link — this is triggered from the application sign-in or sign-up screen.
- Verify the token and return the session and refresh tokens (signed-in user).
Use Cases
- Sign up a new user
- Sign in an existing user
- Sign in with auto sign-up if the user does not exist
- Update user's email address
- Update user's phone number (SMS)
Examples
Example - sign up over email
- Trigger the sign-up process with the Sign-Up endpoint. On success, a magic link with a token is generated and delivered to the user's email.
- When the user clicks the magic link, call the Verify Magic Link endpoint. Once the token is validated, the endpoint returns the session and refresh tokens.
Verify Code (IM) POST
Verify a Sign in / Sign up based on an instant message
Sign-Up POST
### Sign-up new end user by sending a magic link via email Initiate a sign-up process by sending a magic link to a new end user. Descope will generate and deliver a clickable magic link to the email address specified. The clickable magic link is made up of two parts - the URI you provide in the `URI` field and the magic link token generated by Descope. For example, if `URI=https://app.mycompany.com/magiclink/verify`, the clickable magic link will be `https://app.mycompany.com/magiclink/verify?t=magic-link-token.` Magic links expire in the time frame configured in the [Descope console](https://app.descope.com/settings/authentication/magiclink), so sending multiple magic links (for example, when an end user tries to sign-up a second or third time) does not invalidate magic links that have already been sent. The endpoint will return a failure code if the email address is already registered. Note that `URI` is an optional parameter. If omitted - the project setting will apply. If provided - it should to be part of the allowed `Approved Domains` configured in the project settings. ### Next Steps Verify the magic link token using the [Verify Token](/api/magic-link/verification/verify-token) endpoint. ### See Also - See [Magic link Authentication](/auth-methods/magic-link/with-sdks/client#introduction) for details about implementing magic links. - See [The User Object](/api/overview#the-user-object) for further details on how to identify users and their contact information such as email addresses and phone number. - Use the [Sign-In](/api/magic-link/email/sign-in) endpoint to sign-in an existing end user. - Use the [Sign-In with Auto Sign-up](/api/magic-link/email/sign-in-auto-sign-up) endpoint to create a single sign-up and sign-in flow, which will create a new end user if they are not already registered.