# Unsubscribe from alert emails

Stop alert emails using the token from any alert's footer.

POST `/api/v1/notifications/email/unsubscribe`

**cURL**

```shell
curl -X POST 'https://www.prufy.dev/api/v1/notifications/email/unsubscribe?token=9l2mJmZ1hKq0c3o1b8yJ4n0Hk3z7d5WcXv2pQe8sT1A'
```

**Node.js**

```javascript
const response = await fetch("https://www.prufy.dev/api/v1/notifications/email/unsubscribe?token=9l2mJmZ1hKq0c3o1b8yJ4n0Hk3z7d5WcXv2pQe8sT1A", {
  method: "POST",
})
const data = await response.json()
```

**Python**

```python
import requests

response = requests.post("https://www.prufy.dev/api/v1/notifications/email/unsubscribe?token=9l2mJmZ1hKq0c3o1b8yJ4n0Hk3z7d5WcXv2pQe8sT1A")
data = response.json()
```

Response 200 OK

```json
{
  "unsubscribed": true
}
```

Mail apps call this when someone presses their own Unsubscribe button, which is why the token is in the query string and not the body.

It answers 200 either way, so pressing twice isn't an error. `unsubscribed` is false when the token is missing or not one of ours.

## Authentication

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

## Query parameters

`token` string required

The token from the unsubscribe link in an alert email.

## Response

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

- `unsubscribed` boolean

  True when the token matched an address.

## Errors

Nothing specific to this route.

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
