# Verifying Zoom webhook events with Laravel/PHP/hash\_hmac

**URL:** <https://devforum.zoom.us/t/verifying-zoom-webhook-events-with-laravel-php-hash-hmac/75583>\
**Category:** API and Webhooks\
**Created:** [September 8, 2022, 7:00am UTC](https://devforum.zoom.us/t/verifying-zoom-webhook-events-with-laravel-php-hash-hmac/75583 "2022-09-08T07:00:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hellospark](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/hellospark/32/30454_2.png) [@hellospark](https://devforum.zoom.us/u/hellospark)\
**Post date:** [September 8, 2022, 7:00am UTC](https://devforum.zoom.us/t/verifying-zoom-webhook-events-with-laravel-php-hash-hmac/75583/1 "2022-09-08T07:00:13Z")

</div>

I’m trying to verify Zoom webhook events using Laravel/PHP/hash\_hmac. Please see my attempt below:

```auto
$message = 'v0:'.$request->header('x-zm-request-timestamp').':'.json_encode($request->all());
$hash = hash_hmac('sha256', $message, config('services.zoom.webhook_secret_token'));
$signature = "v0={$hash}";

```

Example `$message` (with sensitive data redacted):

```auto
v0:1662618277:{"event":"meeting.updated","payload":{"account_id":"ACCOUNTID","operator":"ACCOUNTEMAIL","operator_id":"OPERATORID","object":{"uuid":"UUID","id":MEETINGID,"duration":60},"old_object":{"uuid":"UUID","id":MEETINGID,"duration":120},"time_stamp":1662618276925},"event_ts":1662618276925}

```

The resulting signature is the correct length and contains only lowercase alpha-numeric characters. It just doesn’t match the signature provided in the header.

I’ve also attempted `base64_encode()` for the `$message` and setting the binary value of hash\_hmac to true & false. I’m also certain that the secret token of my marketplace app matches that which is stored in my application .env file.

Finally, I attempted a process very similar to that found as the PHP code sample here: [Generate Signature](https://marketplace.zoom.us/docs/sdk/native-sdks/web/signature/). But though this does work in my app to generate a signature, attempting to copy it (removing irrelevant datapoints) did not work either.

Could anyone provide a code snippet showing exactly how webhooks should be verified with PHP?

Thanks in advance

---

<div class="post-metadata">

**Author:** ![hellospark](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/hellospark/32/30454_2.png) [@hellospark](https://devforum.zoom.us/u/hellospark)\
**Post date:** [September 8, 2022, 7:33am UTC](https://devforum.zoom.us/t/verifying-zoom-webhook-events-with-laravel-php-hash-hmac/75583/2 "2022-09-08T07:33:21Z")

</div>

Found the error:

`$message` should include `$request->getContent()` not `json_encode($request->all())`

The full snippet being:

```auto
$message = 'v0:'.$request->header('x-zm-request-timestamp').':'.$request->getContent();
$hash = hash_hmac('sha256', $message, config('services.zoom.webhook_secret_token'));
$signature = "v0={$hash}";
$verified = hash_equals($request->header('x-zm-signature'), $signature);

```

Hopefully that helps someone!

Live long and prosper.

---

<div class="post-metadata">

**Author:** ![danial](https://avatars.discourse-cdn.com/v4/letter/d/858c86/32.png) [@danial](https://devforum.zoom.us/u/danial)\
**Post date:** [March 30, 2023, 10:23am UTC](https://devforum.zoom.us/t/verifying-zoom-webhook-events-with-laravel-php-hash-hmac/75583/4 "2023-03-30T10:23:53Z")

</div>

Thanks alot for help 🙂 . The documentation is misleading in this regards which is not good.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/6/1/614bdd549b610bbaa46ff934617683a02bdaa03c.png) [@system](https://devforum.zoom.us/u/system)\
**Post date:** [April 2, 2024, 2:00am UTC](https://devforum.zoom.us/t/verifying-zoom-webhook-events-with-laravel-php-hash-hmac/75583/5 "2024-04-02T02:00:08Z")

</div>

Closed on April 2, 2024, 2:00am UTC

This topic was automatically closed 368 days after the last reply. New replies are no longer allowed.
