Skip to main content
skill CX Codex

emitting-api-events — Claude Code skill for webhooks, SSE

emitting-api-events — a skill that builds event-driven APIs: outbound webhooks, Server-Sent Events, and message broker integration. Fits projects where mutations need to notify downstream services.

MIT 1 installs ★ 2,935 updated 2026-11-01

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add jeremylongshore/tons-of-skills-marketplace --skill emitting-api-events -a claude-code
Open on GitHub

What emitting-api-events does

The skill scans API mutations with Grep and Read, cataloging every POST, PUT, PATCH and DELETE that should emit an event. Event type names follow a resource.action pattern like order.created or user.updated. Each type gets a versioned schema with eventId, eventType, version, timestamp, source and data.

Events publish through a transactional outbox. The event record is written in the same database transaction as the mutation, then a separate process polls the outbox table and publishes to the broker. Crashes between commit and publish do not lose events. Redis Pub/Sub, RabbitMQ, Kafka and AWS SNS/SQS are all supported.

Webhook delivery signs payloads with HMAC-SHA256. Retries follow exponential backoff — 1 min, 5 min, 30 min, 2 hr, 24 hr — and subscriptions deactivate after 5 consecutive failures. The SSE endpoint at GET /events/stream handles reconnection via Last-Event-ID. A dead-letter queue catches events that exhaust every retry. You need a message broker and persistent storage before this skill can generate anything runnable.

What it helps with

  • emit versioned events from API mutations
  • deliver signed webhooks with retry and deactivation
  • stream events to browsers with SSE and replay
  • keep an audit log through event sourcing
  • route failed deliveries to a dead-letter queue

Example prompts for the agent

  • Add webhooks to my orders API and emit order.created on POST
  • Set up GET /events/stream with Last-Event-ID reconnection
  • Implement a transactional outbox polling every 100ms and publishing to Kafka

How to install emitting-api-events

1Skills CLI (Vercel)

npx skills add jeremylongshore/tons-of-skills-marketplace --skill emitting-api-events -a claude-code

2Manually: put the files in place

~/.claude/skills/emitting-api-events/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/emitting-api-events/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about emitting-api-events

How do I install emitting-api-events in Claude Code?

Run npx skills add jeremylongshore/tons-of-skills-marketplace --skill emitting-api-events -a claude-code. The skill lands at ~/.claude/skills/emitting-api-events/SKILL.md.

What does emitting-api-events do?

It designs event-driven API architecture: event emission from mutations, a versioned schema registry, webhook subscription management, retry-based delivery, SSE streaming and a dead-letter queue.

What do I need before using it?

A message broker — Redis Pub/Sub, RabbitMQ, Kafka or AWS SNS/SQS. Also persistent storage for the event log and subscriber registrations: PostgreSQL or MongoDB. The retry queue can be Bull, Celery or a managed service.

Source text

SKILL.md · MIT
---
name: emitting-api-events
description: 'Build event-driven APIs with webhooks, Server-Sent Events, and real-time
  notifications.

  Use when building event-driven API architectures.

  Trigger with phrases like "add webhooks", "implement events", or "create event-driven
  API".

  '
allowed-tools: Read, Write, Edit, Grep, Glob, Bash(api:events-*)
version: 1.25.0
author: Jeremy Longshore <[email protected]>
license: MIT
tags:
- api
- webhooks
- emitting-api
compatibility: Designed for Claude Code
---
# Emitting API Events

## Overview

Build event-driven API architectures using outbound webhooks, Server-Sent Events (SSE), and message broker integration. Implement event emission from API mutations, event schema registry, subscriber management, delivery guarantees with retry logic, and event sourcing patterns for maintaining a complete audit log of API state changes.

## Prerequisites

- Message broker: Redis Pub/Sub, RabbitMQ, Apache Kafka, or AWS SNS/SQS
- Persistent storage for event log and subscriber registrations (PostgreSQL, MongoDB)
- Webhook delivery infrastructure with retry queue (Bull, Celery, or managed service)
- Event schema registry for versioned event type definitions
- SSE-capable web framework for real-time event streaming to browser clients

## Instructions

1. Identify event-producing operations using Grep and Read, cataloging every API mutation (POST, PUT, PATCH, DELETE) that should emit events, with event type names following `resource.action` convention (e.g., `order.created`, `user.updated`).
2. Define event schemas for each event type with versioning: include `eventId` (UUID), `eventType`, `version`, `timestamp` (ISO 8601), `source` (service identifier), and `data` (type-specific payload).
3. Implement the event emitter service that publishes events to the message broker after successful API mutations, using the transactional outbox pattern to ensure events are not lost on application crash.
4. Build a webhook subscription management API: `POST /webhooks` (subscribe), `GET /webhooks` (list), `DELETE /webhooks/:id` (unsubscribe), with URL validation, event type filtering, and signing secret generation.
5. Implement webhook delivery with HMAC-SHA256 signed payloads, configurable retry policy (exponential backoff: 1min, 5min, 30min, 2hr, 24hr), and automatic subscription deactivation after consecutive failures.
6. Add Server-Sent Events endpoint (`GET /events/stream`) for real-time event delivery to browser clients, with `Last-Event-ID` support for reconnection and missed event replay.
7. Create a dead-letter queue for events that exhaust all delivery retry attempts, with alerting and manual replay capability.
8. Write integration tests covering event emission, webhook delivery with signature verification, SSE stream connection with reconnection, and dead-letter queue behavior.

