Command Palette

Search for a command to run...

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

postmark-webhooks

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

Receive and process Postmark webhooks. Use when setting up Postmark webhook handlers, handling email delivery events, processing bounces, opens, clicks, spam…

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

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

Postmark Webhooks

When to Use This Skill

  • Setting up Postmark webhook handlers for email event tracking
  • Processing email delivery events (bounce, delivered, open, click)
  • Handling spam complaints and subscription changes
  • Implementing email engagement analytics
  • Troubleshooting webhook authentication issues

Essential Code

Authentication

Postmark does NOT use signature verification. Instead, webhooks are authenticated with credentials you configure on the webhook: Basic Auth or a token in the URL (shown below), or a custom header set with HttpHeaders (see references/verification.md).

// Express - Basic Auth in URL
// Configure webhook URL in Postmark as:
// https://username:[email protected]/webhooks/postmark

app.post('/webhooks/postmark', express.json(), (req, res) => {
  // Basic auth is handled by your web server or proxy
  // Additional validation can check expected payload structure

  const event = req.body;

  // Validate expected fields exist (Inbound payloads have no RecordType).
  // SubscriptionChange can have MessageID: null, and a 4xx makes Postmark drop the event.
  const recordType = event.RecordType || (event.FromFull ? 'Inbound' : undefined);
  if (!recordType || (recordType !== 'SubscriptionChange' && !event.MessageID)) {
    return res.status(400).send('Invalid payload structure');
  }

  // Process event
  console.log(`Received ${event.RecordType || 'Inbound'} event for message ${event.MessageID}`);

  res.sendStatus(200);
});

// Alternative: Token in URL
// Configure webhook URL as:
// https://yourdomain.com/webhooks/postmark?token=your-secret-token

app.post('/webhooks/postmark', express.json(), (req, res) => {
  const token = req.query.token;
  const expectedToken = process.env.POSTMARK_WEBHOOK_TOKEN;

  // Fail closed: never accept a request when no token is configured
  if (!expectedToken || token !== expectedToken) {
    return res.status(401).send('Unauthorized');
  }

  const event = req.body;
  console.log(`Received ${event.RecordType || 'Inbound'} event`);

  res.sendStatus(200);
});

Handling Multiple Events

// Postmark sends one event per request (not batched)
app.post('/webhooks/postmark', express.json(), (req, res) => {
  const event = req.body;

  // Inbound webhooks have no RecordType, so identify them by FromFull
  const recordType = event.RecordType || (event.FromFull ? 'Inbound' : undefined);

  switch (recordType) {
    case 'Bounce':
      console.log(`Bounce: ${event.Email} - ${event.Type} - ${event.Description}`);
      // Update contact as undeliverable
      break;

    case 'SpamComplaint':
      console.log(`Spam complaint: ${event.Email}`);
      // Remove from mailing list
      break;

    case 'Open':
      console.log(`Email opened: ${event.Recipient} at ${event.ReceivedAt}`);
      // Track engagement
      break;

    case 'Click':
      console.log(`Link clicked: ${event.Recipient} - ${event.OriginalLink}`);
      // Track click-through rate
      break;

    case 'Delivery':
      console.log(`Delivered: ${event.Recipient} at ${event.DeliveredAt}`);
      // Confirm delivery
      break;

    case 'SubscriptionChange':
      console.log(`Subscription change: ${event.Recipient} - ${event.ChangedAt}`);
      // Update subscription preferences
      break;

    case 'Inbound':
      console.log(`Inbound email from: ${event.From} - Subject: ${event.Subject}`);
      // Process incoming email
      break;

    default:
      console.log(`Unknown event type: ${recordType}`);
  }

  res.sendStatus(200);
});

Common Event Types

Event RecordType Description Key Fields
Bounce Bounce Hard/soft bounce, transient failure or block Email, Type, TypeCode, Description
Spam Complaint SpamComplaint Recipient marked as spam Email, BouncedAt
Open Open Email opened (requires open tracking) Recipient, ReceivedAt, Platform, UserAgent
Click Click Link clicked (requires click tracking) Recipient, ReceivedAt, OriginalLink
Delivery Delivery Successfully delivered Recipient, DeliveredAt, Details
Subscription Change SubscriptionChange Unsubscribe/resubscribe Recipient, ChangedAt, SuppressionReason
Inbound None Incoming email received From, FromFull, Subject, TextBody, HtmlBody

Inbound payloads have no RecordType, so identify them by FromFull. Postmark also documents SMTP API Error notifications (enabled per server with EnableSmtpApiErrorHooks) but not their payload or RecordType; its Bounce API lists SMTPApiError (TypeCode 100007) as a bounce type. Log one before you rely on its fields.

Don't deduplicate on MessageID alone: one email produces several events (a Delivery per recipient, Opens, a Click per link) with the same MessageID. Use the X-PM-Webhook-Trace-Id header, which stays the same across retries of one event.

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

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

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

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

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

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

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

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

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

TODO.mdexamples/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/postmark/route.tsexamples/nextjs/package.jsonexamples/nextjs/vitest.config.tsreferences/overview.mdreferences/setup.mdreferences/verification.md

FAQ

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

Receive and process Postmark webhooks. Use when setting up Postmark webhook handlers, handling email delivery events, processing bounces, opens, clicks, spam complaints, or subscription changes.

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

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

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

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

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

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