# Unique Email (UniqueEmailGenerator)

The [Unique Email](https://docs.tonic.ai/app/generation/generators/generator-reference/unique-email) generator generates unique email addresses. It replaces the username with a randomly generated GUID, and either uses a specified domain or uses a character scramble to mask the domain.

## Link object structure <a href="#generator-api-unique-email-link-object" id="generator-api-unique-email-link-object"></a>

The Unique Email generator does not support linking. It can be self-consistent, but not consistent with another column. You cannot configure differential privacy.

The `metadata` object is populated from the [`EmailMetadata`](https://app.tonic.ai/apidocs/index.html#/models/EmailMetadata) object. You can configure:

* The domain to use for all of the email addresses in the destination database. If not specified, a character scramble is applied to the domains.
* Domains for which to keep the email addresses as is in the destination database.
* Whether to replace invalid email addresses with valid ones.

```json
{
  "schema": "string",
  "table": "string",
  "column": "string",
  "path": "string",  //JSON fields only
  "dataType": "string",  //MongoDB, Amazon DynamoDB, and JSON fields only
  "metadata": {
    "presetId": "string",
    "generatorId": "UniqueEmailGenerator",
    "domain": "string",
    "replaceInvalidEmails": boolean,
    "isConsistent": boolean,
    "encryptionProcessor": "x-on", //To use configured Structural data encryption
    "customValueProcessor": "string"  //If custom value processor applied
  }
}
```

## Example replacement <a href="#generator-api-unique-email-replacement" id="generator-api-unique-email-replacement"></a>

In the following example replacement for the Unique Email generator, consistency is enabled.

`tonic.ai` is used as the domain for all of the email addresses, and invalid email addresses are not replaced.

```json
{
  "name": "email",
  "schema": "public",
  "table": "users",
  "links": [
    {
      "schema": "public",
      "table": "users",
      "column": "email",
      "metadata": {
        "presetId": "UniqueEmailGenerator",
        "generatorId": "UniqueEmailGenerator",
        "domain": "tonic.ai",
        "replaceInvalidEmails": false,
        "isConsistent": true
      }
    }
  ]
}
```
