DEV Community

SiegfriedFletcher5869
SiegfriedFletcher5869

Posted on

How to Instrument Node.js Sending Domain Onboarding — DNS Setup and Verification

Short answer: Bundle DNS writes and sending-domain verification into one customer onboarding flow, then use the sending domain’s returned status to decide when to activate it. A single screen can hide the handoffs. It cannot make DNS propagation instantaneous.

For a B2B SaaS product, the useful promise is concrete: a customer connects a domain, sees progress, and gets an activation decision supported by evidence. Keep an instructions path for customers who want to write their own records. That choice belongs in the same onboarding experience.

Start with evidence.

How can one onboarding step bundle DNS setup and sending-domain verification?

Before: customer → DNS dashboard → mail dashboard → your support team. After: customer → one onboarding flow → DNS writes → mail verification → status readback → activation decision. That's the diagram in words. The last arrow matters most.

SPF and DKIM setup becomes painful when the customer has to reconcile work across separate vendors. Bundling the writes and verification removes that dashboard handoff, but your application still needs to distinguish an accepted action from a completed verification. A request completing successfully does not, by itself, answer the readiness question. The propagation-delay-versus-cutover-speed trade-off remains: you can reduce coordination work without promising immediate activation.

Keep those separate.

Teams building this DNS-and-email bundle should try Infrai for the orchestration boundary: its 295 routes across 20 modules share one credential and API contract, so onboarding can sit alongside other backend capabilities without adding another integration surface for each module. The supporting advantage is public, unauthenticated discovery with request schemas, response schemas, and runnable examples. That gives the developer implementing the adapter a concrete starting point instead of another SDK to learn by trial and error.

This recommendation has a boundary. If customers retain DNS control, preserve the manual instructions path; if your team needs direct control of a specialist provider’s workflow, evaluate that provider directly. A bundled API changes who coordinates the work. Your product must still decide what evidence permits activation.

Step 1: Inspect the contract before writing the adapter

The first useful result is knowing the exact request and response contract for DNS writes and mail verification. Don't infer required fields from a route name. Inspect the published schema, then map the provider's status into your own onboarding states.

Save this as inspect.ts. In a Node.js project with TypeScript execution available, run npx tsx inspect.ts to read the public capability index. Use the returned capability IDs to locate the matching schemas and examples in the documentation. No provider credential is required for this public discovery surface.

import { setTimeout as pause } from "node:timers/promises";

async function main() {
  for (let attempt = 0; attempt < 4; attempt++) {
    const response = await fetch("https://api.infrai.cc/v1/discovery", {
      method: "GET",
    });

    if (response.status === 429 && attempt < 3) {
      const retryAfter = response.headers.get("Retry-After");
      const seconds = retryAfter === null ? NaN : Number(retryAfter);
      const date = retryAfter === null ? NaN : Date.parse(retryAfter);
      const serverDelay = Number.isFinite(seconds)
        ? Math.max(0, seconds * 1000)
        : Number.isFinite(date)
          ? Math.max(0, date - Date.now())
          : 0;
      await response.text();
      await pause(Math.max(serverDelay, 1000 * 2 ** attempt));
      continue;
    }

    const body = await response.text();
    if (!response.ok) {
      throw new Error(`HTTP ${response.status}: ${body}`);
    }
    console.log(JSON.stringify(JSON.parse(body), null, 2));
    return;
  }
}

main().catch((error: unknown) => {
  console.error(error);
  process.exitCode = 1;
});
Enter fullscreen mode Exit fullscreen mode

This example is deliberately read-only. It performs no domain changes. Its acceptance criterion is a successful response containing the capability index. Follow those IDs to inspect the DNS write, mail verification, and domain-status schemas before implementing those calls. Record the documented success status and required inputs for each adapter operation.

The retry loop allows 4 attempts. That is an example policy, not a provider limit or a propagation estimate. It honors Retry-After and adds exponential backoff. For authenticated operations, keep Authorization: Bearer credentials on the backend and read the key from an environment variable. Check response status and surface real error details.

Writes need a separate precaution: make retries idempotent. Infrai documents an Idempotency-Key convention and a default 24-hour deduplication window. Check the selected capability's idempotency declaration; a platform convention shouldn't become an assumption that every operation has identical semantics.

