# Request a sign-in link

Email a sign-in link to an account's confirmed alert address.

POST `/api/v1/sign-in`

**cURL**

```shell
curl -X POST 'https://www.prufy.dev/api/v1/sign-in' \
  -H 'content-type: application/json' \
  -d '{
  "email": "owner@yourcompany.com"
}'
```

**Node.js**

```javascript
const response = await fetch("https://www.prufy.dev/api/v1/sign-in", {
  method: "POST",
  headers: { "content-type": "application/json" },
  body: JSON.stringify({ email: "owner@yourcompany.com" }),
})
const data = await response.json()
```

**Python**

```python
import requests

response = requests.post(
    "https://www.prufy.dev/api/v1/sign-in",
    json={"email": "owner@yourcompany.com"},
)
data = response.json()
```

Response 200 OK

```json
{
  "requested": true
}
```

This is how a second device, or a browser that lost its cookie, gets back to an account. Only an address that an account has confirmed for alerts gets an email. An address confirmed on several accounts gets one email with a link for each, named by its domains.

The answer is the same `{ requested: true }` whether or not the address is on an account, and the email is sent after the response, so neither the body, the status nor the timing says who has one.

Each link works once, for 15 minutes, and opens a page with a button. Opening the link does nothing by itself, because mail scanners open every link.

A terminal adds `terminal`: the SHA-256 of a secret it keeps. The link then shows a code to type into that terminal (Redeem a sign-in code), and the browser that opens it isn't signed in.

## Authentication

No credential needed. [How sessions work](https://www.prufy.dev/docs/authentication.md).

## Body

JSON, with `content-type: application/json`.

- `email` email required

  The address that gets this account's alerts. Only a confirmed alert address works.

  - At most 254 characters
- `terminal` string optional

  For a terminal: the SHA-256, in hex, of a secret it keeps. The emailed link then shows a code to type into that terminal instead of signing in the browser.

## Response

`200 OK`, with every field below present. Times are ISO 8601 strings in UTC.

- `requested` true

  Always true, whether or not the address is on an account, so the answer can't be used to find out who has one.

## Errors

| Status | Kind | When |
| --- | --- | --- |
| 400 | `bad_request` | The body isn't JSON, or doesn't match the shape below. `message` names the first field to fix, and `fields` lists each one with its path. |
| 413 | `payload_too_large` | The body is over 16 KB. No route takes anything near that. |
| 429 | `rate_limited` | The address has been asked for 5 times in the last hour, or this network has asked 10 times. Counted the same for every address, known or not. |
| 503 | `email_unavailable` | This server has no email set up. |

Any route can also answer `500` with `internal_error`. Every error has the same shape, described in [Errors](https://www.prufy.dev/docs/errors.md).

---

Every page of these docs, as a list: https://www.prufy.dev/llms.txt
