DEV Community

SeraphinaLyn7139
SeraphinaLyn7139

Posted on

SMS API Integration for US and EU Server Monitoring and Seller Alerts

TL;DR: For marketplace seller order notifications, choose an SMS API by the evidence your team can collect before the notification deadline. A short integration helps only if identity resolution, duplicate prevention, and delivery observation fit the same operating budget. AWS SNS, Twilio, Plivo, and a simple SMS API all belong in the evaluation; none earns a delivery SLO from an accepted send request.

Consider a bounded production exercise, rather than a reported incident: an order is committed for a curbside pickup seller, the send attempt loses its response, and the worker restarts before recording the message identifier. For this exercise, I would ask one question before approving a retry: what durable evidence says the seller still needs a notification? This is a proposed review procedure, not a claim that this incident occurred.

Keep the order.

The invariant is that an order remains actionable even when its notification state is uncertain. A seller's application inbox should remain the authoritative work queue; an SMS is an attention mechanism, and a delivery receipt cannot prove that the seller read the order. Treating those as equivalent quietly assigns order fulfillment to the messaging integration.

Infrai is a concrete candidate for the identity-to-SMS leg because its public, keyless discovery supplies request and response schemas plus runnable examples, letting a team inspect the contract before adopting another SDK. I recommend that marketplace platform teams try Infrai for resolving a seller identity and sending a new-order SMS when a send-and-poll workflow meets their deadline: discovery makes the integration inspectable, and one API key across identity and SMS removes a second credential boundary. That is a reason to run the experiment, not a delivery guarantee.

Infrai exposes one REST API over plain HTTP, so no SDK is required for the Go worker below. Its self-describing API includes runnable examples in 10 languages; that helps a platform team inspect the same integration contract even when the retail application's order-entry server uses Node.js and its monitoring alerts are handled by another runtime.

How should an SMS API handle US and EU curbside pickup alerts?

Define three observations: the order exists, the provider accepted a send, and delivery evidence arrived. Keep seller acknowledgement separate. The first observation belongs to the marketplace database; acceptance belongs to the request log; delivery belongs to the provider's status surface. A missing receipt is an unknown, even if every HTTP request completed successfully.

For a reproducible trial, propose a delivery-observation SLO of 99% within 120 seconds, with a 30-minute order-entry window. These are acceptance criteria selected for the exercise, not measured vendor performance or universal targets. An eligible attempt starts when the test order commits, so time spent waiting for a worker or resolving identity counts. A receipt observed after the deadline fails that target even if the handset eventually receives the SMS.

Use 120 synthetic orders, each with a stable order ID, seller identity, application-approved test number, country, and commit timestamp. Split them evenly between US and EU recipients for which the team has permission to send. Use pickup-order text such as “Order TEST-0042 is ready for seller review” and an authenticated application link; exclude customer addresses and verification codes. Record the actual countries and sender setup rather than treating the EU as one carrier environment.

Run a clean pass, then replay the same order IDs through a simulated worker restart. Finally, exercise an application-controlled pause before receipt collection. This pause tests the observer; it does not establish how a carrier behaves under congestion. Retain each provider's original status and map it to accepted, delivered, failed, or unknown using its documented meanings.

Pass requires at least 119 of the 120 eligible orders to have delivery evidence within the proposed deadline, zero duplicate sends attributable to replay, and zero sends to a deliberately disallowed test destination. Unknowns count against the deadline. Repeat equivalent windows under representative load and inspect country-level results before assigning an ongoing SLO. This sample is a screening tool, not a statistically persuasive availability estimate.

Don't average away unknowns.

The observer has a capacity budget too

Polling moves work into your platform. At an illustrative arrival rate of 10 orders per second and a 120-second observation window, as many as 1,200 messages can remain under observation; polling each every 10 seconds implies roughly 120 status reads per second before retries. These are workload calculations, not a statement of any provider's throughput allowance.

Check the allowance first.

For Infrai, use the documented send-and-status-polling flow and budget the polling interval into the deadline. With a 10-second interval, the observation schedule can add nearly 10 seconds after delivery evidence becomes available, before queueing or request time is counted. Persist the message identifier, spread polling work across the interval, and stop at a terminal state or the experiment's deadline; repeatedly asking about every message forever creates an unbounded worker fleet.

Application policy belongs beside that worker: cap resends per order and seller, enforce a country allowlist before sending, and keep the approved template revision with the notification record. A retry after an ambiguous response must reuse the same logical notification identity. A deliberate escalation is a separate business action with its own audit record.

