# Dynamic Erasure Email integration

A _Dynamic Erasure Email integration_ allows Fides to send a weekly email containing the identities of all the data subjects that have submitted an erasure request in the past week. _Dynamic Erasure Emails_ can be used to notify multiple third-party vendors of their obligations to erase any personal data associated with the provided identities.

This integration is an abstraction of the [Generic Erasure Email integration](/content/docs/integrations/email-integrations/generic-erasure-emails/index.html), where instead of setting a static email address, you must specify a reference to a [dataset](/content/docs/integrations/guides/datasets/index.html) field that contains the email address. The email address will then be dynamically obtained at runtime from that dataset field, using any [custom request fields](/content/docs/privacy-requests/guides/custom-request-fields/index.html) provided in the privacy request as context for the email lookup.

## Prerequisites

### Configure an email provider

In order to setup a _Dynamic Erasure Email integration_, you'll first need to configure an email provider. See our guide for [configuring a message service](/content/docs/privacy-requests/guides/identity-verification#configure-a-messaging-service/index.html).

### Create a dataset with `custom_request_field` annotations

You'll need to have an existing dataset with a field that represents the email address of the third-party vendor, and another one that represents the vendor name. Additionally, the dataset needs to specify which fields will be provided as custom request fields in the erasure request in order to perform the email lookup.

Consider the following example in which we have a `vendors` table with the columns `email_address`, `vendor_name`, and `site_id`. The erasure requests will include a [custom request field](/content/docs/privacy-requests/guides/custom-request-fields/index.html) called `siteId` that we want to use to obtain the vendor email address. We then define our dataset as follows:

```
- fides_key: example_dynamic_erasure_email_dataset
  data_categories: []
  description: Example dataset for a Dynamic Erasure Email integration
  name: Example Dynamic Erasure Email Dataset
  collections:
    - name: vendors
      fields:
        - name: email_address
          data_categories: []
          fides_meta:
            data_type: string
        - name: vendor_name
          data_categories: []
          fides_meta:
            data_type: string
        - name: site_id
          data_categories: []
          fides_meta:
            data_type: string
            custom_request_field: siteId
```

Notice the `custom_request_field` attribute in the `fides_meta` section of the `site_id` column; it tells Fides that the vendor email address and name will need to be obtained using the `siteId` custom request field value as the lookup in the `site_id` column, generating a query of the form `SELECT email_address, vendor_name FROM vendors WHERE site_id = <siteId from privacy request>` to retrieve the vendor information.

In order for the _Dynamic Erasure Email_ integration to work, the provided custom request fields need to uniquely identify the email address when used in the lookup. In our example, this means that a given `siteId` needs to match one single row in our `vendors` table; otherwise erasure emails will fail to send.

### Connect the dataset to the corresponding integration

The dataset we define tells Fides how to _lookup_ the vendor email address and name, but we still need Fides to know how to _connect_ to the data source. You'll need to either create a new integration or edit an existing one and link it to the dataset with the Dataset dropdown. In our previous example, this could be setting up a [PostgreSQL](/content/docs/integrations/databases/postgresql/index.html) integration and selecting the `example_dynamic_erasure_email_dataset` in the Dataset dropdown in the integration.

Currently _Dynamic Erasure Email integrations_ only support dataset references that belong to a SQL integration (e.g [PostgreSQL](/content/docs/integrations/databases/postgresql/index.html), [MySQL](/content/docs/integrations/databases/mysql/index.html), etc.) or a [Snowflake integration](/content/docs/integrations/databases/snowflake/index.html).

## Setting up a Dynamic Erasure Email integration

To set up a _Dynamic Erasure Email integration_:

1. Navigate to **Data map** → **View Systems** and choose the system that you want to connect.
2. Click on the **Integrations** tab.
3. Pick the _Dynamic Erasure Email_ option from the **Connection type** drop-down menu.
4. Complete the required fields for the integration:
   - `Third Party Vendor Name Field`: The dataset field that contains the name of the third-party vendor. Should be a value of the form `dataset_key.collection_name.field_name`. The vendor name is used as part of the email body.
   - `Recipient Email Address Field`: The dataset field that contains the email address of the third-party vendor. Should be a value of the form `dataset_key.collection_name.field_name`.
5. Optionally complete the optional fields for the integration:
   - `Test Email Address`: An email address where you can send a test email when you click **Test integration**. Make sure this is an email address that you own.
6. Click **Save** to save your integration. If you've completed the optional `Test Email Address` field, you can click **Test integration** after saving in order to send a test email to the provided email address.
