Cloudflare DNS logo
PostgreSQL logo

Workflow template

Keep a queryable mail DNS history in PostgreSQL

Store each observed change to MX, SPF or DMARC with the domain, timestamp and both configurations. A unique change ID makes replay safe.

How it works

Keep a queryable mail DNS history in PostgreSQL

1 Trigger · 1 Action
Cloudflare DNS1 · Trigger

Mail routing or authentication changed

Start when the observed MX, SPF or DMARC records differ from the previous check. The first check saves a baseline.

PostgreSQL2 · Action

Upsert the DNS audit row

Insert a row or update mapped columns when a unique key already exists. Use a stable key for repeatable delivery.

Before activation

Set up your workflow

  1. Create the audit table

    Create a table with change_id TEXT PRIMARY KEY, domain TEXT, previous TEXT, current TEXT and observed_at TIMESTAMPTZ. Grant the PostgreSQL connection the permissions needed for an upsert.

  2. Set the observation scope

    Select the Cloudflare zone and enter the full mail domain in the trigger. Its first successful poll saves a baseline. Map the database step to your audit table.

  3. Check replay behavior

    Change a mail record on a test domain after the baseline. Compare the previous and current values in PostgreSQL. Replaying the same change should still leave one row for its change ID.

Explore connected apps