WP Webhooks / Docs / fswa_webhook_data
Filter since v1.3.0

fswa_webhook_data

Filters webhook data before it is returned in REST API responses.

$

/ Signature

apply_filters( 'fswa_webhook_data', $data, $request )

/ When it fires

Fires for each webhook in a REST response: the list and single-webhook endpoints, and the responses to create, update and enable/disable toggle.

/ Parameters

NameInTypeReqDescription
$dataparamarrayyesWebhook data array returned by the REST endpoint. The webhook ID is `$data['id']`.
$requestparamWP_REST_RequestyesThe current REST request.

/ Returns

array Modified webhook data. Extensions use this to append their own per-webhook fields.

/ Examples

Append a custom computed field to webhook responses

add_filter( 'fswa_webhook_data', function ( $data, $request ) {
    $webhook_id = (int) $data['id'];
    $data['delivery_count'] = (int) get_option( "my_webhook_{$webhook_id}_count", 0 );
    return $data;
}, 10, 2 );

/ Related

Ready

Your next automation is
one sentence away.

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