Hookdeck
Transformations overviewTransformation syntaxCreate a transformationEdit a transformationDelete a transformationTroubleshoot a transformation

Transformations overview

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.

Syntax

Hookdeck allows for arbitrary transformations on request data using JavaScript (ES6). For a complete overview, see transformation syntax.

Limitations

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.

Environment

Hookdeck sandboxes your transformation process within a V8 runtime environment known as an isolate. Isolates allow multiple JavaScript VM instances to operate in parallel, sharing low-level resources while remaining fundamentally distinct and secure.

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.

<!--

Included libraries

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.

Example using crypto to create a SHA256 hash

javascript
addHandler('transform', (request, context) => {
  console.log(crypto.createHash('sha256', 'secret').update('Hello World').digest('base64'));
  // Transform the request object then return it.
  return request;
});
``` -->

### Supported methods

The following methods are supported out of the box.

- [JSON.parse](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse)
- [JSON.stringify](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)