---
title: "Adding a custom Webhook Type to Umbraco V13 — Hack Make Do"
description: "Add your own webhook type to Umbraco 13, so any Umbraco notification can fire a webhook, not just the events supported out of the box."
url: https://hackmakedo.com/blog/adding-a-custom-webhook-type-to-umbraco-v13/
---

# Adding a custom Webhook Type to Umbraco V13

1 November 2023

- [Tutorials](https://hackmakedo.com/blog/topic/tutorials/)
- [Umbraco](https://hackmakedo.com/blog/topic/umbraco/)

With the [Umbraco V13 RC1 out today](https://umbraco.com/blog/umbraco-13-release-candidate/), I wanted to do a bit of playing and hacking around with the new features. One new feature I am excited about is Webhooks.

Out of the box Umbraco V13-rc1 supports:

- Content Publish
- Content Unpublish
- Content Delete
- Media Save
- Media Delete

With the lovely DTeam working on this feature they have made it possible to extend which Umbraco Notifications (aka events) can fire off a Webhook. So let’s jump on in and take a look at the code.

## Just show me the code

```csharp
using Microsoft.Extensions.Options;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Notifications;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Sync;
using Umbraco.Cms.Core.Webhooks;

namespace UmbracoV13Playground.MyCustomWebhooks;

public class MemberDeletedWebhookEvent : WebhookEventBase<MemberDeletedNotification, IMember>
{
    public MemberDeletedWebhookEvent(
        IWebhookFiringService webhookFiringService, 
        IWebHookService webHookService, 
        IOptionsMonitor<WebhookSettings> webhookSettings, 
        IServerRoleAccessor serverRoleAccessor) 
        : base(
            webhookFiringService, 
            webHookService, 
            webhookSettings, 
            serverRoleAccessor, 
            "MemberDeleted")
    {
    }

    protected override IEnumerable<IMember> GetEntitiesFromNotification(MemberDeletedNotification notification) => notification.DeletedEntities;

    protected override object? ConvertEntityToRequestPayload(IMember entity)
    {
        // Return everything
        return entity;

        // But we could decide on the shape of the data we send to the Webhook URL
        // return new
        // {
        //     Id = entity.Key,
        //     Name = entity.Name,
        //     Email = entity.Email,
        //     Username = entity.Username,
        //     MemberType = entity.ContentType.Alias
        // };
    }
}
```

Now we have this class that inherits from **WebhookEventBase\<TNotification, TEntity>** we are able to hook into anytime a Member is deleted and the notification (event) is raised from anywhere in the Umbraco site/application.

The next part we need to do is add it into the **WebhookEvents** collection using a simple IComposer like so

```csharp
using Umbraco.Cms.Core.Composing;
namespace UmbracoV13Playground.MyCustomWebhooks;

public class AddMoreWebHooksComposer : IComposer
{
    public void Compose(IUmbracoBuilder builder)
    {
        builder.WebhookEvents().Append<MemberDeletedWebhookEvent>();
    }
}
```

## Tada! It’s that simple

As you can see in the Umbraco backoffice I have a new event I can be notified and send out to a Webhook URL.

![](https://hackmakedo.com/images/blog/adding-a-custom-webhook-type-to-umbraco-v13/image-1.png)

A screenshot of Umbraco v13 with our new custom Webhook Event

![](https://hackmakedo.com/images/blog/adding-a-custom-webhook-type-to-umbraco-v13/image.png)

webhooks.site showing us the payload of the deleted member

## Notes

This is code running against Umbraco V13-rc1 and this could change and I have run into a [bug with using Webhooks](https://github.com/umbraco/Umbraco-CMS/issues/15092) and made a [suggestion on making the WebhookEventBase class a bit more flexible](https://github.com/umbraco/Umbraco-CMS/issues/15093) to work with a more broader range of notifications and hopefully including custom ones.

## Update

A BIG thanks to Kevin Jump aka Mr uSync as he has spent a bit more time and has got a prototype working with uSync and even got some code working for recieving a Webhook from another Umbraco instance that is sending out Webhooks. Kudos Kevin.

If your curious to see how he has done it then take a look at these files in the GitHub repo\
<https://github.com/Jumoo/uSync.Webhooks/blob/master/uSync.Webhooks/Webhooks/uSyncExportCompletedWebhook.cs>

<https://github.com/Jumoo/uSync.Webhooks/blob/dev/webhooks/uSync.Webhooks/WebhookEvents/uSyncItemWebhookEventBase.cs>

## Keep reading

7 September 2021

### [How to run .NETCore Umbraco CMS on a MacBook](https://hackmakedo.com/blog/how-to-run-netcore-umbraco-cms-on-a-macbook/)

Run Umbraco 9, the .NET Core edition, natively on your Mac: install the .NET SDK and the Umbraco templates, and stop running Windows in a virtual machine.

[Umbraco](https://hackmakedo.com/blog/topic/umbraco/) · [Tutorials](https://hackmakedo.com/blog/topic/tutorials/)

15 June 2018

### [Umbraco V8 - Bye bye ApplicationEventHandler, Hello Umbraco Components!](https://hackmakedo.com/blog/umbraco-v8-bye-bye-applicationeventhandler-hello-umbraco-components/)

Umbraco 8 replaces ApplicationEventHandler with components: the same event handler written both ways, why it changed and what the new approach gives you.

[Tutorials](https://hackmakedo.com/blog/topic/tutorials/) · [Umbraco](https://hackmakedo.com/blog/topic/umbraco/)

Need a hand with Umbraco Bellissima? I'm available as a freelancer or contractor.

[Get in touch](https://hackmakedo.com/contact/)
