Consumer Authentication

/

API reference

/

Magic links

/

Authenticate

Authenticate Magic Link

POSThttps://test.stytch.com/v1/magic_links/authenticate

Authenticate a User given a Magic Link. This endpoint verifies that the Magic Link token is valid, hasn't expired or been previously used, and any optional security settings such as IP match or user agent match are satisfied.


Body parameters


token*string

optionsobject

attributesobject

session_duration_minutesint

session_custom_claimsmap<string, any>

session_jwtstring

session_tokenstring

code_verifierstring

Response fields


status_codeint

request_idstring

method_idstring

reset_sessionsboolean

sessionobject

session_jwtstring

session_tokenstring

userobject

user_idstring
curl --request POST \
  --url https://test.stytch.com/v1/magic_links/authenticate \
  -u 'PROJECT_ID:SECRET' \
  -H 'Content-Type: application/json' \
  -d '{
    "token": "SeiGwdj5lKkrEVgcEY3QNJXt6srxS3IK2Nwkar6mXD4="
  }'

RESPONSE

200
{
  "method_id": "email-test-81bf03a8-86e1-4d95-bd44-bb3495224953",
  "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
  "reset_sessions": false,
  "session": null,
  "session_jwt": "",
  "session_token": "",
  "status_code": 200,
  "user": {...},
  "user_id": "user-test-16d9ba61-97a1-4ba4-9720-b03761dc50c6" 
}

Common Error Types