WP Webhooks / Docs / fswa_webhook_payload
Filter since v1.0.0

fswa_webhook_payload

Filters the per-webhook outgoing payload after field mapping, immediately before HTTP dispatch.

$

/ Signature

apply_filters( 'fswa_webhook_payload', $payload, $webhook_id, $trigger, $original_payload )

/ When it fires

Fires once per delivery attempt, after field mapping and type casting but before the HTTP request is sent: inline for synchronous webhooks, and on every queued attempt and retry (each retry starts again from the mapped payload). Test sends (admin Test button, Build with AI test_dispatch) run it too. Pre-dispatch Code Glue snippets run as a listener on this filter at priority 10.

/ Parameters

NameInTypeReqDescription
$payloadparamarrayyesThe mapped payload about to be dispatched.
$webhook_idparamintyesWebhook configuration ID.
$triggerparamstringyesThe WordPress action name.
$original_payloadparamarray|null—Pre-mapping payload, or `null` if no mapping was applied.

/ Returns

array Modified payload. Must remain an array.

/ Examples

Inject site URL and current time into every delivery

add_filter( 'fswa_webhook_payload', function ( $payload, $webhook_id, $trigger, $original ) {
    $payload['_meta'] = [
        'site'      => home_url(),
        'sent_at'   => gmdate( 'c' ),
        'webhook'   => $webhook_id,
    ];
    return $payload;
}, 10, 4 );

Modify payload only for a specific webhook

add_filter( 'fswa_webhook_payload', function ( $payload, $webhook_id, $trigger, $original ) {
    if ( $webhook_id !== 42 ) return $payload;
    // Rename a field for this webhook only
    $payload['contact_email'] = $payload['billing_email'] ?? '';
    unset( $payload['billing_email'] );
    return $payload;
}, 10, 4 );

/ Related

Ready

Your next automation is
one sentence away.

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