Skip to content
API documentation
View as MarkdownOpen in Claude

Sign-in links

Create a single-use sign-in link for one of your students

POST
/v1/{organizationId}/auth/signin

Returns a URL that signs the student in to this organization’s student panel. It works once, and for 120 seconds (expiresIn) from when it is issued, whether or not anyone opened it. Whoever opens it first is signed in as the student, and a second visit is refused, so:

  • redirect the student’s browser to it straight away;
  • never log it, email it or show it anywhere else;
  • ask for a new link for every sign-in.

Each call issues a new link and leaves the earlier ones as they were until they expire. Nothing is issued to your account: no token, cookie or session, only the URL.

The student needs access to this organization first: their activatedPlatformsThisSeason must hold this organization’s slug or common. registerStudent gives common unless you send a list; otherwise grant access with updateOrgStudent. Without it the answer is 403 with a message saying so, and nothing is changed.

The student does not need a confirmed email address: a student you have just registered can be sent a link straight away.

redirect chooses where on the panel the student lands. Leave it out to land on the organization’s defaultRedirect, as getOrganization shows it.

Make this the first call for a student new to this organization. The organization creates its own record of a student the first time they open a link to it, and linkStudentSupervisor and the application, certificate and report operations on this organization need that record.

Only students your account registered can be signed in; another account’s student answers 404, like an unknown id.

Parameters

Path parameters

NameTypeDescription
organizationIdrequiredstringpattern ^[0-9a-f]{24}$

The organization’s _id: 24 hexadecimal digits, as listOrganizations (GET /v1/organization) lists it.

Example 64b7f0c2a1d3e4f5a6b7c8d9

Request body

application/jsonrequired

  • studentIdstringrequired

    The id (_id) of the student to sign in, as registerStudent returned it. It must be one of your students.

    example6650a1b2c3d4e5f6a7b8c9d0

  • redirectstring

    Where the student lands once signed in: a path on the organization’s panel, starting with a single /, with no whitespace and no backslash anywhere. Full URLs, //host and /\host are refused, so a link can never send anyone off the panel. {userId} in the path is replaced with the student’s id on that organization. Leave it out to land on the organization’s defaultRedirect.

    example/dashboard

Responses

200 OK

Success: message is "Sign-in link generated successfully.".

Body

  • successbooleanrequired

    Always true on a success.

    one oftrue

  • messagestringrequired

    exampleSign-in link generated successfully.

  • dataobject · SigninLinkResponserequired

    A link that signs one of your students in to an organization. It works once, within 120 seconds.

    4 fields of data
    • urlstringrequired

      Send the student’s browser here to sign them in. It works once, and only within expiresIn seconds; after either, it answers that the access token is invalid or expired, and you make a new link. Treat it as a secret while it lives, and as opaque: do not build, parse or change it.

      formaturi

    • organizationstringrequired

      The slug of the organization the student lands in.

      examplestem

    • studentIdstringrequired

      The id of the student the link signs in.

      example6650a1b2c3d4e5f6a7b8c9d0

    • expiresInintegerrequired

      Seconds the link stays usable from now: always 120.

      example120

Headers

X-RateLimit-Limit integer

Requests your account may make to this operation per window (100).

X-RateLimit-Remaining integer

Requests left in the current window.

X-RateLimit-Reset integer

Seconds until the current window ends.

Example

{
  "success": true,
  "message": "Sign-in link generated successfully.",
  "data": {
    "url": "https://auth.main-team.org/api/user/oauth/invoke?accessToken=exampletokenexampletokenexampletoken&redirectUrl=%2Fdashboard",
    "organization": "stem",
    "studentId": "6650a1b2c3d4e5f6a7b8c9d0",
    "expiresIn": 120
  }
}

Example request

# $TOKEN: a short-lived token you minted with your API key and secret
curl -sS -X POST 'https://api.main-team.org/v1/<organizationId>/auth/signin' \
  -H "Authorization: Bearer $TOKEN" \
  -H 'Content-Type: application/json' \
  --data-binary @- <<'JSON'
{
  "studentId": "6650a1b2c3d4e5f6a7b8c9d0",
  "redirect": "/dashboard"
}
JSON

Search the API documentation

Guides, endpoints by name, path or permission, and error codes such as not_found.