agentleFS
lettr-comlettr-com/lettr-skills/webhooks/SKILL.md

webhooks

Skill0 starsChanged 5 months agoMITView on GitHub

Use when setting up Lettr webhooks — registering an endpoint via the SDK/API and writing the handler that receives delivery/open/click/bounce events in the user's app. Covers auth (none/basic/oauth2), fast-ack + async processing, and idempotency.

15 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use data-pipelines, incident-response and 1 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • YepAPISkill

    data-pipelines

    ETL patterns, cron scheduling, queue-based processing, and batch jobs with Inngest/BullMQ.

    Also in 3 projects that use this

  • AnthropicSkill

    incident-response

    Run an incident response workflow — triage, communicate, and write postmortem. Trigger with "we have an incident", "production is down", an alert that needs severity assessment, a status update mid-incident, or when writing a blameless postmortem after resolution.

    Also in 3 projects that use this

  • OpenAISkill

    observability

    Vercel Observability expert guidance — Drains (logs, traces, speed insights, web analytics), Web Analytics, Speed Insights, runtime logs, custom events, OpenTelemetry integration, and monitoring dashboards. Use when instrumenting, debugging, or optimizing application performance and user experience on Vercel.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

1 rule. 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 12 edited versions we read keep these.

  • 0

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Create with name, url (HTTPS), auth_type, and events_mode:

    line 30

“Common” is measured: kept by at least 6 in 10 of the 12 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Lettr webhooks

Two halves: register a webhook endpoint with Lettr, and handle the events it posts to the user's app. The first is a few SDK calls; the second is where correctness actually lives.

1. Load the references

  • SDK calls (register/list/update/delete): detect the stack via ../_shared/detect-stack.md, then read ../_generated/sdk/<lang>/webhooks.md.
  • Wire contract: ../_generated/api/index.md, Webhooks section — note auth_type and events_mode are required on create.
  • Payload format, event types, retries: the live docs at https://docs.lettr.com/learn/webhooks (event-types, handling, retries).

⚠️ Payload shape — don't infer it from the registration names. Events arrive as a JSON array, each item wrapped by category:

for (const event of req.body) {           // array, not a single object
  const category = Object.keys(event.msys)[0];   // message_event | unsubscribe_event | relay_event | …
  const data = event.msys[category];
  if (data.type === 'delivery') { … }     // SHORT name, not the namespaced one you registered with
}

The type field carries the short name (delivery, bounce, open), never the <category>.<event> form used at registration. Fields sit directly on data (rcpt_to, transmission_id, bounce_class), not under a .data key.

2. Register the endpoint

Create with name, url (HTTPS), auth_type, and events_mode:

  • events_mode = all → every event, no events array.
  • events_mode = selected → an explicit events array (e.g. message.delivery, message.bounce, engagement.click). Subscribe only to what the handler uses.

3. Authentication — get this right

Lettr authenticates to the user's endpoint. There is no HMAC signature scheme — don't write signature-verification code. The mechanism is set at registration via auth_type:

auth_typeWhat Lettr sendsHandler must
nonenothingreject by other means (secret URL path, IP allowlist) — weakest
basicAuthorization: Basic …compare username/password to stored secrets, else 401
oauth2Authorization: Bearer …validate the token against the OAuth server, else 401

Credentials are configured in the dashboard and never returned by the API (the API only exposes auth_type + has_auth_credentials). Store the expected secrets in env/secret manager, never hardcoded.

4. Write the handler correctly

  • Verify auth first, before doing any work (see table above).
  • Ack fast, process async. Return 2xx immediately, then process events in the background (queue/setImmediate/job). Slow handlers cause timeouts → retries → duplicate processing.
  • Be idempotent. Lettr retries on non-2xx, so the same event can arrive more than once. Dedupe on the event id and make processing safe to repeat.
  • HTTPS only. Plaintext leaks credentials and payloads.

5. Verify it works

Trigger a real event (send a test email via the sending skill, or use the dashboard's webhook test if available) and confirm the handler receives it and returns 2xx. Check the webhook's last_status/last_failure_at (GET /webhooks/{id}) — a failing webhook shows up there.

What this skill does not do

  • It doesn't diagnose why an email bounced — that's diagnose (this skill just makes sure the events arrive).
  • It doesn't configure webhook credentials — those are set in the dashboard.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.