- Reducing payload size — Remove large fields like
run.run_message_historyto significantly decrease payload size - Reshaping the schema — Transform the data structure to match what your system expects
- Filtering data — Remove fields you don’t need
Transformations run server-side before the webhook is sent, so your endpoint receives exactly what you want.
Enabling Transformations
Edit your transformation
Click Edit Transformation next to the toggle to open the transformation editor.
Writing a Transformation
Transformations are JavaScript functions that receive the webhook data and return a modified version. The function must be namedhandler and receives an object with these properties:
| Property | Description |
|---|---|
payload | The webhook payload (JSON object) — modify as needed |
method | HTTP method ("POST" or "PUT") — can be changed |
url | Endpoint URL — can be changed to redirect |
eventType | Event type string (changes ignored) |
transformationsParams | Object passed via the create-message API (changes ignored) |
| Property | Description |
|---|---|
cancel | Boolean to cancel dispatch (defaults to false) |
headers | Object of HTTP headers to add (takes precedence over endpoint headers) |
Example: Remove Message History
Therun_message_history field can be very large. Remove it to reduce payload size:
Example: Extract Only What You Need
Keep just the essential fields for your downstream system:Example: Cancel Webhooks Conditionally
You can cancel delivery for certain events:Cancelled messages appear as successful dispatches in the logs but are not actually sent to your endpoint.
Example: Add Custom Headers
Add headers for routing or authentication on your end:Testing Your Transformation
The transformation editor includes a test panel where you can:- Select an event type to get a sample payload
- Or paste a custom payload
- Run your transformation
- See the resulting webhook that would be sent
Common Issues
Transformation not running
Transformation not running
Make sure the Enable Transformation toggle is on. The toggle and edit button are on the same line in the Advanced tab.
Payload unchanged after transformation
Payload unchanged after transformation
Verify you’re returning the modified
webhook object from your handler function. If you forget to return, the original payload is sent.JavaScript errors in transformation
JavaScript errors in transformation
Check the browser console for syntax errors. Common issues:
- Missing semicolons or brackets
- Accessing properties on undefined (use optional chaining:
webhook.payload.run?.status) - Invalid JSON in test payloads
Webhook delivery failing after adding transformation
Webhook delivery failing after adding transformation
Your transformation might be throwing an error. Wrap risky operations in try/catch:
Large payloads still timing out
Large payloads still timing out
If your payloads are still too large after removing
run_message_history, consider removing other large fields like run.trajectory or creating a minimal payload with only the fields you need.