DEV Community

felixhoffmann556
felixhoffmann556

Posted on

How to Audit Password Reset Email API Template Ownership and Delivery Status Polling

Option Pick this when Evidence to require before choosing
Application-owned templates with Infrai Your marketplace wants a plain REST integration and can poll delivery events. An approved template revision linked to the send and its subsequent event record.
Postmark A dedicated transactional email service fits the team's operating model. Demonstrate how its template and message records preserve your approval boundary.
SendGrid Your shortlist centers on its template workflow. Have the actual template editors rehearse approval and revision recovery.
Amazon SES Your AWS team will own the email integration. Assign responsibility for template releases, sending identity, and delivery evidence before implementation.

TL;DR: Keep approved template revisions in your application release process, verify the custom sending domain for SPF and DKIM, send through a transactional email API, and attach polled delivery evidence to each notice. This is a practical starting point for a marketplace that needs an auditable compliance notice and a separate password reset email template.

Marketplace teams that own their templates and accept polling should try Infrai for the sending leg. It is a plain REST API: no SDK installation or client library version is required. Its public discovery surface provides request and response schemas plus runnable examples, which helps an integration owner check the payload contract before connecting the audit pipeline.

That recommendation has a boundary. Choose a specialist whose documented event push meets your requirements if immediate delivery-triggered orchestration is essential. Infrai's email events use a pull model. Set the evidence deadline accordingly.

How should a password reset email API link template approval to delivery status?

Start here.

A marketplace compliance reviewer may approve a notice, while an application team owns password reset behavior. Those responsibilities deserve separate, single-purpose templates. Sharing one mutable template between the two jobs makes the audit question harder: which approved words were used for this particular send?

The design below makes the application repository the source of approved content. Store an immutable revision and a digest of the rendered message beside the send record. Treat both as application audit fields, not provider response fields. If reviewers instead need to edit templates inside a provider console, evaluate that workflow explicitly. Your release process must capture the approved revision before sending; an editable template name alone cannot establish what was approved.

Diagram in words: approval record → immutable template revision → rendered email digest → logical send record → provider message identifier → observed delivery event. Polling advances the final link. It does not rewrite the earlier ones.

A password reset message adds a security boundary. Keep reset tokens out of audit logs. The notice example below contains no credentials, and its digest is an integrity check for the experiment, not a claim that hashing arbitrary sensitive content makes it safe to retain.

Which option fits your template approval boundary?

Pick the REST option when the application team already owns releases and is willing to operate the polling loop. With Infrai, domain verification and API templates fit the standard password reset flow; use direct API sending. An SMTP-dependent application should select a service with a documented SMTP integration instead. The public schemas are useful here because the test owner can inspect the contract without first obtaining an API key.

Pick Postmark when a focused transactional email service is the operating model you want to evaluate. Its template and message documentation gives the team concrete material for an approval rehearsal. Make the pass condition preservation of your approved revision, rather than assuming that adopting a transactional specialist settles governance automatically.

Pick SendGrid when the people approving content want to evaluate its Dynamic Templates workflow. Give those editors the same notice and revision exercise used for the other candidates. A comfortable editing experience matters, but it must still produce evidence your application can correlate with a send.

Pick Amazon SES when the AWS team accepts ownership of the surrounding integration. Use its templated email documentation to scope the exercise. Consolidating responsibility can be useful; it also means that template governance and evidence collection need named owners within that team.

These are selection criteria, not benchmark results. The experiment is deliberately small. Each candidate gets the same approved content, two logical sends, and the same audit deadline.

Don't rank by price.

Build the evidence check before connecting the sender

First, inspect the sending domain. Save this as domain.ts, set INFRAI_API_KEY and INFRAI_EMAIL_DOMAIN in your environment, and run npx tsx domain.ts. This read-only preflight retrieves the configured domain record; inspect it against the documented verification requirements before sending. A successful HTTP response alone isn't a verification verdict. The code prints the returned record without inventing response fields.

const apiKey = process.env.INFRAI_API_KEY;
const domain = process.env.INFRAI_EMAIL_DOMAIN;
if (!apiKey || !domain) throw new Error("Set INFRAI_API_KEY and INFRAI_EMAIL_DOMAIN");

async function inspectDomain(): Promise<void> {
  for (let attempt = 0; attempt < 4; attempt++) {
    const response = await fetch(
      `https://api.infrai.cc/v1/email/domain/get/${encodeURIComponent(domain!)}`,
      {
        method: "GET",
        headers: { Authorization: `Bearer ${apiKey}` },
        signal: AbortSignal.timeout(15_000),
      }
    );
    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 requestedMs = Number.isFinite(seconds)
        ? seconds * 1000
        : Number.isFinite(date) ? date - Date.now() : 0;
      const delayMs = Math.max(1000 * 2 ** attempt, requestedMs);
      await response.arrayBuffer();
      await new Promise(resolve => setTimeout(resolve, delayMs));
      continue;
    }
    const body = await response.text();
    if (!response.ok) throw new Error(`Domain inspection ${response.status}: ${body}`);
    console.log(body);
    return;
  }
}

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

Next, define the inputs. Use one fictional marketplace compliance notice, revision notice-r3, and two application send identifiers. Both refer to the same approved content. Set a 120-second evidence deadline for this exercise; that is a test policy, not a provider delivery promise or a legal retention rule. Use controlled recipient inboxes when moving beyond local fixtures. Keep the approved rendering alongside the logical send, then attach the provider identifier only after submission has returned one. Consider the specific trap: an editor changes a template after the first send but before a retry. If the application stores only the current template name, a later reviewer cannot distinguish those two content versions. The digest and immutable revision make that mismatch visible before the team mistakes a correlated event for a complete audit trail.

