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
To configure Webhooks, create a `config/webhooks.php` file, which returns an array.
39
+
40
+
```php
41
+
<?php
42
+
return [
43
+
'maxDepth' => 10,
44
+
'maxAttempts' => 3,
45
+
'attemptDelay' => 120,
46
+
];
47
+
```
48
+
49
+
The array can define the following keys:
50
+
51
+
-`maxDepth` – The maximum depth that the plugin should go into objects/arrays when converting them to arrays for event payloads. (Default is `5`.)
52
+
-`maxAttempts` – The maximum number of attempts each webhook should have before giving up, if the requests are coming back with non 2xx responses. (Default is `1`.)
53
+
-`attemptDelay` – The delay (in seconds) between webhook attempts. (Default is `60`.)
54
+
36
55
## Managing Webhooks
37
56
38
57
To manage your webhooks, go to Settings → Webhooks in your project’s Control Panel.
@@ -73,6 +92,32 @@ The attributes listed here (separated by newlines) will be passed to the `$extra
73
92
74
93
For “Extra Event Attributes”, each attribute should be prefixed with the name of the property and a dot (e.g. `element.author` will include the `author` attribute of an `$element` property).
75
94
95
+
#### Sending Custom Payloads
96
+
97
+
You can completely customize the webhook payload by ticking the “Send a custom payload” checkbox. That will reveal the “Payload Template” field, where you can enter the desired body contents.
98
+
99
+
That field supports Twig, so you can make this dynamic. An `event` variable will be available to it that references the event that was triggered.
100
+
101
+
```twig
102
+
{% set entry = event.sender %}
103
+
{{
104
+
{
105
+
time: now|atom,
106
+
user: currentUser.username ?? null,
107
+
name: event.name,
108
+
entry: {
109
+
class: className(entry),
110
+
id: entry.id,
111
+
title: entry.title,
112
+
slug: entry.slug,
113
+
isNew: event.isNew
114
+
}
115
+
}|json_encode(options=0)
116
+
}}
117
+
```
118
+
119
+
If the output is valid JSON, then webhook requests will be sent with an `application/json` content type.
120
+
76
121
### Toggling Webhooks
77
122
78
123
Webhooks can be enabled or disabled from both the Webhooks index page and within their Edit Webhook pages.
0 commit comments