You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update webhooks code samples to replace IPublishedSnapshotAccessor with IPublishedContentCache, IPublishedMediaCache, IPublishedMemberCache and IPublishedContentTypeCache dependencies.
Webhooks provide real-time, event-driven communication within Umbraco. They enable external services to react to content changes instantly by sending HTTP requests when specific events occur. This allows you to integrate with third-party services, automate workflows, and synchronize data effortlessly.
7
+
Webhooks provide real-time, event-driven communication within Umbraco. They enable external services to react to content changes instantly by sending HTTP requests when specific events occur. This allows developers to integrate with third-party services, automate workflows, and synchronize data effortlessly.
8
8
9
9
## Getting Started
10
-
11
10
To manage webhooks, navigate to **Settings > Webhooks** in the Umbraco backoffice.
@@ -17,13 +16,10 @@ To create a webhook, click **Create**. This opens the webhook creation screen wh
17
16

18
17
19
18
## Configuring a Webhook
20
-
21
19
### URL
22
-
23
20
The `Url` is the endpoint where the webhook will send an HTTP request when the selected event is triggered. Ensure this endpoint is publicly accessible and capable of handling incoming requests.
24
21
25
22
### Events
26
-
27
23
Webhooks are triggered by specific events in Umbraco. By default, the following events are available:
28
24
29
25
| Event Name | Description |
@@ -35,48 +31,69 @@ Webhooks are triggered by specific events in Umbraco. By default, the following
35
31
| Media Saved | Fires when a media item is saved. |
36
32
37
33
### Content Type Filtering
38
-
39
-
For **Content** or **Media** events, you can specify whether the webhook should trigger for all content types or only specific ones. This is useful when you only need webhooks for certain document types, such as blog posts or products.
34
+
For **Content** or **Media** events, developers can specify whether the webhook should trigger for all content types or only specific ones. This is useful when activating webhooks for certain document types, such as blog posts or products.
40
35
41
36
### Custom Headers
42
-
43
-
You can define custom HTTP headers that will be included in the webhook request. Common use cases include:
37
+
Developers can define custom HTTP headers that will be included in the webhook request. Common use cases include:
Umbraco webhooks come with predefined settings and behaviors.
52
45
53
46
### JSON Payload
47
+
Each webhook event sends a JSON payload. The following types of payloads are available by default.
54
48
55
-
Each webhook event sends a JSON payload. For example, the `Content Published` event includes full content details:
49
+
#### Legacy
50
+
This is the current default but will be removed in a future version. Legacy payloads follow the format used before version 16. They are inconsistent and may include data that should not be exposed or has been superseded (e.g., use of `int` instead of `Guid`).
56
51
57
-
```json
52
+
#### Minimal
53
+
This will become the default in version 17 and later. Minimal payloads include only essential information to identify the resource. For most events, this means a unique identifier. Some events may include additional data. For example, a document publish event also includes the list of published cultures.
54
+
55
+
#### Extended
56
+
Extended payloads include all relevant information for an event, where available. However, sensitive data, such as usernames, member names, or email addresses, is excluded for privacy and security reasons. If an extended payload is not available for an event, the system falls back to the minimal payload.
57
+
58
+
### Configuring Payload Types
59
+
Payload type can be configured in the following ways:
60
+
61
+
- Changing the appsetting `Umbraco:CMS:Webhook:PayloadType`. Be aware that the system that uses this value runs before any composers. If you manipulate the `WebhookEventCollectionBuilder` in any way, then those methods will not automatically pick up this app setting.
62
+
- Passing in the PayloadType into the `WebhookEventCollectionBuilderExtensions` methods to control which webhook events are added.
63
+
64
+
```csharp
65
+
usingUmbraco.Cms.Core.Composing;
66
+
usingUmbraco.Cms.Core.Webhooks;
67
+
68
+
namespaceUmbraco.Cms.Web.UI.Composers;
69
+
70
+
// this composer clears all registered webhooks and then adds all (umbraco provided) webhooks with their extended payloads
To replace the default Umbraco webhook with your custom implementation:
200
+
{% hint style="info" %}
201
+
Umbraco developers will need to inject `IPublishedContentCache`, `IPublishedMediaCache`, `IPublishedMemberCache` and `IPublishedContentTypeCache` dependencies individually, instead of injecting the `IPublishedSnapshotAccessor` as would have been done previously.
202
+
{% endhint %}
203
+
204
+
The code below shows an example that replaces the default Umbraco webhook with a custom implementation:
185
205
186
206
```csharp
187
207
publicclassMyComposer : IComposer
@@ -197,19 +217,24 @@ public class MyComposer : IComposer
197
217
198
218
Webhook settings are configured in `appsettings.*.json` under `Umbraco::CMS`:
199
219
220
+
{% code title="appsettings.json" %}
200
221
```json
201
-
"Umbraco": {
202
-
"CMS": {
203
-
"Webhook": {
204
-
"Enabled": true,
205
-
"MaximumRetries": 5,
206
-
"Period": "00:00:10",
207
-
"EnableLoggingCleanup": true,
208
-
"KeepLogsForDays": 30
222
+
{
223
+
"$schema": "appsettings-schema.json",
224
+
"Umbraco": {
225
+
"CMS": {
226
+
"Webhook": {
227
+
"Enabled": true,
228
+
"MaximumRetries": 5,
229
+
"Period": "00:00:10",
230
+
"EnableLoggingCleanup": true,
231
+
"KeepLogsForDays": 30
232
+
}
233
+
}
209
234
}
210
-
}
211
235
}
212
236
```
237
+
{% endcode %}
213
238
214
239
| Setting | Description |
215
240
|---------|-------------|
@@ -221,4 +246,4 @@ Webhook settings are configured in `appsettings.*.json` under `Umbraco::CMS`:
221
246
222
247
## Testing Webhooks
223
248
224
-
Use [Beeceptor](https://beeceptor.com/) or [RequestBin](https://pipedream.com/requestbin) to test your event trigger integrations before deploying them to production.
249
+
Use [Beeceptor](https://beeceptor.com/) or [RequestBin](https://pipedream.com/requestbin) to test the event trigger integrations before deploying them to production.
Copy file name to clipboardExpand all lines: 15/umbraco-cms/reference/webhooks/expanding-webhook-events.md
+20-22Lines changed: 20 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,22 +1,21 @@
1
1
---
2
2
description: >-
3
-
Explore new webhook event options, detailed setup, specific content triggers,
4
-
and improved logging and retry mechanisms
3
+
Explore new webhook event options, detailed setup, specific content triggers, and improved logging and retry mechanisms.
5
4
---
6
5
7
6
# Expanding Webhook Events
8
7
9
8
## Introduction
10
9
11
-
With Umbraco, you can create your own webhook events.
10
+
Umbraco developers can create their own webhook events.
12
11
13
-
This documentation guides you through the process of implementing your webhook events using the `WebhookEventBase<TNotification>` base class.
12
+
This article demonstrates the process of implementing custom webhook events using the `WebhookEventBase<TNotification>` base class.
14
13
15
14
## Creating an Event with the WebhookEventBase
16
15
17
16
The `WebhookEventBase<TNotification>` class serves as the foundation for creating custom webhook events. Here's a brief overview of its key components:
18
17
19
-
***Alias**: The property that must be overridden to provide a unique identifier for your webhook event.
18
+
***Alias**: The property that must be overridden to provide a unique identifier for the webhook event.
20
19
***EventName**: A property that represents the name of the event. It is automatically set based on the provided alias unless explicitly specified.
21
20
***EventType**: A property that categorizes the event type. It defaults to "Others" but can be customized using the `WebhookEventAttribute`.
22
21
***WebhookSettings**: The property containing the current webhook settings.
@@ -38,14 +37,14 @@ To create a custom webhook event, follow these steps:
38
37
```
39
38
2. **OverridetheAliasProperty**:
40
39
41
-
Provideauniqueidentifierforyour event using the `Alias` property:
40
+
Provideauniqueidentifierforthe event using the `Alias` property:
42
41
43
42
```csharp
44
43
public override string Alias => "YourUniqueAlias";
@@ -74,11 +74,11 @@ To create a custom webhook event, follow these steps:
74
74
}
75
75
}
76
76
```
77
-
6. **ImplementOptionalOverrides**:Dependingonyourrequirements, youcanoverridemethodssuchas `ConvertNotificationToRequestPayload` and `ShouldFireWebhookForNotification` tocustomizethebehaviorofyourwebhookevent.
77
+
6. **ImplementOptionalOverrides**:Dependingonrequirements, methodssuchas `ConvertNotificationToRequestPayload` and `ShouldFireWebhookForNotification` canbeoverriddentocustomizethebehaviorofthewebhookevent.
78
78
79
79
### Sample Implementation
80
80
81
-
Here's a basic example of a custom webhook event:
81
+
Thecodebelowshowsasampleimplementationofacustomwebhookevent. The `YourCustomEvent` classis derived from the `WebhookEventBase<YourNotificationType>` class, and it overrides the `Alias` property to provide a unique identifier for the event. The `WebhookEventAttribute` is applied to the class to specify the event name and type.
@@ -111,7 +111,7 @@ public class YourCustomEvent : WebhookEventBase<YourNotificationType>
111
111
112
112
## Creating an Event with the WebhookEventContentBase\<TNotification, TEntity>
113
113
114
-
For scenarios where your webhook event is content-specific, Umbraco provides another base class: `WebhookEventContentBase<TNotification, TEntity>`. This class is an extension of the generic `WebhookEventBase<TNotification>` and introduces content-related functionalities.
114
+
For scenarios where the webhook event is content-specific, Umbraco provides another base class: `WebhookEventContentBase<TNotification, TEntity>`. This class is an extension of the generic `WebhookEventBase<TNotification>` and introduces content-related functionalities.
115
115
116
116
The `WebhookEventContentBase<TNotification, TEntity>` class is designed for content-specific webhook events, where `TEntity` is expected to be a type that implements the `IContentBase` interface.
117
117
@@ -131,23 +131,21 @@ To leverage the `WebhookEventContentBase<TNotification, TEntity>` class, follow
0 commit comments