# Sign-in links

> POST /users/{id}/sign-in-links returns a URL on your team's own address that signs that learner in once and takes them to the page you choose. Links last 30 to 300 seconds (120 by default), work once, and are refused for administrators, accounts in other teams and anyone using two-factor authentication.

A sign-in link lets someone who is already signed in to **your** system move into Continuum Learn without a second password: your server asks the API for a link, and sends the person's browser to it.

It needs the `auth:sign_in_links` scope. Give that scope only to the key on the server that does the redirect.

## How it works

1. The person clicks "Go to my training" in your portal.
2. Your server calls `POST /users/{id}/sign-in-links` for their Continuum user id.
3. The API returns a `url` that works once and expires after a short time.
4. Your server redirects the browser to that `url` straight away.
5. Continuum signs the person in on your team's own address and takes them to `redirect_path`. If the browser was already signed in (as anyone, on any team), the link signs that person out first, including their remember-me cookie, then signs in the link's user on the link's team.

## Create a link

| Body field | Default | Description |
|---|---|---|
| `redirect_path` | Where the person would normally land after signing in | Where to go after signing in. A relative path starting with a single `/`, such as `/learn/course/food-safety-level-2`. Full URLs and other sites are refused (`422`). |
| `ttl_seconds` | `120` | How long the link stays valid, from 30 to 300 seconds. |

```bash
curl https://your-team.continuumlearn.com/api/v2/users/2/sign-in-links \
  -H "Authorization: Bearer $CONTINUUM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"redirect_path": "/learn/courses", "ttl_seconds": 60}'
```

```php
<?php
// In your portal, after your own sign-in check. $continuumUserId comes from GET /users?external_id=...
$res = $client->post("users/{$continuumUserId}/sign-in-links", [
    'json' => ['redirect_path' => '/learn/courses', 'ttl_seconds' => 60],
]);
$link = json_decode($res->getBody(), true)['data']['url'];

header('Location: '.$link, true, 302);
exit;
```

```js
// Express: GET /training, behind your own authentication
app.get('/training', async (req, res) => {
  const r = await fetch(`https://your-team.continuumlearn.com/api/v2/users/${req.user.continuumId}/sign-in-links`, {
    method: 'POST',
    headers: { Authorization: `Bearer ${process.env.CONTINUUM_API_KEY}`, 'Content-Type': 'application/json' },
    body: JSON.stringify({ redirect_path: '/learn/courses', ttl_seconds: 60 }),
  });
  if (!r.ok) return res.redirect('https://your-team.continuumlearn.com/login');
  const { data } = await r.json();
  res.redirect(302, data.url);
});
```

The response is `201`:

```json
{
  "data": {
    "url": "https://acme.continuumlearn.com/auth/link/Xf3k9QpL2mVb7RtY8wZc1HnJ4sDe6GaK0uOiPq5T",
    "expires_at": "2026-11-09T14:07:11+00:00"
  }
}
```

## Rules

- **Single use.** A link stops working the moment it is used.
- **Short-lived.** It expires after `ttl_seconds`. Create it at the moment you redirect, never in advance, and never email it.
- **Your team's address only.** The link only works on the team's own address it was created for.
- **Checked twice.** Whether the person may sign in is checked when the link is created and again when it is used, so a link stops working if, say, the person is deactivated or sets up two-factor authentication in the meantime.
- **Neutral failure.** An expired, used or otherwise invalid link shows the normal sign-in page with the message "This sign-in link is invalid or has expired.", without saying which, so a link can't be used to probe accounts. Opening links is limited to 30 a minute per visitor.
- **Treat the URL as a secret.** Whoever opens it first is signed in as that person. Don't log it, store it, or put it anywhere but a redirect.
- **Audited.** Every link created and every use is logged with the team, the API key and the user. The link itself is never logged.
- **Limited.** Each API key can create 60 links a minute, on top of the normal [rate limits](https://continuumlearn.com/developers/rate-limits). Over that, the API returns `429` with `Retry-After`.

## Who can't get a link

Sign-in links are for ordinary learners. The API returns `409` with `error.code` `user_protected` for:

- administrators, owners, billing contacts, authors and outreach administrators of the team, and platform staff;
- people who also belong to another Continuum team;
- people linked to a presenter profile;
- anyone who has set up two-factor authentication, because a link can't replace their second factor;
- everyone, on a team that requires single sign-on.

A user who has been [deactivated](https://continuumlearn.com/developers/users#deactivate-reactivate-and-remove) gets `409` `user_deactivated`.

These people sign in the normal way, or through your [single sign-on](https://continuumlearn.com/lms-single-sign-on).

## Frequently asked questions

### Is this single sign-on?

It does a similar job for one direction, your system into Continuum, without setting up SSO. If you already have an identity provider (Microsoft Entra ID, Google, Okta), Continuum's OpenID Connect single sign-on may suit you better: see [LMS single sign-on](https://continuumlearn.com/lms-single-sign-on).

### Can I use it in an email?

No. Links last five minutes at most and work once. For emails, link to the course page and let people sign in.

### What if someone forwards the URL?

If it has already been used or has expired, nothing happens. That is why links should be created only at the moment of the redirect and kept short.
