Workflow transformations
Transformation Steps change the current input before later Steps use it. FastHook offers an inline JSON Patch editor and reusable JavaScript DSL transformations.
Choose the transformation type
Use JSON Patch for deterministic JSON edits that can be expressed as a sequence of RFC 6902 operations. Use a JS Transformation for reusable logic, calculated values, or request-aware processing that is easier to maintain as code.
JSON Patch
The builder supports six operations, executed from top to bottom:
addinserts a value or appends an array item.removedeletes an existing value.replacereplaces an existing value.moveremoves a value from one JSON Pointer and adds it at another.copycopies a value to another JSON Pointer.testfails unless the value at a JSON Pointer equals the expected value.
Example:
[
{ "op": "add", "path": "/processed", "value": true },
{ "op": "copy", "from": "/customer/id", "path": "/customer_id" },
{ "op": "remove", "path": "/internal_debug" }
]Paths use JSON Pointer syntax, not dot notation. Escape ~ as ~0 and / as ~1 inside a field name.
Test JSON Patch in the builder
The workspace shows Original, JSON Patch, and Result panels. Load the available trigger or previous-Step sample, add operations from the JSON tree or manually, and run the Patch before saving.
The preview validates syntax and operation order. A real run can still fail if its JSON shape differs from the sample—for example, when a required source path does not exist.
Reusable JS Transformation
Create reusable code under JS Transformations, then choose that resource in a Workflow Transformation Step. At runtime the selected Step input becomes the transformation body. The runtime also receives request headers, query string, path, method, and ingestion timestamp when available.
The successful transformed body becomes the Step output. A runtime exception produces a transformation error that can be handled through an error route.
Mapping after a transformation
Later Steps read the transformed output under steps.<transformation-step-id>. Use the field picker and verify the output preview in Audit before relying on newly created fields.
Transformation checklist
- Prefer JSON Patch for small structural edits.
- Prefer a reusable JS Transformation when logic is shared across Workflows.
- Test missing fields,
null, empty arrays, and alternate provider event shapes. - Keep provider-specific side effects in Actions, not transformations.
- Connect an error route when invalid input should be recorded or recovered instead of failing the whole run.
The existing Transformations reference covers reusable transformations used by direct Connections.