Use Cases
Transformations are useful when you need to:- Modify payloads to match your system’s expected format
- Redirect webhooks to different URLs based on payload content
- Add custom headers for authentication or routing
- Filter webhooks by canceling ones you don’t need
- Transform data (e.g., convert currency formats, rename fields)
Accessing Transformations
- Go to the Webhooks settings in your dashboard
- Click on an endpoint to view its details
- Navigate to the Advanced tab
- Scroll down to the Transformations card
- Toggle the switch to enable transformations
Writing a Transformation
Transformations use a JavaScripthandler function that receives the webhook data and returns the modified version.
Input Properties
Thehandler function receives an object with these properties:
| Property | Type | Description |
|---|---|---|
method | string | HTTP method ("POST" or "PUT") |
url | string | The endpoint URL |
payload | object | The webhook payload as JSON |
eventType | string | The event type (read-only) |
Return Properties
Return the same object with your modifications. You can also add:| Property | Type | Description |
|---|---|---|
cancel | boolean | Set to true to cancel this webhook |
headers | object | Custom headers to add to the request |
Examples
Modify the Payload
Flatten nested data or rename fields:Redirect Based on Payload
Send webhooks to different URLs based on content:Add Custom Headers
Include additional headers for your endpoint:Cancel Specific Webhooks
Filter out webhooks you don’t want to receive:Change HTTP Method
Switch from POST to PUT if needed:Testing Transformations
Before saving your transformation:- Click Test in the transformation editor
- Select an event type or enter a custom payload
- Review the transformed output
- Verify the changes are correct before saving