Skip to content
Back to skills

Webhook Handling

ASecurity

Builds a webhook receiver that verifies signatures on the raw body, rejects replays, deduplicates events and acknowledges fast before processing.

  • 3 stars
  • 0 votes
  • 0 copies
  • 5 views
  • Added November 15, 2026
ai-agentsrustgoapidatabasedocumentation

Works with

  • api

Security analysis

A100/100

Scanned November 15, 2026

npx -y skills add workspace-templates/ai-agent-templates --skill webhook-handling --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Webhook Handling?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Webhook Handling
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/workspace-templates-webhook-handling/badge)](https://www.skillsdirectory.com/skills/workspace-templates-webhook-handling)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: webhook-handling
description: Builds a webhook receiver that verifies signatures on the raw body, rejects replays, deduplicates events and acknowledges fast before processing.
---

# Webhook handling

Verify first, answer quickly, process later, never twice.

## Steps

1. Read the provider's signature documentation for the exact scheme: header name, signed payload (often `timestamp.body`), algorithm and tolerance.
2. Capture the raw request body before any JSON parsing. Frameworks that parse first change whitespace and break the signature. Configure the route to keep the raw bytes.
3. Verify with HMAC using the stored secret and compare in constant time (`crypto.timingSafeEqual`, `hmac.compare_digest`). Reject if the timestamp is older than about 5 minutes to stop replays. Reply 401 on any mismatch, with no detail.
4. Insert the event id into an `webhook_events` table with a unique constraint. If the insert conflicts, return 200 immediately; it is a duplicate.
5. Enqueue the processing job with the stored event and return 2xx within a second or two. Do no database fan-out or outbound calls in the request.
6. In the job, handle ordering. Never assume events arrive in sequence: compare the event's timestamp or version with the stored one and ignore stale events, or fetch the current object from the provider's API.
7. Ignore unknown event types with a 200 so new provider events do not cause retries.
8. Add tests with a valid signature, a tampered body, an expired timestamp and a duplicate id.

## Rules

- Never log the secret or the full signature header.
- Never use a plain `==` to compare signatures.
- Never trust the payload to identify the account without verifying.

## Report

Provider scheme implemented, table and job added, behaviors for duplicates and stale events, tests.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.