DEV Community

FinnianFox8297
FinnianFox8297

Posted on

Delivery Evidence: How to Choose Welcome Email API Templates Without Webhooks

An e-commerce contact form needs two outcomes: put the order question in the right support queue and send a branded welcome acknowledgment. Choose its email API by checking custom templates and domain verification, then rehearsing what an operator can establish from polled delivery events. A US/EU app backend can use this approach when its acknowledgment workflow tolerates delayed visibility.

Short answer: require reliable API sends, template creation and updates, preview, and sender-domain verification. Accept polling without webhooks only when the business deadline leaves time to collect delivery evidence. Keep the support queue assignment and the email's delivery state separately inspectable.

Start with a proposed page: “Welcome acknowledgment evidence overdue.” The operator opens contact order-question-42, sees its assigned orders queue, and finds an accepted send without a recorded delivery event. The page also shows when event collection last completed. This is a rehearsal, not a reported incident; all thresholds below are proposed application settings, not provider measurements.

Don't resend yet.

If collection is stale, the operator lacks current evidence. If collection is fresh, the message deserves investigation. If the contact has no queue assignment, support routing needs attention regardless of what happened to the email. A single red “email failed” indicator loses those distinctions and encourages duplicate acknowledgments.

Step 1: How should welcome email API delivery events trigger an alert without webhooks?

The earlier signal is loss of observation. Record the last completed event-collection cycle independently of the last send attempt. Advance it after processing the response successfully. Starting a timer or receiving an HTTP response is not enough to establish that delivery evidence reached application state.

Use three clocks: time since contact intake, time since send acceptance, and time since completed observation. They answer different questions. An accepted send starts the acknowledgment's evidence budget; it does not establish inbox delivery. Contact intake starts the routing budget. Observation freshness determines whether the other evidence is current enough to interpret.

The runbook should first resolve missing queue assignment, then examine observer freshness, and only then escalate overdue message evidence. Keep a separate observer-health alert even when every tracked acknowledgment already has a delivery event. Otherwise, a quiet period can hide a stopped collector until the next customer contact arrives.

An example budget makes the selection test concrete. Suppose the application polls every 30 seconds, allows 90 seconds for observation freshness, and investigates accepted acknowledgments after five minutes without delivery evidence. These values are hypotheses for a proof of concept. They do not establish a delivery guarantee, and a different support promise may require different settings or a different event contract.

The trade-off is operational: a shorter freshness allowance detects collection gaps earlier but also makes normal scheduler drift more likely to page someone. Decide which intervention a page should trigger before choosing its threshold.

Step 2: Rehearse the instrumentation before integrating a provider

First inspect the actual event response. Set INFRAI_BASE_URL to the versioned HTTPS API base supplied in your deployment configuration and INFRAI_API_KEY to your credential. Save this standalone probe as main.go and run go run main.go. It calls the email event-list operation and prints its response without inventing event fields. Compare the result with the operation's response schema before mapping anything into application state.

package main

import (
    "fmt"
    "io"
    "net/http"
    "os"
    "strconv"
    "strings"
    "time"
)

func main() {
    base := strings.TrimRight(os.Getenv("INFRAI_BASE_URL"), "/")
    key := os.Getenv("INFRAI_API_KEY")
    if !strings.HasPrefix(base, "https://") || key == "" {
        panic("set INFRAI_BASE_URL to the versioned HTTPS API base and INFRAI_API_KEY")
    }
    client := &http.Client{
        Timeout: 20 * time.Second,
        CheckRedirect: func(req *http.Request, via []*http.Request) error {
            return http.ErrUseLastResponse
        },
    }
    for attempt := 0; attempt < 4; attempt++ {
        req, err := http.NewRequest(http.MethodGet, base+"/email/event/list", nil)
        if err != nil { panic(err) }
        req.Header.Set("Authorization", "Bearer "+key)
        resp, err := client.Do(req)
        if err != nil { panic(err) }
        body, readErr := io.ReadAll(resp.Body)
        resp.Body.Close()
        if readErr != nil { panic(readErr) }
        if resp.StatusCode == http.StatusTooManyRequests && attempt < 3 {
            delay := time.Second * time.Duration(1<<attempt)
            retry := resp.Header.Get("Retry-After")
            if seconds, err := strconv.Atoi(retry); err == nil && seconds >= 0 {
                if d := time.Duration(seconds)*time.Second; d > delay { delay = d }
            } else if until, err := http.ParseTime(retry); err == nil {
                if d := time.Until(until); d > delay { delay = d }
            }
            time.Sleep(delay)
            continue
        }
        if resp.StatusCode < 200 || resp.StatusCode >= 300 {
            panic(fmt.Sprintf("event poll status %d: %s", resp.StatusCode, body))
        }
        fmt.Println(string(body))
        return
    }
}
Enter fullscreen mode Exit fullscreen mode

