Skip to content

Commit 80608a1

Browse files
committed
Add information about webhook payload types
1 parent 9704b09 commit 80608a1

File tree

1 file changed

+36
-17
lines changed

1 file changed

+36
-17
lines changed

16/umbraco-cms/reference/webhooks/README.md

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -52,31 +52,50 @@ Umbraco webhooks come with predefined settings and behaviors.
5252

5353
### JSON Payload
5454

55-
Each webhook event sends a JSON payload. For example, the `Content Published` event includes full content details:
55+
Each webhook event sends a JSON payload. The following types of payloads are available by default
5656

57-
```json
57+
- Legacy: This is the current default but will be removed in a future version. It uses the payloads as they were before V16. These payloads are inconsistent and contain information that was never ment to be exposed or is superseded by newer types (int vs guid).
58+
- Minimal: This will be the default in v17+. This version of the payloads will only contain information to indentify the resource in question. For most resources this will be it's unique identifier. Some events might require more information. For example: the payload for the document publish event will also contain all cultures that were published at that point in time.
59+
- Extended: These are new payload types that are available for some but not all events that gives you all relevant information regarding the event. Some information, like user/member names and emails, are not part of the payloads for security/privacy concerns. In cases where an extended payload is not present for an event, the minimal will be used as fallback.
60+
61+
You can change which payload type is used by
62+
63+
- Changing the appsetting `Umbraco:CMS:Webhook:PayloadType`. Be aware that the system that uses this value is run before any composers. If you manipulate the `WebhookEventCollectionBuilder` in anyway then those methods will not automatically pick up this appsetting.
64+
- Passing in the PayloadType into the `WebhookEventCollectionBuilderExtensions` methods to control which webhook events are added
65+
66+
```csharp
67+
using Umbraco.Cms.Core.Composing;
68+
using Umbraco.Cms.Core.Webhooks;
69+
70+
namespace Umbraco.Cms.Web.UI.Composers;
71+
72+
// this composer clears all registered webhooks and then adds all (umbraco provided) webhooks with their extended payloads
73+
public class AllWebhookComposer : IComposer
5874
{
59-
"name": "Root",
60-
"createDate": "2023-12-11T12:02:38.9979314",
61-
"updateDate": "2023-12-11T12:02:38.9979314",
62-
"route": {
63-
"path": "/",
64-
"startItem": {
65-
"id": "c1922956-7855-4fa0-8f2c-7af149a92135",
66-
"path": "root"
75+
public void Compose(IUmbracoBuilder builder)
76+
{
77+
builder.WebhookEvents().Clear().AddCms(onlyDefault: false, payloadType: WebhookPayloadType.Extended);
6778
}
68-
},
69-
"id": "c1922956-7855-4fa0-8f2c-7af149a92135",
70-
"contentType": "root",
71-
"properties": {}
7279
}
80+
7381
```
7482

75-
The `Content Deleted` event sends only the content ID:
83+
- Manually manipulating the `WebhookEventCollectionBuilder`
7684

77-
```json
85+
```csharp
86+
using Umbraco.Cms.Core.Composing;
87+
using Umbraco.Cms.Core.Webhooks.Events;
88+
89+
namespace Umbraco.Cms.Web.UI.Composers;
90+
91+
// since legacy is the default, this composer removes the old content published webhookevent and changes it with the new extended version.
92+
public class AllWebhookComposer : IComposer
7893
{
79-
"id": "c1922956-7855-4fa0-8f2c-7af149a92135"
94+
public void Compose(IUmbracoBuilder builder)
95+
{
96+
builder.WebhookEvents().Remove<LegacyContentPublishedWebhookEvent>();
97+
builder.WebhookEvents().Add<ExtendedContentPublishedWebhookEvent>();
98+
}
8099
}
81100
```
82101

0 commit comments

Comments
 (0)