# Need help sending notification if webhook fails

**URL:** <https://community.gravityforms.com/t/need-help-sending-notification-if-webhook-fails/19983>\
**Category:** Get Help\
**Tags:** gform\_webhooks\_post\_request, notifications, gform\_webhooks\_request\_data\
**Created:** [January 15, 2026, 12:10am UTC](https://community.gravityforms.com/t/need-help-sending-notification-if-webhook-fails/19983 "2026-01-15T00:10:45Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![user60de525d36876719](https://avatars.discourse-cdn.com/v4/letter/u/8baadc/32.png) [@user60de525d36876719](https://community.gravityforms.com/u/user60de525d36876719)\
**Post date:** [January 19, 2026, 5:40pm UTC](https://community.gravityforms.com/t/need-help-sending-notification-if-webhook-fails/19983/5 "2026-01-19T17:40:26Z")

</div>

After working with another developer, we found that the code Gravity Forms provides in the documentation wasn’t registering that there was an error because it was only looking for whether it returned _a response_, not whether the response was that the webhook was successful or not (ie, not whether it was returning a 200 response vs 404, 502, etc.). So we changed up the code, and finally got this to work:

```auto
add_action(
	'gform_webhooks_post_request',
	function ( $response, $feed, $entry, $form ) {
		gf_webhooks()->log_debug( __METHOD__. json_encode($response) );
		if ( $response['response']['code']!=200 ) {
			gf_webhooks()->log_debug( __METHOD__. '(): Sending email for error...' );
			$error_message = $response['body'];
			$to = 'email@emailhere.com';
			$subject = 'Webhook failed!';
			$body = "Webhook for entry #$entry[id] failed. Error: $error_message";
			wp_mail( $to, $subject, $body );
			gf_webhooks()->log_debug( __METHOD__. '(): Email sent...' );
		}
	},
	10,
	4
);

```

Now it it registering whether the response is 200 (successful) or not, and sending the email if the response is anything other than 200.

---

_[View the full topic](https://community.gravityforms.com/t/need-help-sending-notification-if-webhook-fails/19983)._
