# Confirm the alert email

Turn a confirmation token into a confirmed address.

POST `/api/v1/notifications/email/confirm`

**cURL**

```shell
curl -X POST 'https://www.prufy.dev/api/v1/notifications/email/confirm' \
  -H 'content-type: application/json' \
  -d '{
  "token": "Q0s8n1Jr6bTqM3uZxW5eYd2LkPvA7hGfC9oXiR4tNwE"
}'
```

**Node.js**

```javascript
const response = await fetch("https://www.prufy.dev/api/v1/notifications/email/confirm", {
  method: "POST",
  headers: { "content-type": "application/json" },
  body: JSON.stringify({ token: "Q0s8n1Jr6bTqM3uZxW5eYd2LkPvA7hGfC9oXiR4tNwE" }),
})
const data = await response.json()
```

**Python**

```python
import requests

response = requests.post(
    "https://www.prufy.dev/api/v1/notifications/email/confirm",
    json={"token": "Q0s8n1Jr6bTqM3uZxW5eYd2LkPvA7hGfC9oXiR4tNwE"},
)
data = response.json()
```

Response 200 OK

```json
{
  "confirmed": true
}
```

No session needed: the token is the credential, and the person confirming may be on a different device from the one that asked.

It's a POST from a button, so opening the emailed link can't confirm anything by itself. `confirmed` is false when the token is unknown, used or more than 24 hours old, and that's still a 200.

## Authentication

No cookie. The token in the request is the whole credential. [How sessions work](https://www.prufy.dev/docs/authentication.md).

## Body

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

- `token` string required

  The token from the confirmation link.

  - At most 200 characters

## Response

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

- `confirmed` boolean

  True when the token was good. It only works once.

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

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
