How to get notified of a project deletion?

I have a webhook configured for each project, and they are working fine for task adds/changes/deletes. But if I delete a project via the UI, I don’t receive any webhook.

I guess that makes logical sense - I suppose it can’t send a webhook for a project which no longer exists? - but then how can we know when a user deletes a project via the UI?

1 Like

Unfortunately you will need to keep the list of the hooked projects and compare them with the list of the projects that exist.

Thanks, @Diakoptis - that’s what I was afraid of, but good to get confirmation. Alas it seems there’s more to it than that, as it looks like that also means checking each task assigned to a detected-as-deleted project to see if the task needs to be deleted as well. More complicated but certainly do-able.

If the project deleted you will get delete notifications for all the tasks in that project I think.

When you delete a project for some reason the webhook is still active.

I was hoping that would be the case, but in my testing just now, I am not getting any webhooks firing when there are tasks in a project and I delete the project via the UI.

I will test it in this week and i will let you know.

Be careful if you delete the tasks that exist in a deleted project. If the task is multihomed just remove the specific membership.

That would be great, much appreciated. Would definitely like to know if you get task-deletion webhooks when you delete a project.

Got it, thanks. Also looks like the task should only be deleted if it’s unassigned to someone.

We would be interested in the future ability to have Admins have access to a list of projects and tasks that have been deleted in the organisation (and the ability to restore them). Or, even better, be able to lock down both tasks and projects and assign user with permissions to be able to delete.

1 Like

Apologies for bumping this old topic. It seems webhook events do not trigger when we delete a project. Although we did select this event.

Does anyone have a solution on how to keep track of deleted projects?

curl --request POST
–url https://app.asana.com/api/1.0/webhooks
–header ‘accept: application/json’
–header ‘authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MDM3MDY3NDIsInNjb3BlIjoiZGVmYXVsdCBpZGVudGl0eSIsInN1YiI6MTIwNTU5MjQzODk2ODkwNywicmVmcmVzaF90b2tlbiI6MTIwNjIzMzYwNDM3Mjc0NywidmVyc2lvbiI6MiwiYXBwIjoxMjA2MjIxNTMwNTc0NzI5LCJleHAiOjE3MDM3MTAzNDJ9.OO8JDgmZ02QY9QfBsdogdK8MHw8k0gWhcezhalrAAQ4’
–header ‘content-type: application/json’
–data ’
{
“data”: {
“resource”: “1206240523143205”,
“target”: “https://xxxxxxxxx-asana-webhook…fnc.fr-par.scw.cloud”,
“filters”: [
{
“resource_type”: “project”,
“action”: “deleted”
}
]
}
}

Hi @nocodeventure,

Try changing the action to “removed”, I think that will do it. Let us know!

1 Like

Thanks Phil,

We’ll have this tested first thing in the morning.

1 Like

Hi @Phil_Seeman

Unfortunately using removed also doesn’t trigger the webhook response.

We tried all of these filters. The webhooks for changed events is working just fine.

"filters": [
  {
    "action": "changed",
    "resource_type": "project"
  },
  {
    "resource_type": "project",
    "action": "removed"
  },
  {
    "resource_type": "project",
    "action": "deleted"
  }
]

Yeah, I just tested “removed” and indeed it didn’t work for me. And “deleted” has never worked as I indicated above.

@Jeff_Schneider @John_Baldo maybe you could check on this? It seems deleting a project doesn’t emit a webhook event?

1 Like

Hi @Phil_Seeman and @nocodeventure,

You should be able to see project deleted events if you establish a webhook at the domain/workspace level with the project deleted filter.

EX:

{
    "data": {
        "resource": "<WORKSPACE_GID>",
        "target": "<TARGET_URL>",
        "filters": [
            {
                "resource_type": "project",
                "action": "deleted"
            }
        ]
    }
}

@Phil_Seeman I think you are right about your assumption:
“I guess that makes logical sense - I suppose it can’t send a webhook for a project which no longer exists? - but then how can we know when a user deletes a project via the UI?”

I tried two things:

1: Established a webook at the project level and deleted that project

EX: This webhook essentially shows all events that happens in a project

{
    "data": {
        "resource": "<PROJECT_GID>",
        "target": "<TARGET_URL>"
    }
}

Result = no webhook deleted event for project → I think this makes sense from @Phil_Seeman’s reasoning

2: Establish a webhook at the domain/workspace level and use the filter to filter out for project deleted events. Then deleted a project in that domain/workspace.

EX:

{
    "data": {
        "resource": "<WORKSPACE_GID>",
        "target": "<TARGET_URL>",
        "filters": [
            {
                "resource_type": "project",
                "action": "deleted"
            }
        ]
    }
}

Result = webhook event for project being deleted

EX: sample event

[
  {
    "user": {
      "gid": "<USER_GID>",
      "resource_type": "user"
    },
    "created_at": "2024-01-03T16:00:24.970Z",
    "action": "deleted",
    "parent": null,
    "resource": {
      "gid": "<DELETED_PROJECT_GID>",
      "resource_type": "project"
    }
  }
]

@Phil_Seeman to further confirm your hypothesis I tried: Establishing a webhook at the task level and deleting the task resource that the webhook was created with.

EX:

{
    "data": {
        "resource": "<TASK_GID>",
        "target": "<TARGET_URL>"
    }
}

Result = same as #1 for project webhook. I did not get any task deleted events back about the task that the webhook was established under.

In conclusion, I think your hypothesis about “can’t send a webhook for a project which no longer exists” is right.

2 Likes

Thanks for these tests and results, @John_Vu.

Checking my code, I see that in fact I never tested the scenario of a workspace-level webhook and listening for “project deleted” webhooks within that. Glad to hear that works!