---
title: "Walkthrough: Customizing contact purge conditions"
slug: "walkthrough--customizing-contact-purge-conditions"
abstract: "Walkthrough to extend the purge tool with custom filters of contact data."
---
# Walkthrough: Customizing contact purge conditions

You can extend the purging tool with custom conditions to further filter contact data extraction before purging. This option is useful to refine the selection of contact data to purge for more specific use cases.

This walkthrough describes how to:

- Implement the `ICondition` interface
- Register the custom condition

<details>
<summary><h2>Implement the ICondition interface</h2></summary>

To create a custom condition:

- Implement the `Sitecore.XConnect.DataTools.Abstractions.Conditions.ICondition` interface with a unique `ConditionId`.

    > [!note]
    > The `ConditionId` is a string you set that uniquely identifies it in the system. You must pass the `ConditionId` in the `Conditions` POST parameter during [task registration](https://doc.sitecore.com/xp/en/developers/101/sitecore-experience-platform/register-a-purge-contacts-api-task.html "Register a purge contacts API task").

    For example:

    ```csharp
    public interface ICondition
    {
        bool IsAccepted(Contact contact);
        string ConditionId { get; }
    }

    public class AnonymousCondition : ICondition
    {
        public bool IsAccepted(Contact contact)
        {
            return !contact.IsKnown;
        }

        public string ConditionId { get; } = "AnonymousCondition";
    }
    ```

> [!note]
> The conditions are limited to filter by contact data and contact identifiers. You cannot create a condition based on the contact facet or interaction data in Sitecore 10.1.

</details>

<details>
<summary><h2>Register the custom condition</h2></summary>

You must register the condition in the Cortex Processing Engine instance.

To register the condition:

1. Open the configuration file `/App_Data/Config/Sitecore/Processing/sc.XConnect.DataTools.Conditions.xml`.
2. Under the `<Settings>/<Sitecore>/<Processing>/<Services>` tag, register the new condition.

    For example:

    ```xml
    <Settings>
      <Sitecore>
        <Processing>
          <Services>
            <Condition.AnonymousCondition>
              <Type>Sitecore.XConnect.DataTools.Conditions.AnonymousCondition,Sitecore.XConnect.DataTools.Conditions</Type>
              <As>Sitecore.XConnect.DataTools.Abstractions.Conditions.ICondition,Sitecore.XConnect.DataTools.Abstractions</As>
              <LifeTime>Singleton</LifeTime>
            </Condition.AnonymousCondition>
          </Services>
        </Processing>
      </Sitecore>
    </Settings>
    ```

> [!note]
> You cannot get a list of all the registered conditions. After you extend processing with a custom condition, you must make a note of the `ConditionId`.

</details>