# Confirm an email change

`POST /api/v1/auth/email-change`

Moves the account to the link's address. Signs nobody in; the old address gets a notice.

Sign-in: none.

Section: Sign-in and account. Operation id in openapi.json: `confirm_email_change`.

## Request body

Required: yes.

`application/json`: EmailChangeConfirmInput

| Field | Type | Required | Description |
|---|---|---|---|
| `token` | string | yes |  |

## Responses

Errors are `application/problem+json` (`Problem`); branch on `type`.

### 200

Moved.

`application/json`: EmailChanged

| Field | Type | Required | Description |
|---|---|---|---|
| `email` | string | yes | The account's address now; sign in with it. |

### 400

Bad Request.

- `request.malformed`: the body or a parameter is not of the expected shape
- `auth.credentials_conflict`: the request carries both a session cookie and a token

### 401

Unauthorized.

- `token.invalid`: the token is malformed, unknown, revoked or expired, or its creator left the workspace

### 403

Forbidden.

- `request.origin_mismatch`, `request.header_required`: a changing request with a session comes from another site or lacks `X-Monitorly-Request: 1`

### 404

Not Found.

- `email_change.not_found`: the email change link does not exist

### 409

Conflict.

- `email_change.address_taken`: another account took the new address after the request

### 410

Gone.

- `email_change.expired`: the link is older than 24 hours, or a newer request replaced it
- `email_change.used`: the link was already used

### 413

Payload Too Large.

- `request.too_large`: the body is larger than 256 KiB

### 422

Unprocessable Entity.

- `field.required`, `field.too_long`, `field.invalid`: a field breaks a rule; `errors` points at it

Schemas named above are listed with their fields in [the schema list](https://docs.monitorly.cloud/api/reference/schemas.md).
