WP Webhooks / Docs / fswa_delivery_event
Action since v3.3.0

fswa_delivery_event

Fires at every delivery state change — success, recovered, failed attempt, retry scheduled, permanently failed, skipped — with the full context in hand.

$

/ Signature

do_action( 'fswa_delivery_event', $event, $ctx )

/ When it fires

Fired by the dispatcher itself — synchronous and queued deliveries alike — at the moment it writes each state to the delivery log, so the context is complete and nothing needs to be queried back. The built-in Notifications feature is a listener on this hook at priority 10 and does no I/O of its own beyond queuing a row; keep your own listener cheap too, since it runs inside the dispatch (on a cron tick for queued webhooks, inside the request for synchronous ones). Do not dispatch another webhook from here without guarding against loops.

/ Parameters

NameInTypeReqDescription
$eventparamstringyesOne of `success`, `recovered`, `failed_attempt`, `retry_scheduled`, `permanently_failed`, `skipped`. `recovered` fires right after a `success` whose delivery had at least one earlier failed attempt, so a listener can subscribe to either.
$ctxparamarrayyesNormalized context: `webhook` (id, uuid, name, endpoint_url, is_enabled), `trigger`, `log_id`, `event_uuid`, `event_timestamp`, `attempt` (1-based), `max_attempts`, `next_attempt_at`, `http_code` (null for transport errors), `error_message`, `response_body` (capped at 4 KB), `duration_ms`, `request_url`, `is_test`, `payload` (what was sent), `original_payload` (pre-mapping, or null), `reason` (`exhausted` | `non_retryable` on permanently_failed), `had_failures`, `fired_at`.

/ Examples

Count permanently failed deliveries per webhook in a transient

add_action( 'fswa_delivery_event', function ( string $event, array $ctx ) {
    if ( $event !== 'permanently_failed' ) return;
    $key   = 'my_failed_' . (int) $ctx['webhook']['id'];
    $count = (int) get_transient( $key ) + 1;
    set_transient( $key, $count, DAY_IN_SECONDS );
    if ( $count === 3 ) {
        error_log( sprintf( '%s gave up 3 times today — last error: %s', $ctx['webhook']['name'], $ctx['error_message'] ) );
    }
}, 10, 2 );

/ Related

Ready

Your next automation is
one sentence away.

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