hubspotmake.com

HubSpot API — Automatically bulk delete tasks/contacts/deals (or anything) using Make


I would like to automatically bulk delete all tasks older than a month in HubSpot (we have more than 10,000 tasks!), instead of doing it one by one. I tried looking on the internet but it doesn’t seem that HubSpot has any functionalities like it. Thus, I tried to implement such scenario using Make (formerly Integromat) unsuccessfully.


Solution

  • Answering to my question for knowledge purposes.

    I managed to create a scenario allowing me to automatically bulk delete tasks (or anything) based on a certain set of criteria using Make (formerly Integromat). I had to use HubSpot’s API and Flow Control tools to achieve such result.

    The scenario looks like the following: Automatically bulk delete all tasks in HubSpot using a Make scenario overview

    Module 1: API Call

    Search for all tasks based on a certain set of criteria (here, all tasks created before the last 30 days).

    If you wish to search for another object (such as contacts or deals), you can take a look at the CRM Search API for all available search requests. You can also browse through the Properties API to get a comprehensive list of available properties.

        {
          "limit": "5",
          "properties": [
            "hs_task_subject",
            "hs_task_type",
            "hs_timestamp"
          ],
          "filterGroups": [
            {
              "filters": [
                {
                  "propertyName": "hs_task_status",
                  "operator": "EQ",
                  "value": "NOT_STARTED"
                },
                {
                  "propertyName": "hs_createdate",
                  "operator": "LT",
                  "value": "{{formatDate(addDays(now; -30); "x")}}"
                }
              ]
            }
          ]
        }
    

    Module 2: Repeater

    You can find out more about properties and search limitations here and here. Basically, the repeater allows you to loop over all HubSpot pages.

    Module 3: Sleep

    Sleep module to prevent RateLimitError

    Module 4: API Call

    Same as Module 1, except that you must add an after parameter to include the repeater’s value.

    +    "after": "{{module2.i}}"
    

    Module 5: Iterator

    Iterate over Module 4’s results array: {{module4.body.results}}.

    Module 6: API Call

    Delete tasks using the ID returned by the iterator.

    {
       "inputs":[
          {
             "id":"{{module5.id}}"
          }
       ]
    }
    

    Voilà !