A magic link is an email with a link to the app's login URL carrying sct_magic=<token>. Your page reads the token and sends it to the authenticate route, which returns a token set. The app's email method has to be set to sign-in links; with codes selected, these routes return 403 sign_in_method_disabled with details.method email_link.
Magic links go to email addresses only. Phone numbers get a one-time code.
Send a sign-in link#
/v1/auth/:app_id/magic_links/loginNoneSends a sign-in link to the email. A person with no account is created, unless sign-up is closed.
The request's Origin header is stored with the link as the place to return to.
curl -X POST https://api.scute.io/v1/auth/$SCUTE_APP_ID/magic_links/login \ -H "Content-Type: application/json" \ -d '{"identifier": "ada@example.com"}'{ "magic_link": { "id": "0193fa10-1c2d-7e3f-8a4b-5c6d7e8f9a0b" }, "user_meta_errors": null}Keep magic_link.id to poll the link status from the device that asked.
| Status | error_code | When |
|---|---|---|
| 400 | invalid_identifier | Missing or invalid email. |
| 403 | sign_in_method_disabled | Email sign-in or sign-in links are off for the app. |
| 429 | More than 5 sends to the same identifier in a minute. |
The sign-in refusals apply.
Send a sign-up link#
/v1/auth/:app_id/magic_links/registerNoneSame parameters, checks and response as Send a sign-in link. The audit event is magiclink.register.init instead of magiclink.login.init.
Authenticate a magic link#
/v1/auth/:app_id/magic_links/authenticateNoneExchanges the token from the link for a session. Call it from the page the link opens. The same route finishes OAuth and SAML sign-ins, whose redirects carry the token as sct_oauth.
curl -X PATCH https://api.scute.io/v1/auth/$SCUTE_APP_ID/magic_links/authenticate \ -H "Content-Type: application/json" \ -d '{"token": "'"$MAGIC_TOKEN"'"}'Returns a token set with status 200, or the next sign-in step. A link works once: when it is opened twice at the same time, only the first request gets a session.
A link sent by the challenge API for a purpose other than sign-in completes that challenge and returns no session, unless the workspace lets challenge links sign people in:
{ "status": "completed", "signed_in": false, "challenge": { "token": "ch_zN4kP2qX9wT5aB3xY9QkLm7RsT2uVw8E", "status": "completed", "purpose": "verify_identity", "method": "magic_link" }}| Status | error_code | When |
|---|---|---|
| 202 | Attack protection wants a code first. See Security verification. | |
| 403 | security_block | Attack protection refused the sign-in. |
| 403 | sign_in_method_disabled | Email sign-in or sign-in links were turned off after the link was sent. |
| 404 | magic_link_not_found_or_expired | Unknown, used, expired, or another app's token. |
Poll for the sign-in on the asking device#
/v1/auth/:app_id/magic_links/statusNoneLets the device that asked for the link get a session after the link was opened on another device. Poll it with the magic_link.id from the send response.
curl -X POST https://api.scute.io/v1/auth/$SCUTE_APP_ID/magic_links/status \ -H "Content-Type: application/json" \ -d '{"id": "0193fa10-1c2d-7e3f-8a4b-5c6d7e8f9a0b"}'| Status | Body | Meaning |
|---|---|---|
| 200 | Token set | The link was opened and the sign-in is done. |
| 200 | {"message": "ok"} | The window to pick up the session on this device has closed. Stop polling. |
| 202 | verification_required | Attack protection wants a code from this device first. |
| 404 | {"error": "Not found"} | The link is unknown, belongs to another app, or has not been opened yet. Keep polling. |
| 409 | error_code sign_in_pending | The device that opened the link is still finishing MFA or a contact step. Keep polling. |
| 409 | error_code sign_in_step_started | This device was already given its own step. Finish it. |
The workspace's cross-device MFA setting decides what happens when the sign-in owes a step. With the default (clicking_device), the device that opened the link does the step and this route returns 409 sign_in_pending until it is done. With both_devices, this route starts the step for this device and returns it in the sign-in step shape.
Accept an invitation#
/v1/auth/:app_id/magic_links/confirm_inviteNoneSigns in a person who was invited to the app, using the token from the invitation email.
curl -X POST https://api.scute.io/v1/auth/$SCUTE_APP_ID/magic_links/confirm_invite \ -H "Content-Type: application/json" \ -d '{"token": "'"$INVITE_TOKEN"'", "user_meta": {"company": "Acme"}}'Returns a token set, or an MFA step when the app requires one.
| Status | error_code | When |
|---|---|---|
| 404 | magic_link_not_found_or_expired | Unknown, used, or expired invitation. |
| 422 | incomplete_user_info | Required user fields are still missing. errors lists them. |