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
Copy file name to clipboardExpand all lines: content/docs/automation/webhook/create-webhook.mdx
+120-5Lines changed: 120 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -115,13 +115,16 @@ For **After Insert** event, you can configure webhook to trigger only when a **s
115
115
116
116
### Webhook with custom payload ☁
117
117
118
-
<Callouttype="note">
119
-
This feature is only available in the paid plans, in both cloud & self-hosted.
120
-
</Callout>
118
+
<Callouttype="note">This feature is only available in cloud & self-hosted enterprise plans.</Callout>
121
119
122
-
In the enterprise edition, you can set up a personalized payload for your webhook. Just head to the `Body` tab to make the necessary configurations. Users can utilize [handlebar syntax](https://handlebarsjs.com/guide/#simple-expressions), which allows you to access and manipulate the data easily.
120
+
Custom payload lets you fully control the body a webhook sends when an event is triggered. You can send the entire event object, a specific field, a compact row summary, or transform rows into arrays/objects that downstream services expect.
121
+
122
+
NocoDB exposes the current event as `event` inside custom payload. These are processed with [Handlebars-like expressions](https://handlebarsjs.com/guide/#simple-expressions) and a built-in `json` helper ([examples below](#examples)).
123
+
124
+
#### Example event object
125
+
126
+
This is the sample event generated by NocoDB after a record is inserted.
123
127
124
-
Use `{{ json event }}` to access the event data. Sample response is as follows
125
128
```json
126
129
{
127
130
"type": "records.after.insert",
@@ -144,6 +147,118 @@ Use `{{ json event }}` to access the event data. Sample response is as follows
144
147
}
145
148
```
146
149
150
+
In custom payload, you will typically access paths such as `event.data.table_name` or `event.data.rows.[0].Tags`.
151
+
152
+
#### Adding a custom payload
153
+
154
+
To add a custom payload, open your webhook in NocoDB's UI and follow these steps:
155
+
1. Click on the **Body** tab
156
+
2. Enter your template using Handlebars expressions and the `json` helper.
157
+
3. Create/update Webhook or use the **Test Webhook** action to verify rendering.
<Callouttype="info">Some applications require specific headers to process webhook payloads correctly. For example, if you're sending JSON data, ensure you include the appropriate `Content-Type` header in your webhook configuration (commonly `application/json`).</Callout>
162
+
163
+
The `json` helper is used to safely serialize values into valid JSON, whether they’re strings, objects, or arrays. It ensures proper quoting and escaping, preventing common errors with quotes, newlines, or special characters. For example, `{{ json event }}` outputs the full event object, while `{{ json event.data.rows.[0].Title }}` safely inserts a single field as a JSON string. This makes it the most reliable way to embed dynamic values in webhook payloads.
164
+
165
+
Handlebars expressions allow you to dynamically access and manipulate data within templates, similar to how the json helper works for serialization. You can reference fields using dot or bracket notation, iterate over arrays with `{{#each ...}}`, and conditionally include content with `{{#if ...}}`. Learn more about using Handlebars expressions in [Handlebars documentation](https://handlebarsjs.com/guide/#simple-expressions).
166
+
167
+
#### Examples
168
+
169
+
Here are some common payload templates you can use as a starting point:
170
+
171
+
1.**Full event object:**
172
+
Sends the complete event data as JSON
173
+
174
+
```text
175
+
{
176
+
"event": {{ json event }}
177
+
}
178
+
```
179
+
180
+
2.**Single field value:**
181
+
Sends just the `Title` field of the first row
182
+
183
+
```text
184
+
{
185
+
"content": {{ json event.data.rows.[0].Title }}
186
+
}
187
+
```
188
+
189
+
3.**Compact row summary:**
190
+
Sends all fields of the first row as a JSON object
191
+
192
+
```text
193
+
{
194
+
"row": {{ json event.data.rows.[0] }}
195
+
}
196
+
```
197
+
198
+
4.**All rows as array:**
199
+
Sends all rows in the event as a JSON array
200
+
201
+
```text
202
+
{
203
+
"rows": {{ json event.data.rows }}
204
+
}
205
+
```
206
+
207
+
5.**Custom object with metadata:**
208
+
Sends an object with table name, row count, and all rows
209
+
210
+
```text
211
+
{
212
+
"table": {{ json event.data.table_name }},
213
+
"count": {{ json event.data.rows.length }},
214
+
"rows": {{ json event.data.rows }}
215
+
}
216
+
```
217
+
218
+
6.**Custom text with field value:**
219
+
Sends a simple message including the `Title` field
220
+
221
+
```text
222
+
{
223
+
"message": "New record created with title: {{ event.data.rows.[0].Title }}"
224
+
}
225
+
```
226
+
227
+
7.**Handlebar logic example:**
228
+
Sends different payloads based on whether rows exist
229
+
230
+
```text
231
+
{{#if event.data.rows.length}}
232
+
{
233
+
"hasRows": true,
234
+
"rows": {{ json event.data.rows }}
235
+
}
236
+
{{else}}
237
+
{
238
+
"hasRows": false
239
+
}
240
+
{{/if}}
241
+
```
242
+
243
+
8.**Multiple rows with formatting:**
244
+
Sends all rows with only `Id` and `Title`, formatted as a JSON array
0 commit comments