DEV Community

Vigilmon
Vigilmon

Posted on

How to Monitor Your Postmark Email Service with Vigilmon

How to Monitor Your Postmark Email Service with Vigilmon

Postmark is built for transactional email delivery with an emphasis on fast, reliable inbox placement. Used by developers who need password resets, welcome emails, and order confirmations to land in the inbox — not the spam folder — every time. This guide covers how to monitor your Postmark integration with Vigilmon to ensure email delivery never silently breaks.

Why Monitor Postmark?

Postmark is highly reliable, but your integration with it can still fail:

  • API token misconfiguration after environment changes or key rotation
  • Sender signature drift when your "From" domain changes
  • Message stream conflicts when transactional and broadcast limits are mixed
  • Template rendering failures from invalid Postmark template IDs or missing variables
  • Webhook endpoint failures causing unprocessed bounce and open events

Postmark API Health Check

1. Use the Server API Validation Endpoint

Postmark provides a server info endpoint that verifies your API token without sending emails:

import requests
from flask import Flask, jsonify

app = Flask(__name__)

POSTMARK_TOKEN = "your-server-api-token"

@app.route("/health/postmark")
def postmark_health():
    try:
        # Get server info - verifies token and server status
        response = requests.get(
            "https://api.postmarkapp.com/server",
            headers={
                "Accept": "application/json",
                "X-Postmark-Server-Token": POSTMARK_TOKEN
            },
            timeout=10
        )
        if response.status_code == 200:
            server = response.json()
            return jsonify({
                "status": "ok",
                "server_name": server.get("Name"),
                "delivery_type": server.get("DeliveryType")
            })
        return jsonify({"status": "error", "code": response.status_code}), 503
    except Exception as e:
        return jsonify({"status": "error", "message": str(e)}), 503
Enter fullscreen mode Exit fullscreen mode

2. Add a Sandbox Send Test (Optional)

Postmark supports a sandbox mode for staging environments:

@app.route("/health/postmark/send")
def postmark_send_health():
    try:
        # Use a test token for sandbox sends
        response = requests.post(
            "https://api.postmarkapp.com/email",
            headers={
                "Accept": "application/json",
                "Content-Type": "application/json",
                "X-Postmark-Server-Token": "POSTMARK_API_TEST"  # Test token
            },
            json={
                "From": "sender@example.com",
                "To": "recipient@example.com",
                "Subject": "Health check",
                "TextBody": "Health check email"
            },
            timeout=10
        )
        if response.status_code == 200:
            return jsonify({"status": "ok"})
        return jsonify({"status": "error"}), 503
    except Exception as e:
        return jsonify({"status": "error"}), 503
Enter fullscreen mode Exit fullscreen mode

3. Configure Vigilmon Monitor

  1. Sign in to vigilmon.onlineAdd Monitor
  2. Type: HTTP(S)
  3. URL: https://yourapp.com/health/postmark
  4. Interval: 5 minutes
  5. Timeout: 10 seconds
  6. Expected status: 200
  7. Add keyword check: "status":"ok"

Monitoring Bounce Webhooks

Postmark sends bounce notifications to your webhook endpoint. High bounce rates cause Postmark to automatically block your account. Monitor your bounce webhook endpoint with Vigilmon:

@app.route("/health/postmark/webhook")
def postmark_webhook_health():
    # Just confirm the endpoint is alive
    return jsonify({"status": "ok"})

@app.route("/webhooks/postmark/bounce", methods=["POST"])
def handle_bounce():
    data = request.json
    # Process bounce event
    return jsonify({"received": True}), 200
Enter fullscreen mode Exit fullscreen mode

Add /health/postmark/webhook to Vigilmon with a 1-minute check interval.

Delivery Rate Monitoring

Postmark's delivery rates are what you're ultimately paying for. Monitor via their Stats API:

import requests
from datetime import datetime, timedelta

def check_postmark_delivery_rate():
    yesterday = (datetime.utcnow() - timedelta(days=1)).strftime("%Y-%m-%d")
    response = requests.get(
        f"https://api.postmarkapp.com/stats/outbound?fromdate={yesterday}&todate={yesterday}",
        headers={"X-Postmark-Server-Token": POSTMARK_TOKEN}
    )
    stats = response.json()
    sent = stats.get("Sent", 0)
    delivered = stats.get("Delivered", 0)

    if sent > 0:
        delivery_rate = delivered / sent
        if delivery_rate < 0.95:
            # Alert! Delivery rate below 95%
            pass
Enter fullscreen mode Exit fullscreen mode

Run this check daily and surface results in your monitoring dashboard.

Sender Signature Monitoring

Postmark requires verified sender signatures. If a signature expires or is removed, emails from that sender fail. Monitor the Senders API to detect signature issues before they affect production:

response = requests.get(
    "https://api.postmarkapp.com/senders",
    headers={"X-Postmark-Account-Token": "your-account-token"}
)
senders = response.json().get("SenderSignatures", [])
unconfirmed = [s for s in senders if not s.get("Confirmed")]
Enter fullscreen mode Exit fullscreen mode

Conclusion

Postmark's high deliverability only helps if your integration is working. Set up Postmark monitoring with Vigilmon at vigilmon.online to catch integration failures before your users notice missing emails.

Top comments (0)