- Home
- Skills
- APIs & Backend
- reliable webhook outbox
reliable webhook outbox
Transactional outbox for Python/SQLite apps ensuring at-least-once webhook delivery with idempotency and signing.
$5
reliable webhook outbox
Example session with this skill installed
Add a reliable outbox to my FastAPI app so that every new order in the 'orders' table triggers a webhook to my shipping provider without duplicates.
- Read your context and instructions
- Compiled the reliable webhook outbox
I have integrated the transactional outbox pattern into your FastAPI application. The implementation ensures that order creation and webhook enqueueing occur within a single atomic transaction.
Webhook Outbox Implementation
I have added app/outbox.py, app/worker.py, and app/signing.py. The create_order endpoint now uses an idempotency key to prevent duplicate orders and enqueues the shipping notification as part of the database transaction.
# app/main.py snippets
from app import outbox, worker
@app.on_event("startup")
async def startup():
# Initialize the outbox tables in your existing SQLite DB
outbox.init(db_connection)
# Start the background worker
asyncio.create_task(worker.run_loop(db_connection, target_url=SHIPPING_API_URL))
@app.post("/orders")
async def create_order(order_data: OrderSchema, idempotency_key: str = Header(...)):
async with outbox.tx(db_connection) as tx:
# Check for existing idempotency key to prevent duplicates
if not outbox.is_new_request(tx, idempotency_key, order_data.json()):
raise HTTPException(status_code=409, detail="Duplicate request")
# Save order and enqueue webhook in one transaction
db.save_order(tx, order_data)
outbox.enqueue(tx, event_type="order.created", payload=order_data.dict(), key=idempotency_key)
return {"status": "accepted"}
The worker is now configured to POST signed requests. It will only mark events as delivered if the shipping provider returns a JSON receipt containing {"processed": true, "event_id": <id>}.
Next steps
- Update your
.envwith aWEBHOOK_SECRETfor request signing. - Run the newly created
tests/test_outbox.pyto verify the retry and lease logic. - Configure your shipping provider endpoint to verify the
X-Outbox-Signatureheader.
Connects securely to your tools. The creator never sees your data.
About this skill
Reliable systems shouldn't require heavy infrastructure like RabbitMQ or Celery for simple lead intake or order flows. When a naive process dies between saving a record and calling a webhook, you lose data, or worse, you repeat actions when a client retries.
This skill implements a transactional outbox pattern specifically for Python apps using FastAPI and SQLite. It ensures that business data and the notification event are committed in a single atomic transaction. It includes a worker implementation with leased delivery, exponential backoff, and dead-letter handling for failed events.
What it does
- Atomic Persistence ensures events are enqueued only if the business transaction succeeds.
- Leased Delivery prevents multiple workers from claiming the same event via locking mechanisms.
- Signed Envelopes secures communication using timestamped signatures to prevent tampering.
- Idempotency Control rejects duplicate client requests and prevents re-running processed effects.
- Dead Letter Management holds failed events for manual intervention after retries are exhausted.
- Status Monitoring provides counts for pending, delivered, and dead-letter events.
How it works
- Integration of reference files into the project and initialization of the outbox within the existing database.
- Transaction Wrapping of the business logic and event enqueueing inside an atomic block.
- Worker Deployment of an asyncio loop that claims, signs, and POSTs payloads to external endpoints.
- Receipt Validation to ensure deliveries are acknowledged by the receiver before marking as complete.
- Testing via an included test suite to verify the outbox under simulated failures.
Frameworks & tools
Python, FastAPI, SQLite, and httpx. The implementation relies on standard library asyncio for the worker and pytest for verification.
Why this beats prompting it yourself
Prompting often fails to handle the nuances of BEGIN IMMEDIATE locks in SQLite, leading to race conditions. This skill enforces strict transactional rules and signature verification that are difficult to prompt consistently from scratch.
Use cases
- Triggering n8n or Zapier workflows from a local database event.
- Syncing new signups to a CRM without risking data loss during downtime.
- Sending order confirmations where double-processing must be avoided.
- Managing reliable API notifications in low-resource environments.
Known limitations
Does not guarantee strict global ordering during retries. Requires httpx and pytest dependencies. Designed for single-machine SQLite; Postgres requires specific locking modifications.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 10 days ago
- Accounts
Receiver
Evil
- Software
Python 3.10+SQLite
- Optional
- PostgreSQL
Permissions
Allowed Hosts
File Scopes
What's inside
Frequently Asked Questions
New in APIs & Backend
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for APIs & Backend.