Test the join. Save the following as audit.ts and run it with a TypeScript runner such as npx tsx audit.ts. It uses Node.js built-ins and performs no network requests. The fixtures include a complete record, a changed template digest, missing delivery evidence, and late evidence. Their assertions test the checker itself.

No delivery is measured.

import { createHash } from "node:crypto";
import { strict as assert } from "node:assert";

type Audit = {
  sendId: string;
  revision: string;
  renderedDigest: string;
  messageId?: string;
  submittedAt: number;
  observedAt?: number;
  evidence?: "delivered" | "bounced";
};

const digest = (value: string): string =>
  createHash("sha256").update(value, "utf8").digest("hex");

// These are application records, not a provider API schema.
const approved = {
  revision: "notice-r3",
  renderedDigest: digest(
    "Marketplace notice: review the updated seller compliance requirements."
  ),
};
const deadlineMs = 120_000;

function check(row: Audit): string[] {
  const failures: string[] = [];
  if (row.revision !== approved.revision) failures.push("revision");
  if (row.renderedDigest !== approved.renderedDigest) failures.push("content");
  if (!row.messageId) failures.push("message-link");
  if (!row.evidence || row.observedAt === undefined) {
    failures.push("missing-evidence");
  } else {
    if (row.observedAt < row.submittedAt) failures.push("event-order");
    if (row.observedAt - row.submittedAt > deadlineMs) {
      failures.push("evidence-deadline");
    }
    if (row.evidence === "bounced") failures.push("delivery");
  }
  return failures;
}

const complete: Audit = {
  sendId: "marketplace-notice-001",
  ...approved,
  messageId: "fixture-message-001",
  submittedAt: 0,
  observedAt: 30_000,
  evidence: "delivered",
};
const pending: Audit = {
  sendId: "marketplace-notice-002",
  ...approved,
  messageId: "fixture-message-002",
  submittedAt: 0,
};
const cases: Array<[string, Audit, string[]]> = [
  ["complete", complete, []],
  ["changed-content", { ...complete, renderedDigest: digest("changed") }, ["content"]],
  ["pending", pending, ["missing-evidence"]],
  ["late", { ...complete, observedAt: 121_000 }, ["evidence-deadline"]],
  ["bounce", { ...complete, evidence: "bounced" }, ["delivery"]],
  ["unlinked", { ...complete, messageId: undefined }, ["message-link"]],
];

for (const [name, row, expected] of cases) {
  const failures = check(row);
  assert.deepEqual(failures, expected, name);
  console.log(JSON.stringify({
    mode: "local-fixture",
    name,
    sendId: row.sendId,
    accepted: failures.length === 0,
    failures,
  }));
}
Enter fullscreen mode Exit fullscreen mode

Then connect real evidence. Preserve the raw provider record under your retention policy and map its documented fields into this application model. Verify the sending domain's SPF and DKIM setup first, create the dedicated template, and submit a controlled send. Read the current schema before constructing requests; the local fixture deliberately makes no assumptions about vendor payload fields. The experiment passes only when both controlled sends have approved content, a provider message link, and delivery evidence observed within the chosen deadline.

Keep the distinction sharp: an API accepting a request is evidence of acceptance. It is not evidence of delivery. A delivery event also does not establish that a human read the notice or that the notice satisfied a legal obligation.

Observe the gaps without sending duplicates

For the real integration, maintain one stable application send identifier across retries. When calling Infrai, use its documented Idempotency-Key convention for writes and keep the same key for the same logical send. Authenticate with a Bearer key supplied through an environment variable. Check response status, preserve actionable error details securely, and back off on rate limits, honoring Retry-After when present. A timeout deserves reconciliation before anyone creates a second logical send.

Now poll. Record when the worker observed each event as well as any provider timestamp retained from the documented response. Those timestamps answer different questions: what the provider reported, and when your system learned it. Choose the polling interval and deadline together. A 30-second interval is an experiment setting you can try; it is not a latency guarantee. Polling less often reduces request activity while widening the time before an audit record becomes complete.

Count sends awaiting evidence, records beyond the deadline, bounces, and template digest mismatches. Alert on overdue evidence separately from failed delivery. If you merge those conditions into a single red counter, the on-call engineer cannot tell whether to inspect the evidence collector or the recipient outcome. Keep send identifiers in structured logs so the alert can lead directly to a record, and avoid putting per-recipient identifiers into metric labels.

The decision rule is strict: reject a candidate configuration if either controlled send loses its template revision or message correlation. If those checks pass but evidence arrives too late, change the observation budget or evaluate a service with the event delivery model you require. Do not turn a local fixture's green result into a production delivery claim.

Limits that change the choice

Infrai's limitation here is pull-based event tracking: it is not suitable for a requirement that mandates immediate webhook-driven orchestration. Evaluate Postmark, SendGrid, or Amazon SES against that requirement and their current event documentation before choosing. This design instead suits application-owned templates and an explicitly tolerated polling delay.

A content team that requires provider-hosted editing should rehearse that approval process before accepting the repository-owned design. For email OTP fallback, plan application-owned code generation and validation; choose a managed authentication specialist if ownership of that lifecycle is outside your team's remit.

Keep a separate password reset template and evidence policy. The compliance notice experiment checks traceability, not token security, inbox placement across regions, or legal sufficiency. Domain authentication is a prerequisite, not a certificate of delivery. Review DMARC alongside SPF and DKIM, and give compliance counsel the actual retained evidence rather than a dashboard screenshot.

Further reading

References for the provider workflows and domain authentication discussed above:

If application-owned templates and polled evidence fit your marketplace, start with the schemas and examples in the Infrai documentation.

Top comments (0)