# Webhook Agent Gate: one action per event, owner-approved refunds and a checker for your handler

> A small gate between Stripe, GitHub, form or store webhooks and the agent they start. It checks the signature on the raw body, stores each event once, keys every action on what it acts on so a duplicate, a retry or a crash cannot do it twice, and holds refunds for the owner at a terminal the agent cannot use. Includes replay.py to fire duplicates and forged deliveries at your own handler, and a read-only checker for handlers, event maps, ledgers and agent rules.

- URL: https://paperchasewebb.ai/bots/marketplace/items/webhook-agent-gate-one-action-per-event-owner-approved-refunds-checker/
- Type: Prompt pack
- Category: Vibe coding
- By: PaperChaseWebb
- Works with: Claude Code, Codex, Grok Bot, Hermes (named in the listing); A small Python gate in front of the agent or automation your webhooks start. Rules for AGENTS.md and CLAUDE.md, Claude Code settings, Codex and Hermes notes and a Grok Bot standing order. Signatures tested against stripe-python 16.1.0, stripe-node 23.1.0 and standardwebhooks 1.1.0. The agent files were checked by the checker on Linux; they were not loaded inside each agent for this release
- Price: $29 USD
- Difficulty: Intermediate
- Setup time: 45 min
- Time to result: The checker on a handler you already have in 5 minutes; the gate running with test events in under an hour
- Format: Markdown (.md) file, webhook-agent-gate-one-action-per-event-owner-approved-refunds-checker.md
- Version: 1.0, updated 2026-10-31
- License: Use inside your own team or company, including on client work. Do not resell or republish the kit itself.

## What you end up with

Every webhook leads to at most one receipt, one refund and one agent run, money waits for your yes, and you can prove your own handler survives duplicates and forged deliveries before you go live.

## What you get

- 20 sections and an appendix in one .md file, with a one-line unpack for all 35 files
- hookgate.py: one endpoint per provider, signature checks for Stripe, GitHub, Standard Webhooks and Lemon Squeezy-style senders, each event stored once
- A ledger keyed on the action (refund:ch_123), an atomic claim, and an unknown state for crashes and timeouts that is looked up, never re-run on its own
- The owner step: refunds wait until the owner types part of the key and a name at a real terminal; piped input is refused
- replay.py: duplicates, a 20-copy burst, forged, tampered, stale and oversized deliveries against your own handler
- hook_check.py: 17 handler checks plus checks for event maps, ledgers and agent rules, tested on Stripe's public sample servers
- Rules and two skills for Grok Bot, Claude Code, Codex and Hermes, six owner stops, eight prompts and a failure table
- The test harness: 97 unit tests, 99 planted faults and 10 interop checks, so you can repeat every result

## Who it is for

Anyone who lets a webhook start an agent and wants each event to act once, with a person in charge of the money.

## Tools needed

- Python 3.8 or newer: runs the gate, the worker, the owner approval script, replay.py and hook_check.py; standard library only
- Grok Bot, Claude Code, Codex or Hermes: picks up task files the gate writes and proposes actions under the AGENTS.md rules or the Grok Bot standing order; never approves money
- Stripe, GitHub, Lemon Squeezy or any Standard Webhooks sender: sends the events; the gate verifies all four signature schemes
- You need: Python 3.8 or newer
- You need: A webhook sender (Stripe, GitHub, a form or store tool)
- You need: Your own HTTPS in front of the gate for live use

Cost to run: The kit is the only purchase. Everything runs locally with Python; the checker makes no network calls.

## How it works

1. **Unpack and test.** Save the kit as pack.md in an empty folder, run the unpack line from section 20, then sh test_all.sh. Expected: 35 files written; 97 tests OK; 99 of 99 planted faults caught.
2. **Check the handler you have.** Run python3 hook_check.py code on your webhook route file with --fail-on high. Expected: A list of findings with fixes, or a clean line.
3. **Watch the flow.** Run sh example/run_example.sh and read it next to section 15. Expected: One receipt and one refund from five deliveries and two refund forms; the forged request refused.
4. **Make it yours.** Fill in the event map with the owner, edit gate/events.json, run replay.py suite against the gate with your test secret, then fill in the go-live card. Expected: Every replay line ok; hook_check events clean.

## Sample prompt: Setup check (Grok Bot, Claude Code, Codex, Hermes)

```
Read AGENTS.md and skills/webhook-gate-builder/SKILL.md. Tell me the stop points in your own words and which kinds in gate/events.json you may propose.
```

Prompt 1 of 8.

## Sample prompt: Review my handler (Grok Bot, Claude Code, Codex, Hermes)

```
Use skills/webhook-review on [file]. Run hook_check.py code with --fail-on low and explain each high finding in one line with the smallest fix. Do not edit the file.
```

Prompt 2 of 8.

## Sample prompt: A refund request (Grok Bot, Claude Code, Codex, Hermes)

```
Read the task in tasks/ for this refund request. Propose the refund with propose.py, then stop and give me the key. Do not run approve.py.
```

Prompt 5 of 8.

## Free preview of webhook-agent-gate-one-action-per-event-owner-approved-refunds-checker.md

