Skip to content

Sign and verify AI webhook callbacks with HMAC headers

Protect downstream endpoints from forged callbacks using timestamped HMAC-SHA256 signature headers and replay window checks.

Copy the prompt and paste it into the AI assistant you already use.

Checklist for cryptographic webhook verification

  1. 01

    Sign raw payload plus timestamp

    Compute HMAC over timestamp plus raw request body bytes to prevent subtle JSON whitespace mismatches.

  2. 02

    Enforce strict timestamp tolerances

    Reject incoming callbacks older than five minutes on your server to block replay attacks.

  3. 03

    Use constant-time comparison

    Compare signature digests with timing-safe equality checks inside your backend route handler.

  4. 04

    Test dual-secret rotation

    Verify your receiver checks both active and previous signing keys before retiring old secrets.

Common questions

Why include a timestamp inside the HMAC signature?

Signing the timestamp alongside the JSON body guarantees that captured valid callbacks cannot be replayed hours later by an attacker.

Can I rotate signing secrets without breaking live jobs?

Yes. APIkit can emit signatures using dual secrets during a configurable grace window while your backend deploys the new key.

Do you provide verification snippets for Node and Python?

Yes. Copy-paste HMAC verification snippets show raw-body reading and timing-safe checks for Express, Next.js, and FastAPI.