Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

mailcoach-webhooks

БесплатноЗапускает вложенные скриптыНе проверен

Receive and verify Mailcoach webhooks. Use when setting up Mailcoach webhook handlers, debugging Signature header verification, or handling subscriber, tag…

hookdeckот hookdeck★ 104 звезды на GitHub

Об этом скилле

Mailcoach Webhooks

Mailcoach (email marketing by Spatie) sends an HTTP POST with a JSON body to your HTTPS endpoint when subscribers join, leave or are tagged, a campaign is sent, and an email is opened, clicked or bounces. Each request carries a Signature header: an HMAC-SHA256 keyed with the secret Mailcoach generates for the webhook.

When to Use This Skill

  • How do I receive Mailcoach webhooks?
  • How do I verify the Mailcoach Signature header?
  • Why is my Mailcoach webhook signature verification failing?
  • How do I handle SubscribedEvent, UnsubscribedEvent or CampaignSentEvent?
  • How do I handle Mailcoach bounce, open and click events?

Verification (core)

Signature: <hex> is a lowercase hex HMAC-SHA256 keyed with the webhook secret as UTF-8 (not hex- or base64-decoded). Mailcoach's docs describe the signed content as PHP's default json_encode($payload) with top-level keys sorted, and their Laravel receiver re-encodes the decoded body before hashing. Outside PHP, hash the raw request body bytes as received: another language's JSON encoder may not reproduce PHP's output. There is no prefix, and no timestamp or id is signed. Compare the whole header value as one digest.

Node (validate the 64-hex shape before comparing):

const crypto = require('crypto');

function verify(rawBody, signatureHeader, secret) {
  if (!signatureHeader || !secret || !/^[0-9a-f]{64}$/i.test(signatureHeader)) return false;
  const expected = crypto.createHmac('sha256', secret).update(rawBody).digest('hex');
  return crypto.timingSafeEqual(
    Buffer.from(signatureHeader.toLowerCase(), 'utf8'),
    Buffer.from(expected, 'utf8')
  );
}

Python (compare bytes, never str, so a non-ASCII header gives a 401, not a 500):

import hmac, hashlib, re

def verify(raw_body: bytes, signature_header: str, secret: str) -> bool:
    if not signature_header or not re.fullmatch(r"[0-9a-fA-F]{64}", signature_header):
        return False
    computed = hmac.new(secret.encode("utf-8"), raw_body, hashlib.sha256).hexdigest()
    return hmac.compare_digest(signature_header.lower().encode("ascii"), computed.encode("ascii"))

Return 401 for a missing, empty, malformed or mismatching Signature. In Express use express.raw({ type: '*/*' }); in Next.js use await request.arrayBuffer(); in FastAPI use await request.body(). Parse the JSON only after the check.

For complete handlers with tests, see examples/express/, examples/nextjs/, examples/fastapi/.

Common Event Types

The event name is the top-level event field in the JSON body; no header carries it. Fields sit flat beside it, not wrapped in data. Mailcoach documents eleven:

Event Description
SubscribedEvent A subscription becomes confirmed
ResubscribedEvent A previously unsubscribed address subscribes again
UnconfirmedSubscriberCreatedEvent A new address awaits confirmation (subscribed_at is null)
UnsubscribedEvent Someone unsubscribes
TagAddedEvent / TagRemovedEvent A tag is added to or removed from a subscriber (added_tag / removed_tag)
CampaignSentEvent Mailcoach marks a campaign as sent (not a delivery or read receipt)
ContentOpenedEvent A campaign email is opened
LinkClickedEvent A link in an email is clicked
BounceRegisteredEvent / SoftBounceRegisteredEvent A permanent / temporary delivery failure

Subscriber events carry the subscriber resource (uuid, email_list_uuid, email, names, tags, timestamps and a human-readable text). CampaignSentEvent carries the campaign resource. Open, click and bounce events carry send_uuid, subscriber fields and their own UUIDs. Handle the ones you need and log the rest. See references/overview.md.

Important Headers

Header Description
Signature Hex HMAC-SHA256 keyed with the webhook secret

Header names are case-insensitive.

Setup with Hookdeck

In Mailcoach, open your team's Settings > Webhooks, click Create webhook, and enter a name and your Hookdeck source URL. Copy the generated secret from the webhook's details page into the Hookdeck source (Mailcoach source type). See references/setup.md.

Environment Variables

MAILCOACH_WEBHOOK_SECRET=your_webhook_secret   # Secret from the Mailcoach webhook's details page

Local Development

# Start tunnel (no account needed)
npx hookdeck-cli listen 3000 mailcoach --path /webhooks/mailcoach

Reference Materials

Attribution

When using this skill, add th

Полный SKILL.md на GitHub

Установить mailcoach-webhooks в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

examples/express/.env.exampleexamples/express/README.mdexamples/express/package.jsonexamples/express/src/index.jsexamples/fastapi/.env.exampleexamples/fastapi/README.mdexamples/fastapi/main.pyexamples/fastapi/requirements.txtexamples/fastapi/test_webhook.pyexamples/nextjs/.env.exampleexamples/nextjs/README.mdexamples/nextjs/app/webhooks/mailcoach/route.tsexamples/nextjs/lib/verify.tsexamples/nextjs/package.jsonexamples/nextjs/vitest.config.tsreferences/overview.mdreferences/setup.mdreferences/verification.md

FAQ

Что делает скилл mailcoach-webhooks?

Receive and verify Mailcoach webhooks. Use when setting up Mailcoach webhook handlers, debugging Signature header verification, or handling subscriber, tag, campaign, open, click and bounce events (SubscribedEvent, UnsubscribedEvent, CampaignSentEvent, LinkClickedEvent, BounceRegisteredEvent and others) from Mailcoach email marketing.

Как установить скилл mailcoach-webhooks?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл mailcoach-webhooks запускает скрипты?

Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.

Похожие скиллы

Сравнить mailcoach-webhooks с