# Author a Masking Data Policy

{% hint style="info" %}
**Best practice: write global policies**

Build global policies with tags instead of writing local policies to manage data access. This practice will prevent you from having to write or rewrite single policies for every data source added to Immuta.
{% endhint %}

1. Determine your policy scope:
   * [**Global policy**](https://documentation.immuta.com/2024.3/secure-your-data/authoring-policies-in-secure/policies-explained): Click the **Policies page** icon in the left sidebar and select the **Data Policies** tab. Click **Add Policy** and enter a **name** for your policy.
   * [**Local policy**](https://documentation.immuta.com/2024.3/secure-your-data/authoring-policies-in-secure/policies-explained): Navigate to a specific data source and click the **Policies** tab. Scroll to the **Data Policies** section and click **Add Policy**.
2. Select **Mask** from the first dropdown menu.
3. Select **columns tagged**, **columns with any tag**, **columns with no tags**, **all columns**, or **columns with names spelled like**.
4. Select a masking type:
   * [**using hashing**](https://documentation.immuta.com/2024.3/secure-your-data/authoring-policies-in-secure/reference-guides/data-policies#hashing)
   * [**with reversibility**](https://documentation.immuta.com/2024.3/secure-your-data/authoring-policies-in-secure/reference-guides/data-policies#with-reversibility)
   * [**by making null**](https://documentation.immuta.com/2024.3/secure-your-data/authoring-policies-in-secure/reference-guides/data-policies#replace-with-null)
   * [**using a constant**](https://documentation.immuta.com/2024.3/secure-your-data/authoring-policies-in-secure/reference-guides/data-policies#replace-with-constant): Enter a **constant** in the field that appears next to the masking type dropdown.
   * [**using a regex**](https://documentation.immuta.com/2024.3/secure-your-data/authoring-policies-in-secure/reference-guides/data-policies#regular-expression-regex):
     1. Enter a **regular expression** and **replacement value** in the fields that appear next to the masking type dropdown.
     2. From the next dropdown, choose to make the regex **Case Insensitive** and/or **Global**. For this policy to be enforced on Redshift data sources, **Global** must be selected.
   * [**by rounding**](https://documentation.immuta.com/2024.3/secure-your-data/authoring-policies-in-secure/reference-guides/data-policies#rounding): Select the **Bucket Type** and then enter the **bucket size**.
   * [**with format preserving masking**](https://documentation.immuta.com/2024.3/secure-your-data/authoring-policies-in-secure/reference-guides/data-policies#with-format-preserving-masking)
   * [**with K-Anonymization**](https://documentation.immuta.com/2024.3/secure-your-data/authoring-policies-in-secure/reference-guides/data-policies#with-k-anonymization): Select either **using fingerprint** or **requiring group size of at least** and enter a **group size** in the subsequent dropdown menu.
   * [**using randomized response**](https://documentation.immuta.com/2024.3/secure-your-data/authoring-policies-in-secure/reference-guides/data-policies#using-randomized-response)
   * [**using the custom function**](https://documentation.immuta.com/2024.3/secure-your-data/authoring-policies-in-secure/reference-guides/data-policies#custom-function): Enter the custom function native to the underlying database.

     *Note: The function must be valid for the data type of the column. If it is not, the default masking type will be applied to the column.*
5. Select **everyone except**, **everyone**, or **everyone who** to continue the condition.
   * **everyone except**: In the subsequent dropdown menus, choose **is a member of group**, **possesses attribute**, or **is acting under purpose**. Complete the condition with the subsequent dropdown menus.
   * **for everyone who**: Complete the **Otherwise** clause. You can add more than one condition by selecting **+ Add Another Condition**. The dropdown menu in the policy builder contains conjunctions for your policy. If you select **or**, only one of your conditions must apply to a user for them to see the data. If you select **and**, all of the conditions must apply.
6. Opt to complete the **Enter Rationale for Policy (Optional)** field, and then click **Add**.
7. For global policies: Click the dropdown menu beneath **Where should this policy be applied** and select **When selected by data owners**, **On all data sources**, or **On data sources**. If you selected **On data sources**, finish the condition in one of the following ways:
   * **tagged**: Select this option and then search for **tags** in the subsequent dropdown menu.
   * **with columns tagged**: Select this option and then search for **tags** in the subsequent dropdown menu.
   * **with column names spelled like**: Select this option, and then enter a **regex** and choose a **modifier** in the subsequent fields.
   * **in server**: Select this option and then choose a **server** from the subsequent dropdown menu to apply the policy to data sources that share this connection string.
   * **created between**: Select this option and then choose a **start date** and an **end date** in the subsequent dropdown menus.
8. Click **Create Policy**. If creating a global policy, you then need to click **Activate Policy** or **Stage Policy**.

## Create a custom certification for a global policy

This step is optional, but data governors can add certifications that outline acknowledgements or [require approvals from data owners](https://documentation.immuta.com/2024.3/secure-your-data/authoring-policies-in-secure/data-policies/manage-policies-per-data-source#certify-global-policies). For example, data governors could add a custom certification that states that data owners must verify that tags have been added correctly to their data sources before certifying the policy.

1. Click **Add Certification** in the data policy builder.
2. Enter a **Certification Label** and **Certification Text** in the corresponding fields of the dialog that appears.
3. Click **Save**.