This read-only probe has bounded retries, backs off on rate limits, and honors a longer Retry-After delay. A successful response is the inspection checkpoint, not permission to mark an acknowledgment delivered. It makes no writes, so it cannot create a duplicate welcome email.

Save the following as main.go and run go run main.go. It is a complete local rehearsal using only the Go standard library. The records and signal names are application-owned examples, not email API request fields. No network access or credentials are needed.

The change being tested is specific: print observer age separately from message age, preserve a stable logical acknowledgment key, and give routing errors their own decision. Each case fails loudly if the runbook chooses the wrong action.

package main

import (
    "fmt"
    "time"
)

type Evidence struct {
    ContactID string
    Queue string
    TemplateRevision string
    DomainVerified bool
    AcceptedAt time.Time
    PollCompletedAt time.Time
    DeliveryObserved bool
}

func classify(e Evidence, now time.Time) string {
    if e.Queue == "" {
        return "repair_contact_routing"
    }
    if e.PollCompletedAt.IsZero() ||
        now.Sub(e.PollCompletedAt) > 90*time.Second {
        return "investigate_observer"
    }
    if e.DeliveryObserved {
        return "delivery_evidence_recorded"
    }
    if e.AcceptedAt.IsZero() {
        if !e.DomainVerified || e.TemplateRevision == "" {
            return "hold_for_sender_or_template_review"
        }
        return "inspect_send_dispatch"
    }
    if now.Sub(e.AcceptedAt) > 5*time.Minute {
        return "investigate_message_evidence"
    }
    return "await_next_poll"
}

func main() {
    now := time.Date(2026, time.November, 29, 12, 0, 0, 0, time.UTC)
    original := Evidence{
        ContactID: "order-question-42",
        Queue: "orders",
        TemplateRevision: "support-welcome-r3",
        DomainVerified: true,
        AcceptedAt: now.Add(-6 * time.Minute),
        PollCompletedAt: now.Add(-20 * time.Second),
    }
    cases := []struct {
        name string
        edit func(*Evidence)
        want string
    }{
        {"fresh observation", func(e *Evidence) {},
            "investigate_message_evidence"},
        {"stale observation", func(e *Evidence) {
            e.PollCompletedAt = now.Add(-2 * time.Minute)
        }, "investigate_observer"},
        {"unassigned contact", func(e *Evidence) {
            e.Queue = ""
        }, "repair_contact_routing"},
        {"recorded delivery", func(e *Evidence) {
            e.DeliveryObserved = true
        }, "delivery_evidence_recorded"},
        {"unverified sender", func(e *Evidence) {
            e.AcceptedAt = time.Time{}
            e.DomainVerified = false
        }, "hold_for_sender_or_template_review"},
        {"recent acceptance", func(e *Evidence) {
            e.AcceptedAt = now.Add(-time.Minute)
        }, "await_next_poll"},
    }
    for _, tc := range cases {
        e := original
        tc.edit(&e)
        got := classify(e, now)
        if got != tc.want {
            panic(fmt.Sprintf("%s: got %s, want %s", tc.name, got, tc.want))
        }
        logicalKey := e.ContactID + ":welcome"
        fmt.Printf("case=%q key=%q queue=%q observer_age=%s message_age=%s action=%s\n",
            tc.name, logicalKey, e.Queue,
            now.Sub(e.PollCompletedAt), now.Sub(e.AcceptedAt), got)
    }
}
Enter fullscreen mode Exit fullscreen mode

All six cases must complete without a panic. The unverified-sender case deliberately clears acceptance: the intended action is to hold dispatch for review. Its zero timestamp produces a diagnostic duration with no business meaning; production telemetry should represent an absent acceptance timestamp as missing rather than treat that duration as an overdue send.

This program decides what to inspect. It does not implement a durable send queue or deduplication store. In production, associate the stable logical key with one acknowledgment intent in durable application state. Retrying a worker must reuse that identity; generating a new key per attempt defeats deduplication. Retain the returned provider message identifier separately so the runbook can find evidence for the original attempt.

The pitfall is an ambiguous send outcome. A worker timeout does not tell you that the recipient received nothing. Reconcile the existing intent before authorizing a new send, and verify the chosen operation's idempotency contract. Do not convert the absence of a polled event into permission to send another welcome message.

