> ## Documentation Index
> Fetch the complete documentation index at: https://docs.eazecustoms.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Verify Signatures

> Check Eaze-Signature with the raw request body before you trust an event.

> [!WARNING]
>
> **Security requirement: Always verify the `Eaze-Signature` header using your webhook signing secret before processing events. Requests without a valid signature must be rejected.**

Eaze Customs signs the outgoing request. Your application has to perform the check. A missing, stale, or mismatched signature means you respond with an error and do not update your system.

## What is signed

| Header | Meaning |
| - | - |
| `Eaze-Event-Id` | The event `id`. It matches `id` in the body. |
| `Eaze-Timestamp` | Unix time in seconds, as a decimal string. |
| `Eaze-Signature` | `sha256=` plus a lowercase hexadecimal HMAC-SHA256. |
| `Content-Type` | `application/json`. |

The signed text is the UTF-8 string:

```text theme={null}
{timestamp}.{eventId}.{rawBody}
```

`rawBody` is the exact request body. Do not parse and stringify the JSON before you verify. A re-serialized body will not match.

The HMAC key is the signing secret string, using its UTF-8 bytes. Do not decode the secret from base64 first. Compare the full `sha256=` header value in constant time.

Reject the request when `Eaze-Event-Id` does not match `id` in the verified body.

## Timestamp and duplicates

Eaze Customs does not enforce a clock window on your server. Reject a timestamp that is more than 5 minutes from the current time. That limits replay of a captured request. Use the timestamp header, not a timestamp you find only after parsing an unverified body.

Store `id` after a valid signature. Automatic retries and a portal **Retry** send the same event ID again. There is no guarantee of order or of exactly-once delivery. If you have already handled that ID, acknowledge the delivery and do not apply it again.

Keep the secret in a secret manager. When you rotate it in the portal, the previous secret stops working immediately. Update your receiver before the next delivery.

## Node.js

Use the raw body. This TypeScript example keeps the body as received bytes. Return `401` before you do any business work when verification fails. Eaze Customs waits up to 5 seconds for your response.

```typescript theme={null}
import { createHmac, timingSafeEqual } from 'node:crypto';
import { createServer, type IncomingMessage, type ServerResponse } from 'node:http';

const secret = process.env.EAZE_WEBHOOK_SECRET ?? '';

type HeaderValue = string | string[] | undefined;

function header(headers: IncomingMessage['headers'], name: string): string | undefined {
  const value = headers[name] as HeaderValue;
  return Array.isArray(value) ? value[0] : value;
}

function verifyWebhook(rawBody: string, headers: IncomingMessage['headers']) {
  const timestamp = header(headers, 'eaze-timestamp');
  const eventId = header(headers, 'eaze-event-id');
  const signature = header(headers, 'eaze-signature');
  if (!secret || !timestamp || !eventId || !signature) return null;

  const ageSeconds = Math.abs(Date.now() / 1000 - Number(timestamp));
  if (!Number.isFinite(ageSeconds) || ageSeconds > 300) return null;

  const expected = `sha256=${createHmac('sha256', secret)
    .update(`${timestamp}.${eventId}.${rawBody}`)
    .digest('hex')}`;
  const left = Buffer.from(expected);
  const right = Buffer.from(signature);
  if (left.length !== right.length || !timingSafeEqual(left, right)) return null;

  let event: { id?: string };
  try {
    event = JSON.parse(rawBody) as { id?: string };
  } catch {
    return null;
  }
  return event.id === eventId ? event : null;
}

function readBody(request: IncomingMessage): Promise<string> {
  return new Promise((resolve, reject) => {
    const chunks: Buffer[] = [];
    request.on('data', (chunk: Buffer) => chunks.push(chunk));
    request.on('end', () => resolve(Buffer.concat(chunks).toString('utf8')));
    request.on('error', reject);
  });
}

const server = createServer(async (request, response: ServerResponse) => {
  if (request.method !== 'POST' || request.url !== '/eaze/webhooks') {
    response.writeHead(404).end();
    return;
  }
  const event = verifyWebhook(await readBody(request), request.headers);
  if (!event) {
    response.writeHead(401).end();
    return;
  }
  response.writeHead(204).end();
});

server.listen(8080);
```

Return the success status only after verification. Do the business GET after you have stored the event ID, or do it asynchronously.

## Python

```python theme={null}
import hashlib
import hmac
import json
import time

def verify(raw_body: bytes, headers: dict, secret: str):
    timestamp = headers["Eaze-Timestamp"]
    event_id = headers["Eaze-Event-Id"]
    signature = headers["Eaze-Signature"]
    if abs(time.time() - int(timestamp)) > 300:
        return None
    signed = f"{timestamp}.{event_id}.".encode() + raw_body
    expected = "sha256=" + hmac.new(secret.encode(), signed, hashlib.sha256).hexdigest()
    if not hmac.compare_digest(expected, signature):
        return None
    event = json.loads(raw_body)
    if event.get("id") != event_id:
        return None
    return event
```

Pass the framework's raw body. Do not give `compare_digest` two strings that you rebuilt from parsed JSON.

## C\#

```csharp theme={null}
var signed = Encoding.UTF8.GetBytes($"{timestamp}.{eventId}.{rawBody}");
var hash = HMACSHA256.HashData(Encoding.UTF8.GetBytes(secret), signed);
var expected = "sha256=" + Convert.ToHexString(hash).ToLowerInvariant();
var valid = CryptographicOperations.FixedTimeEquals(
    Encoding.UTF8.GetBytes(expected),
    Encoding.UTF8.GetBytes(signature));
```

`rawBody` must be the unchanged request text.

## After a valid signature

1. Store `id` so a later delivery of the same event does not apply twice.
2. Return a 2xx response.
3. Read `clientRef` and `data.resource.id`.
4. Call the authorized GET for that resource.

Next: [Deliveries & Retries](https://docs.eazecustoms.com/webhooks/retries.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.