DEV Community

YannickSterling6563
YannickSterling6563

Posted on

Transactional Email API — 3 Marketplace Signup Handoffs Before Service Selection

Use a transactional email API for the marketplace signup link, and make account lookup, recipient eligibility, and verification completion explicit handoffs before choosing the provider. Integration effort is the deciding constraint: a short send request is useful, but it does not tell the platform team who owns an expired link, an ineligible recipient, or an SMS fallback that races with successful verification.

TL;DR: choose the service whose account-to-message handoff your team can operate with the least application glue. Keep verification state in the application, use a durable send intent with a stable retry identity, and judge success by completed verification within your chosen SLO. A send acknowledgment alone is insufficient evidence.

For a marketplace, the useful unit of work is one signup attempt that ends with an account verified or a clear next action. Comparing the cheapest transactional email service without defining that unit leaves out the integration work that this decision is supposed to reduce. No current, comparable email price evidence establishes a lowest-cost winner here.

What signal says the signup handoff needs attention?

Start with the gap between an accepted send and a verified account. If the first looks healthy while the second deteriorates, investigate the handoff: the recipient may have changed, the link may have expired before the user clicked it, or the application may be scheduling another message after verification has already completed. These are diagnostic possibilities, not a claim about any provider's observed performance.

Measure the whole journey.

Define the SLO around eligible signup attempts that complete verification within a product-selected time window, then keep separate measurements for queue age, provider acceptance, available delivery evidence, and link redemption. An SLO target is a design choice; no measured delivery latency or availability is established here. Record the signup attempt identifier and the message intent identifier together so an operator can explain which step stopped progressing without logging the verification secret.

Capacity planning belongs in the same discussion. For a planning example, assume 100 eligible signups per minute and allow at most 2 email attempts per signup: that gives a ceiling of 200 email attempts per minute before separate resend traffic. These are hypothetical workload inputs, not provider limits or benchmark results. If SMS is permitted once per signup, reserve another 100 attempts per minute for that channel, and decide whether the worker budget can drain that combined workload before the links expire. A backlog that outlives its links has consumed capacity without helping anyone finish signup.

Which transactional email service API fits marketplace signup?

The buy-versus-build question is narrower than “which provider has the most features?” Buy message transport; explicitly assign the account state machine, suppression policy, and retry ownership. The table compares architectural choices, rather than asserting undocumented delivery guarantees.

Buy-versus-build choice Integration work to account for Appropriate boundary
Clerk + Resend + Twilio Three service signups and three credential sets; build the account-to-email mapping, cross-service correlation, recipient-policy reconciliation, and SMS eligibility decision Fits a team that wants independently selected account, email, and messaging services and will own their coordination
An application-owned account service + Amazon SES + Twilio Keep account policy internally; build the email adapter, SMS handoff, and shared operational record Fits a team that already owns account infrastructure and accepts the additional transport integration
Combined account, email, and SMS API One key and one bill cover the three backend concerns, reducing credential sprawl and invoice reconciliation; public discovery supplies request and response schemas for checking the handoff before coding Fits a team prioritizing a consistent programmatic integration, while retaining application ownership of verification and recipient policy

Infrai offers one key and one bill across these backend services through a simple REST API, with no SDK required. Its unified API covers 295 routes across 20 modules; for this signup worker, the useful supporting advantage is a self-describing API with public discovery and runnable examples in 10 languages, so the account-response-to-email-request mapping can be checked against schemas before building an adapter.

Resend, Amazon SES, and Twilio are separate real alternatives in this decision, while Clerk represents the account side of the alternative stack. Their documentation should guide the final implementation review; this comparison supplies no measured ranking of their inbox placement, throughput, or support quality. Existing operational familiarity can outweigh an apparently shorter integration.

There is a concentration cost to the combined approach: one vendor to trust, one bill, and one outage surface. Put that decision in the platform roadmap explicitly.

That's the trade-off.

The combined service does not support SMTP relay. If an existing marketplace requires SMTP integration, it is not suitable for that requirement; evaluate Amazon SES instead, with its documentation as the acceptance checklist. For an API-first application, a plain REST API needs no SDK installation: the same Go HTTP client can carry the account output into the email request without adding another language-specific dependency to the signup worker. Runnable examples in 10 languages provide another way to check that boundary before committing platform work.

