A transformation lets you modify the payload of a webhook prior to delivery.
How transformations work
You can use transformations to change payload formats (e.g. converting XML to JSON); unify models across sources (e.g. conforming WooCommerce orders and Shopify orders to a single standard); add compatibility with an API (e.g. by adding keys or reformatting the payload); and more.
Filter rules are run after any transformation has been performed.
Transformations have some important limitations to keep in mind.
- The transformation runtime cannot perform any IO, or access any external resources such as the network or file system.
- The transformation runtime does not support promises and async/await.
- The execution runtime is limited to 1 second.
- Transformation code is limited to 5 MB.
- Transformations run in environments known as isolates, which carry their own set of limitations, detailed below.
Isolates deliver a host of performance and security advantages, but they also come with some noteworthy limitations.
While external JS libraries can be bundled with webpack for use inside your transformations, not all bundled libraries will function out of the box. Libraries that call unsupported APIs (such as the Node.js API) may require shimming using polyfills as a means of adding support. And for some libraries, this workaround may not function due to other limitations, such as:
- dependencies for which polyfills cannot add support.
- resource limitations.
- process timeouts.
In the event that memory or time limits are exceeded, the isolate will terminate the execution of your code.
Hookdeck injects a few libraries automatically to make common operations simpler, and to avoid the need to bundle with webpack. Those libraries are accessed as globals in the transformation code.
crypto to create a SHA256 hash