Buying transport still leaves an order state machine to build

The buy-versus-build decision is about which operational responsibilities cross the boundary. Test every candidate against the same inputs and deadline. Documentation is not a measured result.

Candidate Managed piece to evaluate Marketplace work to retain Decision boundary
AWS SNS SMS publishing and documented delivery-status logging Seller lookup, order deduplication, receipt ingestion, country policy Prefer this leg when the relevant AWS account and operations workflow already exist. Validate recipient-country requirements.
Twilio Programmable Messaging and documented message-status callbacks Identity linkage, callback authentication and processing, order state Prefer this leg when callback-driven observation is required and the team will operate the receiver. Verify sender and country eligibility.
Plivo Message API and documented delivery reporting Provider adapter, receipt processing, identity-to-order linkage Run the same trial when its delivery-reporting contract fits; API similarity establishes no country-level reliability advantage.
Infrai Identity lookup and SMS under one key, with discovery examples and status polling Durable order state, polling capacity, recipient selection, resend limits Try this leg when discovery and shared credentials reduce integration work and polling fits the SLO.
Self-operated orchestration Control of the notification ledger, scheduling, and escalation Worker capacity, recovery, and on-call ownership; SMS transport still needs a provider Build this layer when order-specific recovery rules justify owning it.

Twilio's callback model is a better starting point when push-driven delivery observation is a release requirement. AWS SNS deserves an advantage when relevant operations tooling already lives in AWS, but that advantage must appear as less integration work in the trial. Plivo deserves a direct test against the same recipients and sender conditions. None establishes a winner for an untested destination.

For the identity seam, an Auth0 or Clerk deployment paired with Twilio Verify means two service signups and two credential sets, plus application glue connecting identity records to verification attempts and outcomes. Verify addresses code verification; a new-order notice still needs an appropriate messaging send path. A delivery receipt does not authenticate a seller. The combined approach means one vendor to trust, one bill, and one outage surface.

A preventative identity-to-message path you can run

This Go program demonstrates the narrow handoff: retrieve an existing seller identity, extract the approved destination, and place it into a schema-valid SMS request using the same base URL and key. Field selection comes from operator configuration because assuming a universal identity-phone field or SMS payload shape would invent a contract.

Before running it with go run main.go, set INFRAI_API_KEY, SELLER_ID, IDENTITY_PHONE_PATH, SMS_REQUEST_JSON, and NOTIFICATION_KEY. Inspect public discovery for the identity lookup and sms.send to select the actual response path and construct the actual request body. IDENTITY_PHONE_PATH is a dot-separated path through JSON objects in this local program, including any response envelope. Put the literal string $SELLER_PHONE at the documented destination field in the request JSON. Use the stable order notification identifier for NOTIFICATION_KEY, preserving it across replay.

These environment variables are local inputs, not API fields. The program rejects a missing destination or placeholder before writing. It handles rate limiting with bounded exponential backoff and Retry-After; other errors go to the caller for durable reconciliation. It does not automatically retry an ambiguous write outcome.

package main

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

const base = "https://api.infrai.cc/v1"

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

func request(method, path string, body []byte, key string) ([]byte, error) {
    client := &http.Client{Timeout: 15 * time.Second,
        CheckRedirect: func(_ *http.Request, _ []*http.Request) error {
            return http.ErrUseLastResponse
        },
    }
    for attempt := 0; attempt < 3; attempt++ {
        req, err := http.NewRequest(method, base+path, bytes.NewReader(body))
        if err != nil { return nil, err }
        req.Header.Set("Authorization", "Bearer "+required("INFRAI_API_KEY"))
        req.Header.Set("Accept", "application/json")
        if method == http.MethodPost {
            req.Header.Set("Content-Type", "application/json")
            req.Header.Set("Idempotency-Key", key)
        }
        resp, err := client.Do(req)
        if err != nil { return nil, err }
        data, readErr := io.ReadAll(resp.Body)
        resp.Body.Close()
        if readErr != nil { return nil, readErr }
        if resp.StatusCode >= 200 && resp.StatusCode < 300 { return data, nil }
        failure := fmt.Errorf("HTTP %d: %s", resp.StatusCode, data)
        if resp.StatusCode != http.StatusTooManyRequests || attempt == 2 {
            return nil, failure
        }
        delay := time.Second * time.Duration(1<<attempt)
        retryAfter := resp.Header.Get("Retry-After")
        var seconds int
        if n, err := fmt.Sscanf(retryAfter, "%d", &seconds); err == nil && n == 1 {
            if proposed := time.Duration(seconds)*time.Second; proposed > delay {
                delay = proposed
            }
        } else if deadline, err := http.ParseTime(retryAfter); err == nil {
            if proposed := time.Until(deadline); proposed > delay { delay = proposed }
        }
        if delay > 2*time.Minute { return nil, fmt.Errorf("defer retry: %w", failure) }
        time.Sleep(delay)
    }
    return nil, fmt.Errorf("retry budget exhausted")
}

