# End user notices

> Email your customer their DNS records and reconnect requests.

Source: https://docs.customdomain.ai/docs/connect-flow/end-user-notices

When a connected domain is [moved](/docs/connect-flow/routing#changing-where-domains-point),
the person who connected it may have to replace its DNS records. CustomDomain™
can email them the new records on your behalf, once it knows their address.

## Give us the address

### From your server

* **On the widget token:** `end_user_email` in the `POST /v1/tokens` body. It
  is never put in the token. It is kept on our side, and a connection created
  with the token takes it.
* **On the connection:** `end_user_email` in the
  [`POST /v1/connections`](/docs/connect-flow/create-a-connection) body. It wins
  over the token's.
* **Later:** `PUT /v1/connections/{id}/end-user-email` with an API key replaces
  any earlier address.

Only an API key replaces an address the connection already has. A widget token's
create keeps the stored one (as the `PUT` answers it, `409`), and a delegated
agent token that sends a non-empty `end_user_email` is refused with `403`: the
reconnect email below goes to this address and carries a link that signs in as the
end user, so an agent never sets it.

### From the widget

When your server gives no address, the widget can ask for one. The create
response carries `ask_end_user_email: true` when the feature is on, the caller
is a widget token, the domain is not a test domain and the connection has no
address yet. The widget then shows one optional field, **Get DNS updates by
email**, and sends the answer with `PUT /v1/connections/{id}/end-user-email`.
The end user can skip it.

* A widget token can set an address only while the connection has none:
  otherwise the answer is `409`, so a browser never overwrites what your server
  gave.
* A widget token bound to another end user than the connection's (`end_user_ref`)
  sets none: the `PUT` answers `403`, the create stores neither this address nor
  one given when the token was minted, and the create does not ask for one.
* Turn the field off with the widget option `askEndUserEmail: false`
  (customdomain-js 0.5.9 or later passes it to the widget).
* An application whose email sender is **Don't send** (`none`) is never asked:
  it tells its end users itself, so the widget does not collect an address.

## What the end user gets

One email per Move, titled "Update the DNS records for" the domain. It names
your application, says CustomDomain™ writes on its behalf, and lists the full
record set the domain needs now. It has no button, no console link and no
account wording, because the reader has no account with us.

* At most 3 per connection in 30 days.
* A Move that rewrites the records itself through a connected provider account
  sends nothing. The end user is emailed only if that rewrite fails.
* Every Move that needs new records from the customer also sends the
  `connection.records_outdated` webhook and an email to your owners and admins,
  whether or not there is an address.

## Reconnect emails

When a [secure sign-in](/docs/guides/secure-sign-in#lasting-api-keys) made a
lasting API key at the domain's DNS provider, the same address gets a short email
when that key needs the end user: 30 and 7 days before it ends, when it ends, and
when the provider stops accepting it. It is titled "Reconnect Hostinger for
acme.com" (the provider and the domain), names your application, says in one
sentence what happened to the key, and has one button, **Reconnect Hostinger**,
which opens a [reconnect link](/docs/guides/secure-sign-in#reconnect): one
sign-in, nothing about the domain's DNS changes. The link works once.

The same email goes out when you press **Send reconnect link** in the console, or
call `POST /v1/connections/{id}:reconnect-link` with `{"send": true}` and your API
key (a widget token or an agent token is refused with `403`). Reconnect
emails count toward the same 3 per connection in 30 days, and go through the
sender below; with no address, or the sender set to `none`, nothing is sent and
the `credential.*` webhooks are yours to act on.

## Who sends it

Each application picks its sender, in the console under **End user email** on
the application's settings, or with `GET` and `PUT /v1/applications/{id}/email-sender`:

| `mode`    | What happens                                                                                                                                                                                 |
| --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `default` | The CustomDomain™ sender.                                                                                                                                                                    |
| `smtp`    | Your own mail server, with the From taken from `from_address` and `from_name`. TLS is always on, on port 25, 465, 587 or 2525. Check it with `POST /v1/applications/{id}/email-sender:test`. |
| `none`    | Nothing is sent. Use the `connection.records_outdated` webhook to tell the end user yourself.                                                                                                |

If your server fails at send time, that message goes through the default
sender instead and the error is kept in `last_error`.

## Where the address is kept

The address is stored only on the connection and never logged. It is shown
back only in the response of the call that created the connection with it, and
on `GET /v1/connections/{id}` with an API key: never in a list, a webhook, or a
read with a widget token.
