> ## Documentation Index
> Fetch the complete documentation index at: https://moengage-analytics-query-api-docs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Trigger Card Deletion Through Custom Connector Campaigns

# Introduction

As marketers, we sometimes need to delete cards to remove irrelevant or outdated promotional content that no longer serves its purpose. We should ideally remove the card when its expiry condition is met. However, there may be scenarios where you need to delete the card for a user before its expiry, such as:

* **User availing the benefit**: The user has already utilized the card benefits, making the card irrelevant.
* **User feedback**: If users consistently ignore or negatively react to a specific card, deleting it can improve campaign performance.
* **Cleaning up clutter**: Removing redundant or similar cards helps present a more streamlined experience for users, allowing us to deliver focused messaging.

#### Advantages of triggering card deletion

* **Improved user experience**: Automating *Card Deletion* based on specific trigger conditions helps improve the user experience and ensures the relevance of campaigns.
* **Relevant information**: Removing cards after a user has taken a specific action or when they are no longer eligible for a promotion ensures that the user interface remains clean and focused on relevant information.
* **Reduced resource consumption**: By removing outdated cards, you can optimize system performance and save resources.
* **Increased efficiency**: Automated card deletion streamlines campaign management and reduces manual effort.

We will achieve this use case by [creating a Custom Connector campaign](/use-cases/cards/trigger-card-deletion-through-custom-connector-campaigns#create-a-custom-connector-campaign) that automatically deletes cards based on predefined trigger conditions.

<Info>
  You can also remove the card for the specific user manually using the [Delete Cards API](/api/cards/delete-cards-for-user).
</Info>

# Expected Result

Cards will be deleted depending on the trigger conditions.

<Tip>
  * A Card campaign promoting a product must be published. In this example, the product ID is 8137850880291.
  * An event must be available in MoEngage to track the action of a user checking out products. In this example, we will use the event *Checkout Started*. To understand how to track events, refer to the [Developer Guide](/developer-guide/introduction).
  * An event must be available in MoEngage to track the Card campaigns. In this example, we will use the events *Card Campaign Sent* and *Card Campaign Dismissed*. To understand how to track events, refer to the [Developer Guide](/developer-guide/introduction).
  * The **Campaign ID** from the Card info page must be noted.
</Tip>

# Create a Custom Connector Campaign

In this section, we will create a Custom Connector campaign to delete a card automatically.

## Step 1: Target Users

1. On the left navigation menu in the MoEngage dashboard, click **Engage**, and then click **Campaigns**.
2. On the All campaigns page, click **+ Create campaign**.
3. Under **Connectors**, click **Custom** > **Event Triggered**. For more information, refer to [Event Triggered Campaigns](/user-guide/campaigns-and-channels/connectors/create/create-a-connector-campaign). <img src="https://mintcdn.com/moengage-analytics-query-api-docs/EDE9gun_JMtxSzaH/images/moengage_c9f626.png?fit=max&auto=format&n=EDE9gun_JMtxSzaH&q=85&s=4103b837b6a5474106ba7c188252f78f" alt="customconnect.png" width="700" height="1512" data-path="images/moengage_c9f626.png" /> You are taken to the first step, **Target users**, of defining your campaign.
4. Define your campaign with a name and tags. Enter the following details:
   * **Team**: Select a team if your organization has teams enabled for your account. For more information, refer to [Teams in MoEngage](/user-guide/settings/account/team-management/teams-in-moengage).
   * **Campaign name**: Enter a name for the campaign. For example, *Delete Card API Connector*.
   * **Campaign tags**: Select the required campaign tags. <img src="https://mintcdn.com/moengage-analytics-query-api-docs/QM8Jxj1UOgs1MH53/images/moengage_7436a7.png?fit=max&auto=format&n=QM8Jxj1UOgs1MH53&q=85&s=09a68523559872694e94c8b9cfeb01b0" alt="12usecase2.png" width="2748" height="518" data-path="images/moengage_7436a7.png" />
5. In the **Trigger criteria** section, define the trigger condition by performing the following steps:
   1. In the **IF user** section, select *Checkout Started*.
   2. Click **+ Attribute** and select *Product IDs* because they are unique attributes that can help you identify the card.
   3. Select the (any of) is operator because you want an exact match.
   4. In the **Select Option** list, select *8137850880291*. <img src="https://mintcdn.com/moengage-analytics-query-api-docs/G1Sh8cGNx6G2YQGb/images/moengage_34b6ea.png?s=2a97acd1e6243aef78f46375a432eded" alt="12usecase3.gif" width="1374" height="336" data-path="images/moengage_34b6ea.png" />
6. In the **Select audience** section, define the audience as users who have executed the *Card Campaign Sent* event at least once in the last 3 days with the noted *Campaign Id* as shown below: <img src="https://mintcdn.com/moengage-analytics-query-api-docs/G1Sh8cGNx6G2YQGb/images/moengage_333898.png?fit=max&auto=format&n=G1Sh8cGNx6G2YQGb&q=85&s=a670cdbb6958262e401cdb24d98efb42" alt="12usecase4.png" width="2722" height="550" data-path="images/moengage_333898.png" />
7. In the **Control groups** section, turn the **Global control group** toggle off. <img src="https://mintcdn.com/moengage-analytics-query-api-docs/YpRQXnMLuHTp9-Hn/images/moengage_416fe7.png?fit=max&auto=format&n=YpRQXnMLuHTp9-Hn&q=85&s=f074029f63acb66adaf6f2bdc8ab1b16" alt="12usecase5.png" width="2764" height="286" data-path="images/moengage_416fe7.png" />
8. Click **Next** to move to the second step, **Content**, where you can define the content for your custom connector campaign.

## Step 2: Content

1. In the **Method** section, select the **DELETE** option to configure the API request. <img src="https://mintcdn.com/moengage-analytics-query-api-docs/dKEqeh2ILfSrPmB2/images/moengage_29f84a.png?fit=max&auto=format&n=dKEqeh2ILfSrPmB2&q=85&s=bfb6c73344c2fd811341dd65d1cddb7e" alt="12usecase6.png" width="2742" height="502" data-path="images/moengage_29f84a.png" />
2. In the **Webhook URL** box, type your URL. For example, [**https://api-0X.moengage.com/v1/cards/delete**](https://api-0X.moengage.com/v1/cards/delete).
   <Info>
     Because each user is hosted on a different data center, refer to the [Data Centers in MoEngage](/user-guide/data/key-concepts/data-centers-in-moengage) article to find your data center number (value of **X**).
   </Info>
3. Under **Headers**, type key names and their values as shown in the following table:
   | Key                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          | Sample Values                                                    |
   | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------- |
   | Authorization                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | `{"Authorization": "Basic Base64_ENCODED_WORKSPACEID_APIKEY=="}` |
   | Content\_Type                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | `{"Content_Type": "application/json"}`                           |
   | <img src="https://mintcdn.com/moengage-analytics-query-api-docs/U3b_LbDL6ZrBKo8L/images/moengage_c093a9.png?fit=max&auto=format&n=U3b_LbDL6ZrBKo8L&q=85&s=81c0050b8798b45ea5c0b5e75bedac91" alt="12usecase7.png" width="2424" height="602" data-path="images/moengage_c093a9.png" /> |                                                                  |
   | For more information on the authentication key to be used in this request, refer to [Delete Cards API](/api/cards/delete-cards-for-user).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |                                                                  |
4. Select the **Body type** as **Raw**and then enter the JSON code in the input field as follows: JSON
   ```json wrap theme={null}
   {
   "uid": "{{UserAttribute['ID']}}",
   "campaign_ids": [
   "{{readable_campaign_id}}"
   ],
   "platforms": [
   "android","web","ios"
   ]
   }
   ```
   <img src="https://mintcdn.com/moengage-analytics-query-api-docs/U3b_LbDL6ZrBKo8L/images/moengage_c11a44.png?fit=max&auto=format&n=U3b_LbDL6ZrBKo8L&q=85&s=1d482ad347183d4b5d3924e7922efc8d" alt="12usecase8.png" width="1136" height="420" data-path="images/moengage_c11a44.png" />
   | Attribute     | Description                                                                                                                                                                                                                                                                                                                                   |
   | ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
   | uid           | Replace *ID* with the unique MoEngage Standard ID (Email ID Standard, Mobile Number Standard, or any unique identifier mapped to a MoEngage standard attribute) that identifies the user.  The Delete API will use this identifier to delete the card for the right user. You can add this value by personalizing it to the **ID** attribute. |
   | campaign\_ids | Replace *readable\_campaign\_id* with the previously noted *Campaign ID* of the card you wish to remove. For any additional configuration, refer to the [Delete Cards API](/api/cards/delete-cards-for-user) documentation.                                                                                                                   |
5. Click **Next** to move to the third step, **Schedule and goals**, where you can define your campaign's schedule and goals.

## Step 3: Schedule and Goals

1. In the **Send campaign** section, define when to start and end this campaign. <img src="https://mintcdn.com/moengage-analytics-query-api-docs/B1dP3oCRPo4NMx7b/images/moengage_fcbbff.png?fit=max&auto=format&n=B1dP3oCRPo4NMx7b&q=85&s=0dc11457c2b55d3258cbad122ecc485a" alt="12usecase10.png" width="2734" height="786" data-path="images/moengage_fcbbff.png" />
2. In the **Conversion goals** section, set the conversion goal as *Card Campaign Dismissed* with the attribute *Campaign ID* that you have identified before. <img src="https://mintcdn.com/moengage-analytics-query-api-docs/QM8Jxj1UOgs1MH53/images/moengage_74b2a8.png?fit=max&auto=format&n=QM8Jxj1UOgs1MH53&q=85&s=ded2425494f0473a6dae7ee38be142bf" alt="12usecase11.png" width="2736" height="488" data-path="images/moengage_74b2a8.png" />
3. In the **Delivery controls** section, define the settings based on your requirements.
4. Click **Publish**.

# Conclusion

In this use case, we created a Custom Connector campaign to delete a card automatically.

Now that we have created and published the card and its Delete Card API Connector campaign, the campaign will monitor users who meet the trigger condition and then request to delete the relevant card.

<Info>
  * If a card is available for a user and the delete API successfully deletes the card for them, you will see the status Card Campaign Dismissed in the user activity.
  * For periodic campaigns, using the parent ID in the **Campaign ID** field of the body will delete all the child campaigns.
  * It may take a few minutes for the delete request to be processed and the card changes to be reflected in the user's inbox.
</Info>