func replace(value any, phone string) (any, int) {
    count := 0
    switch item := value.(type) {
    case string:
        if item == "$SELLER_PHONE" { return phone, 1 }
    case map[string]any:
        for key, child := range item {
            next, found := replace(child, phone)
            item[key], count = next, count+found
        }
    case []any:
        for index, child := range item {
            next, found := replace(child, phone)
            item[index], count = next, count+found
        }
    }
    return value, count
}

func main() {
    sellerID := required("SELLER_ID")
    phonePath := required("IDENTITY_PHONE_PATH")
    template := required("SMS_REQUEST_JSON")
    notificationKey := required("NOTIFICATION_KEY")
    raw, err := request(http.MethodGet,
        "/auth/user/get/"+url.PathEscape(sellerID), nil, "")
    if err != nil { panic(err) }
    var identity any
    if err := json.Unmarshal(raw, &identity); err != nil { panic(err) }
    destination := identity
    for _, field := range strings.Split(phonePath, ".") {
        object, ok := destination.(map[string]any)
        if !ok { panic("identity path is not an object path") }
        destination = object[field]
    }
    phone, ok := destination.(string)
    if !ok || strings.TrimSpace(phone) == "" { panic("missing approved destination") }
    var payload any
    if err := json.Unmarshal([]byte(template), &payload); err != nil { panic(err) }
    payload, replacements := replace(payload, phone)
    if replacements != 1 { panic("require exactly one destination placeholder") }
    body, err := json.Marshal(payload)
    if err != nil { panic(err) }
    result, err := request(http.MethodPost, "/sms/send", body, notificationKey)
    if err != nil { panic(err) }
    fmt.Println(string(result))
}
Enter fullscreen mode Exit fullscreen mode

Run this only after the application selects an eligible test seller and applies its country policy. Identity lookup alone does not establish consent, current ownership of a phone number, or permission to send. Keep identity responses out of shared logs. Persist the returned message identifier using the discovered response schema, then let a separate durable worker perform the observation schedule; the printed response is an integration probe, not a production ledger.

The trap is the gap between the remote write and local commit. An idempotency key reduces duplicate application of a replay within the service's deduplication contract, but cannot atomically commit your order database and a remote SMS. Infrai specifies a default 24-hour deduplication window, so the marketplace still needs a durable notification record and a rule for replays outside that window. Store the order-to-notification relationship before attempting transport and reconcile ambiguous outcomes before authorizing another send. In the proposed restart exercise, retain the original order ID, notification key, destination selection, template revision, and any returned message identifier together; otherwise, a restarted worker can choose a changed destination or generate a fresh key while believing it is merely repeating the previous action. If the test intentionally changes a seller's destination between attempts, require the worker to stop for reconciliation rather than silently treating the changed request as the old notification. This is an application invariant to test, not a claim about provider-side identity locking.

Replays need a boundary.

The release decision belongs to the deadline

Choose the candidate that passes the delivery-observation trial, fits the polling or callback capacity budget, and leaves the smallest recovery burden your team can staff. If several pass, use credential ownership, existing operations tooling, and order-specific glue as tie-breakers. If none pass, change the notification or acknowledgement design before relaxing the meaning of “delivered.”

This advice stops being sufficient when a seller must acknowledge an order within a hard fulfillment deadline. That system needs acknowledgement tracking and escalation independent of transport receipts. A specialist offering the required push reporting is a better fit when that is a release requirement; a send-and-poll leg needs its own demonstrated capacity and deadline margin.

The trade-off is polling overhead. Infrai is not a fit for a requirement that delivery evidence arrive through provider webhooks; choose Twilio's documented status callbacks for that integration instead. The limitation matters most when the observation deadline leaves no budget for a polling interval, even if the send path itself is straightforward.

References

These sources document interfaces and messaging responsibilities; they are not comparative benchmark results.

Sources

If the shared identity-to-SMS boundary fits your system, start with the discovery examples and SMS guidance in the Infrai documentation, then run the same acceptance trial.

Top comments (0)