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: admin_manual/webhook_listeners/index.rst
+65-16Lines changed: 65 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,12 +4,40 @@ Webhook Listeners
4
4
5
5
.. _webhook_listeners:
6
6
7
-
Nextcloud supports listening to internal events via webhooks.
7
+
Introduction
8
+
------------
9
+
10
+
Nextcloud supports sending notifications to external services whenever something
11
+
important happens, such as when files are changed or updated.
12
+
13
+
Overview
14
+
--------
15
+
16
+
The Webhook Listeners app enables your Nextcloud server to automatically notify
17
+
external services whenever important events - such as file changes, uploads, or
18
+
deletions - occur in your instance. By configuring webhook listeners, administrators
19
+
can set up custom HTTP notifications (webhooks) that are triggered by specific
20
+
internal events, allowing seamless integration with other platforms and automation of
21
+
workflows without manual intervention.
22
+
23
+
The Webhook Listeners app enables your Nextcloud server to automatically notify
24
+
external services whenever important events - such as file changes, uploads, or
25
+
deletions - occur in your instance. By configuring webhook listeners, administrators
26
+
can set up custom HTTP notifications (webhooks) that are triggered by specific
27
+
internal events, allowing seamless integration with other platforms and automation of
28
+
workflows without manual intervention.
29
+
30
+
The app works by monitoring Nextcloud's event system and dispatching HTTP
31
+
requests to defined endpoints whenever a matching event takes place. Management and
32
+
configuration of webhook listeners are handled via the Nextcloud OCS API and
33
+
command-line tools. The app is ideal for scenarios where you want to connect Nextcloud
34
+
with notification systems, external automation platforms, or custom integrations -
35
+
without requiring manual polling.
8
36
9
37
Installation
10
38
------------
11
39
12
-
* Enable the ``webhook_listeners`` app that comes bundled with Nextcloud
40
+
Enable the ``webhook_listeners`` app that comes bundled with Nextcloud - e.g.
13
41
14
42
.. code-block:: bash
15
43
@@ -18,37 +46,58 @@ Installation
18
46
Listening to events
19
47
-------------------
20
48
21
-
You can use the OCS API to add webhooks for specific events: https://docs.nextcloud.com/server/latest/developer_manual/_static/openapi.html#/operations/webhook_listeners-webhooks-index
49
+
You can use the OCS API to add webhooks for specific events. See:
50
+
`Register a new webhook <https://docs.nextcloud.com/server/latest/developer_manual/_static/openapi.html#/operations/webhook_listeners-webhooks-index>`_.
22
51
23
-
.. TODO ON RELEASE: Update version number above on release
52
+
.. TODO ON RELEASE: Update version number above upon release.
24
53
25
-
Note: When authenticating with the OCS API to register webhooks the account you authenticate as must have administrator rights or delegated administrator rights.
54
+
Note: When authenticating with the OCS API to register webhooks, the account you
55
+
use must have administrator rights or delegated administrator rights.
26
56
27
57
Filters
28
58
~~~~~~~
29
59
30
-
When registering a webhook listener, you can specify a filter parameter. The value of this parameter must be a JSON object whose properties represent filter conditions. The ``{}`` is an empty query, meaning no specific criteria, so all events are matched.
31
-
32
-
If you would like to match events fired by a specific user, you can pass ``{ "user.uid": "bob" }`` to match all events fired in the context of user ``"bob"``.
60
+
When registering a webhook listener, you can specify a filter parameter. The value of
61
+
this parameter must be a JSON object whose properties represent filter conditions.
62
+
The ``{}`` object is an empty query, meaning no specific criteria are set, so all events
63
+
are matched.
33
64
34
-
If you would like to enforce multiple criteria, you can simply pass multiple properties ``{ "event.tableId": 42, "event.rowId": 3 }``
65
+
If you want to match events triggered by a specific user, you can pass
66
+
``{ "user.uid": "bob" }`` to match all events associated with the user ``bob``.
35
67
36
-
If you would like to match values partially, you can use regular expressions: ``{ "user.uid": "/admin_.*/"}`` will match any user whose user ID starts with ``admin_``. This can be especially useful for filesystem events for filtering by path: ``{ "event.node.path": "/^\\/.*\\/files\\/Special folder\\//"}`` will match files inside the ``Special folder`` of any user (Note especially, that the slashes in the path need to be escaped with two back-slashes, once because we're inside a json string and once because we're inside a regular expression).
68
+
To enforce multiple criteria, simply pass multiple properties:
69
+
``{ "event.tableId": 42, "event.rowId": 3 }``.
37
70
38
-
You can also use additional comparison operators (``$e, $ne, $gt, $gte, $lt, $lte, $in, $nin``) as well as logical operators (``$and, $or, $not, $nor``). For example use ``{ "time" : { "$lt": 1711971024 } }`` to accept only events prior to April 1st 2024 and ``{ "time" : { "$not": { "$lt": 1711971024 } } }`` to accept events after April 1st 2024.
71
+
If you want to match values partially, you can use regular expressions:
72
+
``{ "user.uid": "/admin_.*/" }`` will match any user whose user ID starts with
73
+
``admin_``. This can be especially useful for filesystem events when filtering by path:
74
+
``{ "event.node.path": "/^\\/.*\\/files\\/Special folder\\//" }`` will match files
75
+
inside the ``Special folder`` of any user. Note that the slashes in the path need to be
76
+
escaped with two backslashes: once because you are inside a JSON string, and once
77
+
because you are inside a regular expression.
39
78
79
+
You can also use additional comparison operators (``$e``, ``$ne``, ``$gt``, ``$gte``,
80
+
``$lt``, ``$lte``, ``$in``, ``$nin``) as well as logical operators (``$and``, ``$or``,
81
+
``$not``, ``$nor``). For example, use ``{ "time": { "$lt": 1711971024 } }`` to accept
82
+
only events prior to April 1st, 2024, and ``{ "time": { "$not": { "$lt": 1711971024 } }}``
83
+
to accept events after April 1st, 2024.
40
84
41
85
Speeding up webhook dispatch
42
86
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
43
87
44
-
This app uses background jobs to trigger the registered webhooks. Thus, by default, webhooks will be triggered only every 5 minutes, as the default cron interval is 5 minutes.
45
-
To trigger webhooks earlier, you can set up a background job worker. The following command will launch a worker for the webhook call background job:
88
+
This app uses background jobs to trigger registered webhooks. By default, webhooks
89
+
are triggered every 5 minutes, as the default cron interval is set to 5 minutes.
90
+
To trigger webhooks sooner, you can set up a background job worker.
91
+
92
+
The following command will launch a worker for the webhook call background job:
46
93
47
94
Screen or tmux session
48
95
^^^^^^^^^^^^^^^^^^^^^^
49
96
50
-
Run the following occ command inside a screen or a tmux session, preferably 4 or more times for parallel processing of multiple requests by different or the same user.
51
-
It would be best to run one command per screen session or per tmux window/pane to keep the logs visible and the worker easily restartable.
97
+
Run the following ``occ`` command inside a screen or tmux session, preferably four
98
+
or more times, to enable parallel processing of multiple requests by different users
99
+
or the same user. It is best to run one command per screen session or tmux window/pane
100
+
to keep logs visible and make each worker easy to restart.
52
101
53
102
.. code-block::
54
103
@@ -690,4 +739,4 @@ This is an exhaustive list of available events. It features the event ID and the
0 commit comments