Summary
Webhooks configured for a feature service or an organization can be used as triggers to run a notebook, that is, run the notebook as webhook. Webhook receivers in this example are created and hosted by ArcGIS Notebook Server. The image below shows webhook URLs for Organization and Service webhooks. These webhook receivers are associated with specific notebook items that will be run as webhooks.

This article demonstrates how to configure webhooks (service and organization webhooks) that are used to trigger a notebook that captures a payload and saves the received payload as a JSON file.
Procedure
Create a notebook script in ArcGIS Notebook Server (see image below, payload_to_json notebook) . The notebook item will be created in the My content page in Portal for ArcGIS. The script does the following;
- It makes a folder in user's workspace if it doesn't exist. for example, a Json folder.
- It creates a timestamped json file with the current date and time.
- It writes the payload to JSON, that is, it takes the webhookPayload variable received from ArcGIS Enterprise and converts it to JSON format.

Organization webhooks
- Create an organization webhook: Organization > Settings > Webhooks > Organizations webhooks > Create webhook.
- Select the Type that triggers the webhook, for example, All.
- Choose Notebook, and associate it with the notebook payload_to_json.

- Secret is optional.
- Create an item in Portal to trigger the webhook, for example, create a hosted feature layer item.
- This creates an executeNotebookAsWebhook job on the ArcGIS Notebook server. Open the job at the ArcGIS Notebook Server Admin API, as shown in the next image, and note that under Jobs, the payload is injected into the job. The payload shows the item ID for the content added, and other properties for the webhookpayload.


- Open the notebook item from the My Content page and notice the json file in Files tab, shown in the next image

- Open the JSON file. It shows the payload injected to the job

Service webhooks
- Create a webhook receiver in the ArcGIS Notebook Server admin API. See the related article, "How to create a webhook receiver in ArcGIS Notebook server". Use the item ID associated with the notebook to execute it. that is, the payload_to_Json notebook.
- Create a service webhook: Organization >Settings > Webhooks > service webhooks > Create webhook.
- Select a feature service in Service that will trigger the webhook, for example, the below image shows a feature service named Facilities was used.
- The Events section pop ups after a feature service is selected, and select All, for example.
- In the Webhook URL section, copy and paste the webhook receiver URL created in Step 1.
- Secret is optional, but use the secret associated with developer credentials app used when creating the webhook URL (Step1, and see related article).

- Make edits on the feature service, for example, add new features.
After this, follow the same steps from 3 throug 5, above, shown for Organization webhooks. The payload however will be different as the webhookPayload variable has properties about the feature service, for example, it includes the property ChangesUrl, the URL that points to a Feature Service operation that returns list of edits made such as adds, updates and deletes.