Login or Create User by Magic Link
Create an email Magic Link to the provided email for login verification. If no user account exists, a new user will be created and Magic Link sent.
HTTP Request
POST /v1/auth/magic_links/email/login_or_create
Returns
A successful response returns an object with user_id, user_created indicating if the user has been newly created, and email_id properties.
Body
-
RequiredEmail that uniquely identifies the user.Minimum length is
1. -
The base url we will use to construct the final login magic link and send to the user via email if this is a login (existing user). If the
redirect_urlishttps://streambird.io/authenticate, final url user sees in email will behttps://streambird.io/authenticate?token=autogeneratedmagictoken. We will redirect to your app in this url and your app should handle and parse thetokenparameter and allow the user log in. If no url is sent in, we will use the default redirect url set in the Console and if no default redirect url is available, an error will be returned. -
The base url we will use to construct the final login magic link and send to the user via email if this is a registration (new user). If the
redirect_urlishttps://streambird.io/authenticate, final url user sees in email will behttps://streambird.io/authenticate?token=autogeneratedmagictoken. We will redirect to your app in this url and your app should handle and parse thetokenparameter and register the user. If no url is sent in, we will use the default redirect url set in the Console and if no default redirect url is available, an error will be returned. -
Expiration time of the magic link in minutes for login (when an existing user is found) Must be between 5 to 10080 minutes (7 days), defaults to 60 minutes.
-
Expiration time of the magic link in minutes for registration (when a new user is created). Must be between 5 to 10080 minutes (7 days), defaults to 60 minutes.
-
Determines if verification for the authentication method (email, phone_number) is required before marking the user as active.
-
Device fingerprinting metadata for fraud detection during verification step. This is useful to ensure that the user who originated the request matches the user that verifies the token. Verification requirements can be enabled in the
Verify Tokenstep by matching fields in thedevice_fingerprintsuch as IP, User Agent or the combination of them (more fraud detection features coming soon!)
curl \
--request POST 'https://api.streambird.io/v1/auth/magic_links/email/login_or_create' \
--header "Authorization: Bearer $ACCESS_TOKEN" \
--header "Content-Type: application/json" \
--data '{"email":"sandbox@streambird.io","expires_in":60,"login_redirect_url":"http://localhost:8081/authenticate","registration_redirect_url":"http://localhost:8081/authenticate"}'
{
"email": "sandbox@streambird.io",
"expires_in": 60,
"login_redirect_url": "http://localhost:8081/authenticate",
"registration_redirect_url": "http://localhost:8081/authenticate"
}
{
"status": "active",
"user_id": "user_24wFP9pDa9YiMJLun94iKykoZs2",
"email_id": "email_24oXBL3PufzHkH1Jzyjc2EXYeo7",
"created_at": 1630989225,
"updated_at": 1630989225,
"user_created": false
}