Skip to main content
Transformations allow you to write JavaScript code that modifies webhook properties before they’re delivered to your endpoint. You can change the HTTP method, target URL, payload, add custom headers, or even cancel specific webhooks.

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

  1. Go to the Webhooks settings in your dashboard
  2. Click on an endpoint to view its details
  3. Navigate to the Advanced tab
  4. Scroll down to the Transformations card
  5. Toggle the switch to enable transformations

Writing a Transformation

Transformations use a JavaScript handler function that receives the webhook data and returns the modified version.

Input Properties

The handler function receives an object with these properties:

Return Properties

Return the same object with your modifications. You can also add:

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:
  1. Click Test in the transformation editor
  2. Select an event type or enter a custom payload
  3. Review the transformed output
  4. Verify the changes are correct before saving
Canceled webhooks appear as successful deliveries in your logs. Use cancellation carefully to avoid missing important events.
Keep transformations simple and fast. Complex logic may cause timeouts or unexpected behavior.