# `account.setEmail`

<span class="badge">bearer</span>

**Change the caller's email address**

Verifies the current password and updates the email. No confirmation email is sent. JWT session only.

## Parameters

Passed by name in the `params` object.

| Name | Type | Required | Description |
|---|---|---|---|
| `current_password` | string | yes | The caller's current password (re-authentication) |
| `email` | string | yes | The new email address |

## Result

Returns `userResult`:

| Field | Type | Description |
|---|---|---|
| `user *` | `userDTO` |  |

## Errors

| Code | Message | When |
|---|---|---|
| `2002` | `validation_failed` | Malformed request; see error.data. |

See the [error reference](/docs/errors) for the full catalog, including the authentication codes.

## Example

Request:

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "account.setEmail",
  "params": {
    "current_password": "correct-horse-battery-staple",
    "email": "ada@analyticalengine.example"
  }
}
```

Response:

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "user": {
      "id": "018f3a5c-1c7a-7e3b-9c2a-3f4b5a6c7d8e",
      "email": "ada@analyticalengine.example",
      "is_admin": false
    }
  }
}
```

**curl**

```bash
curl -s https://peinture.gumeniuk.com/rpc \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":1,"method":"account.setEmail","params":{"current_password":"correct-horse-battery-staple","email":"ada@analyticalengine.example"}}'
```

**JavaScript**

```js
const res = await fetch("https://peinture.gumeniuk.com/rpc", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": `Bearer ${token}`,
  },
  body: JSON.stringify({
    jsonrpc: "2.0", id: 1, method: "account.setEmail", params: {"current_password":"correct-horse-battery-staple","email":"ada@analyticalengine.example"},
  }),
});
const { result, error } = await res.json();
```

**Go**

```go
body := []byte(`{"jsonrpc":"2.0","id":1,"method":"account.setEmail","params":{"current_password":"correct-horse-battery-staple","email":"ada@analyticalengine.example"}}`)
req, _ := http.NewRequest("POST", "https://peinture.gumeniuk.com/rpc", bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer "+token)
resp, err := http.DefaultClient.Do(req)
```

