Skip to content

Commit 98e6648

Browse files
authored
Merge pull request #7247 from umbraco/update/v16/webhook-payloads
Add information about webhook payload types
2 parents a7d5ae9 + 83d99c8 commit 98e6648

File tree

1 file changed

+44
-17
lines changed

1 file changed

+44
-17
lines changed

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

Lines changed: 44 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -52,31 +52,58 @@ 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
58+
59+
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`).
60+
#### Minimal
61+
62+
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.
63+
#### Extended
64+
65+
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.
66+
67+
### Configuring Payload Types
68+
69+
Payload type can be configured in the following ways:
70+
71+
- 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.
72+
- Passing in the PayloadType into the `WebhookEventCollectionBuilderExtensions` methods to control which webhook events are added.
73+
74+
```csharp
75+
using Umbraco.Cms.Core.Composing;
76+
using Umbraco.Cms.Core.Webhooks;
77+
78+
namespace Umbraco.Cms.Web.UI.Composers;
79+
80+
// this composer clears all registered webhooks and then adds all (umbraco provided) webhooks with their extended payloads
81+
public class AllWebhookComposer : IComposer
5882
{
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"
83+
public void Compose(IUmbracoBuilder builder)
84+
{
85+
builder.WebhookEvents().Clear().AddCms(onlyDefault: false, payloadType: WebhookPayloadType.Extended);
6786
}
68-
},
69-
"id": "c1922956-7855-4fa0-8f2c-7af149a92135",
70-
"contentType": "root",
71-
"properties": {}
7287
}
88+
7389
```
7490

75-
The `Content Deleted` event sends only the content ID:
91+
- Manually manipulating the `WebhookEventCollectionBuilder`.
7692

77-
```json
93+
```csharp
94+
using Umbraco.Cms.Core.Composing;
95+
using Umbraco.Cms.Core.Webhooks.Events;
96+
97+
namespace Umbraco.Cms.Web.UI.Composers;
98+
99+
// since legacy is the default, this composer removes the old content published webhookevent and changes it with the new extended version.
100+
public class AllWebhookComposer : IComposer
78101
{
79-
"id": "c1922956-7855-4fa0-8f2c-7af149a92135"
102+
public void Compose(IUmbracoBuilder builder)
103+
{
104+
builder.WebhookEvents().Remove<LegacyContentPublishedWebhookEvent>();
105+
builder.WebhookEvents().Add<ExtendedContentPublishedWebhookEvent>();
106+
}
80107
}
81108
```
82109

0 commit comments

Comments
 (0)