---
title: "Dynamic URLs via Filter"
description: "Rewrite the webhook endpoint URL per-event from PHP using the `fswa_webhook_url` filter."
url: "https://wpwebhooks.org/docs/dynamic-urls/"
---

[WP Webhooks](https://wpwebhooks.org/) / [Docs](https://wpwebhooks.org/docs/) / Dynamic URLs via Filter

Feature since v1.0.0

# Dynamic URLs via Filter

Rewrite the webhook endpoint URL per-event from PHP using the \`fswa\_webhook\_url\` filter.

The `fswa_webhook_url` filter receives the configured URL, the outgoing payload, the webhook configuration, the trigger name, and the original pre-mapping payload. Return a modified URL to route different events to different endpoints — useful for REST APIs that embed object IDs in the path.

/ Examples

Route to a specific HubSpot deal by ID

```
add_filter( 'fswa_webhook_url', function ( $url, $payload, $webhook, $trigger, $original ) {
    if ( (int) $webhook['id'] === 30 ) {
        $deal_id = $payload['_hs_deal_id'] ?? '';
        return "https://api.hubapi.com/crm/v3/objects/deals/{$deal_id}";
    }
    return $url;
}, 10, 5 );
```

/ Related

[fswa\_webhook\_url](https://wpwebhooks.org/docs/fswa-webhook-url/)[Dynamic URL Templates](https://wpwebhooks.org/docs/dynamic-url-templates/)[URL Query Parameters](https://wpwebhooks.org/docs/url-query-params/)

/Ready

## Your next automation is  
one sentence away.

[Install Plugin→](https://wordpress.org/plugins/flowsystems-webhook-actions/) [See the Plugin →](https://wpwebhooks.org/wordpress-webhook-plugin/)

$ wp plugin install flowsystems-webhook-actions --activate

## Structured data

```json
{"@context":"https://schema.org","@type":"TechArticle","name":"Dynamic URLs via Filter — Feature — Webhook Actions Docs","description":"Rewrite the webhook endpoint URL per-event from PHP using the `fswa_webhook_url` filter.","url":"https://wpwebhooks.org/docs/dynamic-urls/","isPartOf":{"@type":"WebSite","name":"WP Webhooks","url":"https://wpwebhooks.org"},"about":{"@type":"SoftwareApplication","name":"Webhook Actions","applicationCategory":"WordPress Plugin"}}
```
