Consumer Authentication

/

API reference

/

Magic links

/

Via email

/

Log in or create user

Log in or create User by email

POSThttps://test.stytch.com/v1/magic_links/email/login_or_create

Send either a login or signup Magic Link to the User based on if the email is associated with a User already. A new or pending User will receive a signup Magic Link. An active User will receive a login Magic Link. For more information on how to control the status your Users are created in see the create_user_as_pending flag.

Next steps

The User is emailed a Magic Link which redirects them to the provided redirect URL. Collect the token from the URL query parameters and call Authenticate Magic Link to complete authentication.


Body parameters


email*string

login_magic_link_urlstring

signup_magic_link_urlstring

login_expiration_minutesint

signup_expiration_minutesint

login_template_idstring

signup_template_idstring

create_user_as_pendingboolean

localestring

attributesobject

code_challengestring

Response fields


status_codeint

request_idstring

user_idstring

email_idstring

user_createdboolean
curl --request POST \
  --url https://test.stytch.com/v1/magic_links/email/login_or_create \
  -u 'PROJECT_ID:SECRET' \
  -H 'Content-Type: application/json' \
  -d '{
    "email": "sandbox@stytch.com"
  }'

RESPONSE

200
{
  "status_code": 200,
  "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
  "user_id": "user-test-16d9ba61-97a1-4ba4-9720-b03761dc50c6",
  "email_id": "email-test-81bf03a8-86e1-4d95-bd44-bb3495224953",
  "user_created": true
}

Common Error Types