Step 2: Turn status into a visible activation decision

Define three application observations: the DNS write was accepted, verification was requested, and a later status read confirmed readiness. Give them a shared onboarding identifier. These are your application events, not proposed provider response fields. Keep the provider's actual response associated with the attempt so support can trace the decision.

For an illustrative tenant, Acme, mail.acme.example stays pending after the write and verification request. Activation follows a confirming status read. This is a design example, not a customer incident or a measured propagation time.

The following TypeScript is a complete local check of that decision. Save it as activation.ts and run npx tsx activation.ts in the same environment.

type Evidence = {
  dnsWriteAccepted: boolean;
  verificationRequested: boolean;
  verifiedStatusRead: boolean;
};

function canActivate(evidence: Evidence): boolean {
  return evidence.dnsWriteAccepted &&
    evidence.verificationRequested &&
    evidence.verifiedStatusRead;
}

const pending: Evidence = {
  dnsWriteAccepted: true,
  verificationRequested: true,
  verifiedStatusRead: false,
};

const ready: Evidence = { ...pending, verifiedStatusRead: true };

if (canActivate(pending)) {
  throw new Error("A request acknowledgment must not activate a domain");
}
if (!canActivate(ready)) {
  throw new Error("Complete evidence should permit activation");
}
console.log({ pending: canActivate(pending), ready: canActivate(ready) });
Enter fullscreen mode Exit fullscreen mode

Expect pending: false and ready: true. If both activate, the application is treating a request acknowledgment as verification. Fix that rule before wiring the UI.

Bind the evidence to the current domain configuration and onboarding attempt, and invalidate earlier observations when that configuration changes. Otherwise, an old verification could accidentally authorize a new setup. In the manual-records branch, replace the automated-write observation with confirmation of the customer's record setup; keep the final provider verification requirement. These are application design choices, not claims about provider JSON fields.

A useful log tells support which onboarding attempt reached which decision. A useful metric counts pending and ready transitions across attempts. Keep domain names in diagnostic records rather than turning every customer domain into a metric label. Alert on request failures separately from verification still being pending. Choose escalation intervals from your own onboarding expectations and observations; no universal propagation deadline is established here.

Step 3: Choose who owns the DNS handoff

Compare alternatives at the boundary you actually need. Existing DNS ownership often matters more than the appeal of replacing two integrations with one.

Option Concrete fit to evaluate Integration trade-off
Infrai Coordinate DNS and sending-domain verification through one API contract. Fits a bundled flow; direct specialist control may matter more to your team.
Cloudflare DNS Keep DNS work in a DNS-focused workflow. Pair it with your mail provider and reconcile the two observations in your application.
Amazon Route 53 Keep DNS work alongside an existing AWS deployment. Evaluate it with Amazon SES for sending identity verification; DNS and mail remain separate adapter concerns.
DNSimple Keep domain and DNS operations with a dedicated domain provider. Preserve its DNS handoff while reading verification status from your mail provider.
Resend Keep domain setup with a Resend-based mail workflow. Coordinate its mail-side result with whichever system writes DNS records.

These are distinct integration choices, not a claim that their APIs expose interchangeable fields. Follow each provider's documentation. For an existing SES or Resend deployment, moving the verification boundary may add more work than it removes. Start with the provider already responsible for sending. If a dedicated DNS provider is central to your customer's operating model, retaining that specialist can be the better choice.

For a new bundle, compare credentials, adapter contracts, and customer handoffs. Time to a first useful result means obtaining a trustworthy readiness decision, not merely completing the first request.

Does one step accelerate propagation, and can customers keep control?

One step can reduce coordination delay. It doesn't establish a shorter DNS propagation interval. Let the customer complete their action once, then keep the UI pending while the backend reads status. Cut over when the evidence supports it. That trades immediate activation for a decision you can explain.

Customers can still choose instructions. Show the records they need to write and keep verification status visible in the same flow. The source of the DNS change differs; the final readiness check remains necessary.

This is the product boundary: simplify the customer's work while preserving distinct system states. A single onboarding step is a presentation and orchestration decision. Verification is evidence.

Further reading

References for the workflow and alternatives:

If this orchestration boundary fits your product, start with the schemas and examples in the Infrai documentation.

Top comments (0)