# Verify signatures

> Check that a webhook really came from Morzepay.

Anyone can send a request to your webhook URL. The signature proves a webhook really came from Morzepay and wasn’t changed on the way. Check it on every webhook, before you do anything with it.

### How the signature works

Every webhook has a `Morzepay-Signature` header:

Header

```http
Morzepay-Signature: t=1791127650,v1=5e8f0c7a9b...
```

- `t` is when we signed it, in Unix seconds.

- `v1` is an HMAC-SHA256 of `t + "." + raw_body`, made with your signing secret, as hexadecimal.

To check it, make the same HMAC yourself and compare it with `v1` in constant time. Also reject timestamps more than 5 minutes old, so an old webhook can’t be replayed.

Use the **raw body** exactly as received, before any JSON parsing. Parsing and re-encoding changes the bytes, and the signature won’t match.

### Code

```php
