API reference

Magic links

Email a sign-in link, exchange its token for a session, and finish the sign-in on the device that asked for it.

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.

POST/v1/auth/:app_id/magic_links/loginNone

Sends a sign-in link to the email. A person with no account is created, unless sign-up is closed.

identifierstringrequired
The person's email address.
webauthn_enabledboolean
Passed to the link. Default false.
user_metaobject
Values for the app's user fields, keyed by field name.

The request's Origin header is stored with the link as the place to return to.

cURLbash
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"}'
Response 200json
{  "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.

Statuserror_codeWhen
400invalid_identifierMissing or invalid email.
403sign_in_method_disabledEmail sign-in or sign-in links are off for the app.
429More than 5 sends to the same identifier in a minute.

The sign-in refusals apply.

POST/v1/auth/:app_id/magic_links/registerNone

Same parameters, checks and response as Send a sign-in link. The audit event is magiclink.register.init instead of magiclink.login.init.

PATCH/v1/auth/:app_id/magic_links/authenticateNone

Exchanges 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.

tokenstringrequired
The sct_magic or sct_oauth value from the URL.
cURLbash
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:

Response 200json
{  "status": "completed",  "signed_in": false,  "challenge": {    "token": "ch_zN4kP2qX9wT5aB3xY9QkLm7RsT2uVw8E",    "status": "completed",    "purpose": "verify_identity",    "method": "magic_link"  }}
Statuserror_codeWhen
202Attack protection wants a code first. See Security verification.
403security_blockAttack protection refused the sign-in.
403sign_in_method_disabledEmail sign-in or sign-in links were turned off after the link was sent.
404magic_link_not_found_or_expiredUnknown, used, expired, or another app's token.

Poll for the sign-in on the asking device#

POST/v1/auth/:app_id/magic_links/statusNone

Lets 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.

idstringrequired
The magic_link.id from the send response.
cURLbash
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"}'
StatusBodyMeaning
200Token setThe 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.
202verification_requiredAttack 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.
409error_code sign_in_pendingThe device that opened the link is still finishing MFA or a contact step. Keep polling.
409error_code sign_in_step_startedThis 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#

POST/v1/auth/:app_id/magic_links/confirm_inviteNone

Signs in a person who was invited to the app, using the token from the invitation email.

tokenstringrequired
The invitation token from the link.
user_metaobject
Values for required user fields the person has not filled yet.
cURLbash
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.

Statuserror_codeWhen
404magic_link_not_found_or_expiredUnknown, used, or expired invitation.
422incomplete_user_infoRequired user fields are still missing. errors lists them.