See [`references/implementation.md`](references/implementation.md) for the full implementation guide.

## Output

- `${CLAUDE_SKILL_DIR}/src/events/emitter.js` - Event emission service with outbox pattern
- `${CLAUDE_SKILL_DIR}/src/events/schemas/` - Versioned event type schema definitions
- `${CLAUDE_SKILL_DIR}/src/events/webhooks/` - Webhook delivery, signing, and retry logic
- `${CLAUDE_SKILL_DIR}/src/events/sse.js` - Server-Sent Events streaming endpoint
- `${CLAUDE_SKILL_DIR}/src/routes/webhooks.js` - Webhook subscription management API
- `${CLAUDE_SKILL_DIR}/src/events/dead-letter.js` - Dead-letter queue handler with replay
- `${CLAUDE_SKILL_DIR}/tests/events/` - Event emission and delivery integration tests

## Error Handling

| Error | Cause | Solution |
|-------|-------|----------|
| Event lost on crash | Application crashes between database commit and event publish | Use transactional outbox pattern: write event to outbox table in same transaction, poll and publish separately |
| Webhook delivery failure | Subscriber endpoint unreachable or returns non-2xx | Retry with exponential backoff; deactivate subscription after 5 consecutive failures; notify subscriber admin |
| Event ordering violation | Concurrent mutations publish events out of order | Use partition keys (resource ID) for ordered delivery within a partition; accept out-of-order across partitions |
| SSE connection memory leak | Server accumulates stale SSE connections without cleanup | Implement heartbeat comments (`:keepalive\n\n`) every 15 seconds; detect and close dead connections |
| Schema version mismatch | Consumer expects v1 event format but receives v2 | Include `version` field in event envelope; support simultaneous v1/v2 delivery; deprecate old versions with notice |

Refer to [`references/errors.md`](references/errors.md) for comprehensive error patterns.

## Examples

**Order lifecycle events**: Emit `order.created`, `order.payment_received`, `order.shipped`, and `order.delivered` events with order details, enabling downstream services (warehouse, email, analytics) to react asynchronously.

**SSE live notifications**: Browser client connects to `GET /events/stream?types=message.received,order.updated` and receives real-time event updates with automatic reconnection and `Last-Event-ID` replay on network interruption.

**Transactional outbox**: Write the event record to an `outbox` table within the same database transaction as the API mutation, then poll the outbox table every 100ms to publish events to Kafka, ensuring at-least-once delivery.

See [`references/examples.md`](references/examples.md) for additional examples.

## Resources

- CloudEvents specification: https://cloudevents.io/
- Server-Sent Events (MDN): https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events
- Transactional outbox pattern: Microservices.io
- Webhook best practices: Standard Webhooks specification

© Jeremy Longshore · MIT · jeremylongshore/tons-of-skills-marketplace

Similar skills

All skills for Backend and APIs →

From the same set139

The whole set →
openrouter-streaming-setup openrouter-streaming-setup — a skill for Claude Code, Codex, Cursor and other platforms that implements streaming responses from OpenRouter via Server-Sent Events. CX Codex +1 1installs evernote-core-workflow-a evernote-core-workflow-a — a skill for Claude Code and five other platforms that covers the primary Evernote workflow: note creation, notebook organisation, and tag management. Handles CRUD operations, ENML formatting, and notebook stacks. CX Codex +1 1installs backlog-grooming-assistant backlog-grooming-assistant automates backlog grooming workflows, guides task refinement, and validates project management configurations. CX Codex +1 1installs long-polling-handler An auto-activating skill for long polling handler work in API integrations, with step-by-step guidance, generated code and configuration checks. CX Codex +1 1installs maintainx-webhooks-events maintainx-webhooks-events configures MaintainX webhook ingestion and work order event handlers in Express. Useful when connecting maintenance status changes to external systems. CX Codex +1 1installs lindy-webhooks-events The lindy-webhooks-events skill guides setup of Lindy AI webhook triggers and application callbacks. Use it to define event contracts, validate requests, and handle retries in a Lindy integration. CX Codex +1 1installs fireflies-webhooks-events fireflies-webhooks-events walks an agent through building a Fireflies Webhooks V2 receiver: raw-body HMAC check, event allowlisting, dedupe, and a 2xx reply fast enough for the 10-second window. CX Codex +1 1installs documenso-webhooks-events documenso-webhooks-events configures Documenso webhook endpoints and event handlers. Useful when tracking document signing status and automating downstream actions. CX Codex +1 1installs

Project sponsors

Companies that keep this analytics open