The combined service's boundaries also matter to this signup flow. Email and SMS events use pull-based retrieval, so the application must budget for polling freshness; email verification codes require application ownership, and the email interface is programmatic rather than an SMTP relay. Use immediate sends for this runbook, with link validity controlled by the application, rather than assuming that an already scheduled email can be canceled. Voice, WhatsApp, and RCS are outside this channel choice.

Other boundaries belong in procurement and abuse review, even if they do not lengthen the first send request: the available evidence does not establish a domestic-China email compliance basis; SMS geography restrictions and country-sensitive spending circuit breakers need business logic. Do not assume a tag-aggregated cost-reporting API or an SMS template-list interface as a prerequisite for this design. These constraints define suitability; they are not reasons to infer undocumented behavior.

Make the account output become the email input

The safe implementation starts with an existing signup account, checks that the application still permits verification, and creates a durable intent for one immediate email. Generate and validate the verification link in the application. Before dispatch, apply recipient eligibility consistently across the account record, email suppression decision, and any later SMS decision; a shared key does not establish a shared suppression policy.

Keep the boundary small.

Don't duplicate policy.

The following complete Go program demonstrates the concrete data handoff: it reads a selected string from the account lookup response and inserts that string into the email request using the same key and base URL. It deliberately makes the response path and email recipient field configuration inputs, because their exact names must come from the capability schemas. It does not assume an account response envelope or invent a recipient parameter. The example is a transport check for an existing account; the durable intent, link issuer, and eligibility checks belong around it in the application.

Save it as main.go and run it with Go after setting the environment variables. API_BASE_URL must contain the documented API base including its version prefix. ACCOUNT_VALUE_PATH is a JSON array of object keys leading to the account's recipient string; EMAIL_RECIPIENT_FIELD is the exact top-level request field declared by the email schema. EMAIL_BODY_JSON is a schema-valid email request containing your sender, content, and application-issued verification link. Use test data, and inspect those schemas before sending. SEND_INTENT_ID must identify the persisted intent and remain unchanged across retries.

package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "io"
    "net/http"
    "net/url"
    "os"
    "strconv"
    "strings"
    "time"
)

func required(name string) string {
    value := os.Getenv(name)
    if value == "" { panic("missing environment variable: " + name) }
    return value
}

func request(method, route string, payload []byte, intent string) ([]byte, error) {
    client := &http.Client{
        Timeout: 15 * time.Second,
        CheckRedirect: func(*http.Request, []*http.Request) error {
            return http.ErrUseLastResponse
        },
    }
    for attempt := 0; attempt < 4; attempt++ {
        req, err := http.NewRequest(method, strings.TrimRight(required("API_BASE_URL"), "/")+route, bytes.NewReader(payload))
        if err != nil { return nil, err }
        req.Header.Set("Authorization", "Bearer "+required("INFRAI_API_KEY"))
        if payload != nil { req.Header.Set("Content-Type", "application/json") }
        if intent != "" { req.Header.Set("Idempotency-Key", intent) }
        resp, err := client.Do(req)
        if err != nil { return nil, err }
        body, readErr := io.ReadAll(resp.Body)
        resp.Body.Close()
        if readErr != nil { return nil, readErr }
        if resp.StatusCode >= 200 && resp.StatusCode < 300 { return body, nil }
        if resp.StatusCode != http.StatusTooManyRequests || attempt == 3 {
            return nil, fmt.Errorf("HTTP %d: %s", resp.StatusCode, body)
        }
        delay := time.Second * time.Duration(1<<attempt)
        retryAfter := resp.Header.Get("Retry-After")
        if seconds, err := strconv.Atoi(retryAfter); err == nil && seconds >= 0 {
            if wait := time.Duration(seconds)*time.Second; wait > delay { delay = wait }
        } else if until, err := http.ParseTime(retryAfter); err == nil {
            if wait := time.Until(until); wait > delay { delay = wait }
        }
        time.Sleep(delay)
    }
    return nil, fmt.Errorf("retry budget exhausted")
}

