- Reducing payload size — Remove fields your endpoint does not need
- 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
1
Open the Webhooks portal
Navigate to the Webhooks tab in your Cyberdesk dashboard.
2
Select your endpoint
Click on the Endpoints tab and select the endpoint you want to transform.
3
Open Advanced settings
Click on the Advanced sub-tab within the endpoint details.
4
Enable transformations
Toggle Enable Transformation to on.
5
Edit your transformation
Click Edit Transformation next to the toggle to open the transformation editor.
6
Write and test your code
Write your JavaScript transformation function, then use the Test feature to verify it works with sample payloads.
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:
The function must return the same object, but may modify its properties as described above. You can also set these additional properties on the returned object:
Example: Remove Output Data
If your endpoint only needs run status and metadata, removeoutput_data 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
The default
run_complete payload omits run_message_history. If your payloads are still too large, remove other large fields such as output_data or create a minimal payload with only the fields you need.