What is a webhook?
In simple terms, think of a webhook as a notification. A user can trigger a webhook in FotoWeb when clicking on an asset marker or when executing an action. FotoWeb then sends data about the asset(s) to the external target system. The external system is targeted using a regular web URL in the webhook setup of FotoWeb configuration. The data that is sent to the target system can be sent in JSON format or as FORM data using a POST command.
The target system receives all the data about the assets in FotoWeb, along with relevant URLs to create thumbnails/previews, for example, and all the relevant metadata in the assets.
From a more technical perspective, webhooks are HTTP requests sent by the FotoWeb server to external sites. They are POST requests to a preset URL whose body can contain either JSON or form data (application/x-www-form-urlencoded). The content depends on the type of webhook. For example, for assets it's the JSON representation of a single asset.
How does using a webhook differ from using FotoWeb's REST API?
- The REST API is used to invoke/call methods in the system (functions, methods, requests)
- Webhooks are used to listen to events in the system (events, callbacks)
Why should I use webhooks, and for what?
Webhooks can be used to customize the behavior of user actions in FotoWeb. For example, you can create a completely custom workflow by passing data about assets that are processed in FotoWeb to an external system that can parse the webhook data and in turn pick up the assets and process them in any way imaginable.
Some practical use cases for webhooks:
- A web master decides on a new picture to be used as the banner on their website's homepage. All she has to do is click on a marker in FotoWeb to deliver the new picture to the CMS, and the website is updated with the new picture immediately.
- A user chooses a new product shot that he wants to promote on the company Facebook page. By clicking on a marker or running an action, he triggers a webhook from FotoWeb that communicates with the zapier.com middleware web service and posts the picture on the Facebook page within a few seconds. A comment is extracted from the asset's metadata and added to the post to describe it on Facebook.
Using webhooks with middleware
Several online services exist that allow you to create any number of integrations using webhooks. One of them is Zapier, which allows you to create an integration with a plethora of online services. For example, Zapier can be used receive a webhook and then store the associated asset in Dropbox, add asset metadata to a spreadsheet in Google Drive, post a preview of the asset on a WordPress blog and so on. Another online service that offer similar functionality is IFTTT ("If this, then that").
Some of these services may be free to use, while full functionality may only be available through a subscription.
What data is transferred using webhooks?
Asset information that is transferred includes all the XMP metadata, as well as file information about the asset and any information required to modify/download it.
- Managing and monitoring webhook requests
- How to manage webhooks that users have triggered and see if they were successful.