````markdown
# Webhook Agent Gate: one action per event, owner approval for money, and a checker for your own handler

Version 1.0, 2026-10-31. By PaperChaseWebb. A small gate that sits between Stripe, GitHub, form or store webhooks and the agent or automation they start. It checks the signature on the raw body, stores each event once, and runs every real-world action (a refund, a receipt, a plan change, an agent task) through a ledger keyed on the action itself, so a duplicate, a retry or a crash cannot do it twice. Refunds wait for the owner at a terminal the agent cannot use. Comes with replay.py, which fires duplicates, bursts and forged deliveries at your own handler, a read-only checker for handlers, event maps, ledgers and agent rules, rules and skills for Grok Bot, Claude Code, Codex and Hermes, and templates. Python 3.8 or later, standard library only. Tested as described in section 12: 97 unit tests and 99 planted faults on Python 3.13, 3.12, 3.11, 3.9 and 3.8, 10 of 10 interop checks against stripe-python 16.1.0, stripe-node 23.1.0 and standardwebhooks 1.1.0, and the checker run on Stripe's public sample servers. All business data is made up. Nothing here was run against a live Stripe or GitHub account; section 12 lists every gap.

Providers send the same event more than once. Stripe says so in its webhook docs, GitHub lets you redeliver by hand, and both retry when your handler is slow. A handler that only writes a row shrugs that off. A handler that starts an agent, sends a r
````

## Test record

- Date: Oct 31, 2026
- What was run: tests/test_verify.py (22), test_ledger.py (21), test_gate.py (24, real HTTP), test_check.py (27) and test_mini.py (3); tests/mutate.py with 99 planted faults across handlers, event maps, ledgers, agent rules and the gate itself; tests/interop.py, 10 checks with stripe-python 16.1.0, stripe-node 23.1.0, standardwebhooks 1.1.0 and Node 24.22.1; hook_check.py on stripe-samples/accept-a-payment; example/run_example.sh end to end; and the unpack line with test_all.sh. Linux, Python 3.13, 3.12, 3.11, 3.9 and 3.8.
- Result: 97 passed, 0 failed on all five versions; 99 of 99 planted faults caught; 10 of 10 interop checks; 26 findings on the Stripe samples; the example made one receipt and one refund; the unpack line wrote 35 files and test_all.sh passed there.
- Not run: Live Stripe or GitHub deliveries, the Stripe CLI and the live Stripe refund adapter. A live Grok Bot, Claude Code, Codex or Hermes session. macOS or Windows. Real business data. Load beyond a few hundred events.

Copied from this item's dated test notes. What was not run stays in.

## Worth knowing

- Nothing was run against a live Stripe or GitHub account. Signatures were tested against the official Stripe and Standard Webhooks libraries, and the real Stripe refund adapter is written from the Stripe docs but was not run. Send test-mode events before you switch a live endpoint.
- The agent rules and settings were checked by the checker but not loaded inside a live Grok Bot, Claude Code, Codex or Hermes session for this release. Run prompt 1 once before you rely on it.
- The owner step assumes the agent cannot run approve.py at a terminal or write gate.db. Run the worker and approve.py as a separate user; agent rules alone are not a hard boundary.
- The gate listens on 127.0.0.1 and needs your own HTTPS in front of it for live use. It suits a small business, not thousands of events a second.
- hook_check.py is pattern checks on Python and JavaScript/TypeScript. It does not follow helper functions in other files and does not prove a handler is safe.
- All business data is made up. Tested on Linux only; macOS and Windows were not tested.
- On 2026-10-31 on Linux: 97 unit tests and 99 of 99 planted faults passed on Python 3.13, 3.12, 3.11, 3.9 and 3.8; 10 of 10 interop checks passed; the checker found 26 findings in Stripe's accept-a-payment sample servers; the unpack line wrote 35 files and test_all.sh passed in that folder.

## Questions

**Which agents does it work with?** Any agent that can read a task file and run a script. The kit has rules for AGENTS.md and CLAUDE.md, Claude Code settings, Codex and Hermes notes and a Grok Bot standing order. Those were checked by the checker, not loaded in each agent for this release.

**Can my agent approve a refund?** Not through the gate. The agent can only propose. approve.py needs a real terminal and part of the key typed by hand. Run it as a separate user so the agent cannot reach it at all.

**I already have a webhook handler. Do I need the gate?** Not always. Run hook_check.py and replay.py on your handler first. If it passes, copy the ledger idea from section 5 and keep your code.

**Does it work with n8n or Zapier?** Put the gate in front and let the worker call your flow as an action, so the flow runs once per action key. The n8n with AI Agents kit covers the approve step inside n8n.

**Can you set it up for us?** Yes. Our Install sprint wires it to your Stripe, forms and agents with your own rules. Book a call or write to mgmt@paperchasewebb.com.

## How to buy

$29 one time at https://paperchasewebb.ai/bots/marketplace/items/webhook-agent-gate-one-action-per-event-owner-approved-refunds-checker/. Stripe checkout, then an instant download page; the download link is also in your emailed receipt.

Seller: PaperChaseWebb Inc., mgmt@paperchasewebb.com