Step 3: Attach template and domain evidence to the handoff

Now run the content review against the same synthetic contact. Create the branded welcome template, preview it with an order reference, update the support wording, and preview the revision again. Confirm the acknowledgment identifies the correct queue without promising that a support agent has already read the request. The acceptance criterion is rendered content that matches the routing decision, with the revision recorded beside the logical message intent.

Preview is necessary. It proves a different thing from delivery.

Next verify the sending domain using the candidate's documented process. Treat the result as a dispatch prerequisite and retain enough evidence to explain the decision later. A verified domain does not prove a particular message arrived, and a successful preview does not verify the sender. Keeping those checks distinct makes an incident review shorter: operators can establish what was approved before chasing delivery evidence.

The local rehearsal's template revision and domain flag show where those review outcomes enter the application's decision. They are not a replacement for running the provider's actual template and verification operations. Use the operation's published schema for that integration; the example deliberately makes no assumptions about request or event payload fields.

Own scheduling before dispatch when a contact can be withdrawn or reassigned. Keep the pending acknowledgment in application state until the decision to send is final, then submit it once using the same logical identity across retries. This workflow avoids depending on retracting a message after handing it off. For immediate automations driven by delivery or engagement, require evidence that the candidate's event contract can meet that deadline; polling is a good dashboard mechanism only when its observation delay is acceptable.

Step 4: Compare the operational handoff, then choose the API

Run the rehearsal before vendor selection, so the comparison has an acceptance test rather than a feature-count winner. Three direct integrations deserve consideration: Amazon SES, Twilio SendGrid, and Postmark. Their official documentation gives different starting points for evaluating the same welcome-email workflow. The following are review paths, not claims of measured delivery superiority.

For Amazon SES, start with its developer guide and evaluate the surrounding identity, template, and event configuration together. This is the natural candidate to investigate for an AWS-centered backend whose team wants to own that infrastructure. Include the event-consumption work in the proof of concept; sending alone does not satisfy the runbook.

For Twilio SendGrid, review Dynamic Templates, domain authentication, and Event Webhook documentation as one operational handoff. Its webhook-oriented documentation is useful when push events fit the backend. A polling-only application must establish a documented way to obtain the required evidence before adopting that design. A webhook feature on a checklist does not answer a no-webhooks requirement.

For Postmark, use the template, sender-signature, and delivery-webhook references to evaluate a transactional-email handoff. Confirm the evidence-retrieval path for a backend that cannot receive callbacks, and test it against the same freshness budget. The selection boundary is the event workflow the team can operate; this article establishes no ranking for inbox placement.

Infrai uses one key, one bill, and a single REST API with no SDK required. A single API key and unified billing cover 295 routes across 20 modules; for a contact-form worker that also owns scheduling, this reduces credential management. The stable capability contract lets the vendor behind a capability change without changing application code. Its public, self-describing discovery surface provides request and response schemas without a key, which helps a team review the handoff before wiring credentials into a worker. Template creation, updates, preview, domain verification, and polling of delivery and engagement events fit this welcome acknowledgment when delayed visibility is acceptable. Choose that abstraction for the contract and reviewability; choose a direct integration when the required provider-specific event behavior makes it easier to meet the runbook.

For a US/EU backend, keep API compatibility separate from residency and compliance review. Establish the selected provider's processing terms and regional configuration before claiming that a deployment meets a jurisdictional requirement. A working send request cannot establish that conclusion.

The decision is now narrow: approve a candidate only after the branded acknowledgment passes content and sender checks and its event path can populate the operator's evidence within the chosen budget. Pricing does not resolve a missing observation contract.

Step 5: Close the page without creating a second incident

Return to order-question-42. Routing already succeeded. With fresh observation and six minutes since acceptance, the proposed runbook investigates message evidence. With a stale collector, it investigates observation first. Neither condition automatically creates another email.

Keep that restraint.

The false-positive cost is concrete even without a benchmark: an overly tight freshness threshold spends on-call attention on scheduler drift, while an overly loose threshold leaves the dashboard looking useful after its evidence has aged out. A tight delivery-evidence threshold can also encourage manual resends while the original acknowledgment remains in flight. Record the triggering evidence, review unnecessary pages, and adjust the proposed budget using the application's own observations. Successful operation means the page points to a defensible action, with one contact in the right queue and one logical welcome acknowledgment to reconcile.

Further reading

References for the candidate review paths:

Top comments (0)