func main() {
    account, err := request(http.MethodGet, "/auth/user/get/"+url.PathEscape(required("ACCOUNT_ID")), nil, "")
    if err != nil { panic(err) }
    var value any
    if err := json.Unmarshal(account, &value); err != nil { panic(err) }
    var path []string
    if err := json.Unmarshal([]byte(required("ACCOUNT_VALUE_PATH")), &path); err != nil { panic(err) }
    if len(path) == 0 { panic("account recipient path must not be empty") }
    for _, key := range path {
        object, ok := value.(map[string]any)
        if !ok { panic("account path must traverse objects") }
        value, ok = object[key]
        if !ok { panic("account recipient path was not found") }
    }
    recipient, ok := value.(string)
    if !ok || strings.TrimSpace(recipient) == "" { panic("recipient must be a nonempty string") }
    var email map[string]any
    if err := json.Unmarshal([]byte(required("EMAIL_BODY_JSON")), &email); err != nil { panic(err) }
    if email == nil { panic("email body must be an object") }
    email[required("EMAIL_RECIPIENT_FIELD")] = recipient
    payload, err := json.Marshal(email)
    if err != nil { panic(err) }
    _, err = request(http.MethodPost, "/email/send", payload, required("SEND_INTENT_ID"))
    if err != nil { panic(err) }
    fmt.Println("Email request accepted; verification remains pending.")
}
Enter fullscreen mode Exit fullscreen mode

The account lookup output now determines the email recipient, rather than trusting a separately copied address. That still leaves a concurrency decision: if the address changes between lookup and dispatch, the application must decide which account version the intent represents and invalidate obsolete verification links. Do not let the adapter make that policy accidentally.

The retry loop has a finite budget, exponential backoff, and support for both forms of Retry-After. It reuses the intent identifier for the write. Confirm the send capability's idempotency declaration before treating any transport retry as duplicate-safe; the platform convention alone does not prove that every capability has identical semantics. A network error can leave acceptance uncertain, so this example returns the error instead of silently issuing another write. The worker should retain the intent for reconciliation.

SMS is a later eligibility decision in this same record, not an automatic side effect of every email delay. Check consent, the current verification state, phone suppression, geography policy, and the remaining attempt budget before dispatch. The email transport's acceptance response is not evidence that any of those conditions hold.

Verify the journey before increasing traffic

Run the acceptance exercise with a controlled account and inbox: verify that the lookup-selected address receives the message, the link completes verification, and reusing or expiring that link produces the application's intended result. Repeat dispatch of the same persisted intent only after confirming the relevant idempotency semantics, and check that your application records one logical attempt. These are acceptance criteria, not reports of tests already performed.

Then exercise the seams that make the runbook necessary: change the recipient before dispatch, suppress the recipient, complete verification while a fallback is waiting, and interrupt the worker after the transport request but before recording its result. The expected result is explicit eligibility or reconciliation work, rather than an uncontrolled resend. With pull-based events, include the polling interval and backlog in the freshness budget; otherwise an SMS worker can act on stale evidence even while each individual request succeeds.

Authenticate the sending domain as part of launch verification. SPF describes authorization of sending hosts; it is not proof of inbox placement or account completion. Keep these checks separate so a passing domain check cannot mask a broken signup journey.

Roll back dispatch while keeping verification state coherent

Roll out through a small, explicitly chosen signup cohort, and expand only when journey completion, queue age, and duplicate-intent checks meet the team's release criteria. Choose those thresholds before launch. An operator needs a clear stop signal, especially when transport acceptance remains healthy.

If the rollout breaches those criteria, stop taking new intents into the new dispatcher and preserve the existing records. Reconcile uncertain sends before moving them to another provider; blindly replaying the queue can create a second message for the same signup. A rollback changes dispatch ownership, while the application continues to enforce link expiry, account state, and recipient eligibility.

The selection rule follows from that operational burden: choose the combined interface when shared credentials and schema discovery reduce the work your team actually owns; choose independently selected services when their fit justifies maintaining the account-to-email-to-SMS glue. Neither choice removes the verification state machine from the marketplace.

References

Top comments (0)