Reconcile SMS event notifications on a schedule, and let the signup service alone decide whether a healthtech verification link was redeemed. The deciding constraint is compliance evidence: a transport receipt cannot establish that the intended person completed account verification.
Short answer: Retrieve SMS events for the original message, retain the observations, and keep link redemption separate. Make observation processing idempotent and stop automatic reconciliation at an explicit evidence deadline. A late receipt must never reopen an expired signup attempt.
For a Node.js application seeking SMS event notifications through common APIs, the important example is this boundary between notification status and account state. The implementation below uses Go to demonstrate a plain HTTP integration without a provider SDK. A Node.js adapter should preserve the same decisions; it should not interpret a successful HTTP request as completed verification.
What do SMS event notifications actually prove during signup?
A verification link has two clocks. One controls how long the signup service will accept redemption. The other controls how long the worker will keep seeking delivery evidence. Define them separately. As an illustrative application policy, a link might expire after 10 minutes while evidence collection continues for 60 minutes. These are design choices, not provider guarantees or compliance requirements.
Keep those clocks separate.
The operational signal is an attempt whose evidence deadline is approaching while its delivery history is still unresolved. An empty observation set does not prove that a message failed. A receipt obtained after the link expires does not justify extending the link. If the worker converts either condition directly into account state, a transport problem becomes an authorization decision, and the audit trail can no longer explain which system made that decision. This is the failure mode the runbook should prevent.
Record an internal attempt identifier, the provider message identifier, the observation time, and the associated signup policy revision. These are proposed application records, not promised vendor response fields. Keep raw provider evidence under a documented retention policy with restricted access; keep verification URLs, tokens, and health information out of routine worker logs. Compliance review must settle the actual retention period and permitted content before production use.
Select the evidence path before the integration
Infrai fits teams that want a plain REST API with one API key and unified billing across backend modules: any runtime that can make an HTTP request can use it, with no SDK installation or client library version to maintain. The shared credential reduces handoffs between the notification integration and supporting services. For this workflow, treat SMS event retrieval as a pull integration and budget for scheduled reconciliation. Its limitation is observation freshness: choose a callback-oriented service instead if your workflow requires provider-initiated delivery reports.
Compare that choice with Twilio Programmable Messaging, Vonage SMS API, and Amazon SNS. Use their delivery-report documentation during the review, then ask each candidate to demonstrate the same evidence chain with your test messages. The table identifies distinct integration surfaces to examine; it does not certify a vendor for healthcare use.
| Candidate | Evidence surface to examine | Operational boundary to verify |
|---|---|---|
| Twilio Programmable Messaging | Message status callbacks | How callbacks authenticate, retry, and map to retained message records |
| Vonage SMS API | Delivery receipt webhooks | How receipt identifiers correlate with the original signup attempt |
| Amazon SNS | SMS delivery status logging | How logging configuration, permissions, and coverage meet evidence requirements |
| SendGrid | Email Event Webhook | Suitable for an explicitly approved email fallback, not an SMS replacement; verify its separate evidence chain |
| Plain REST pull integration | Scheduled retrieval of message observations | How reconciliation deadlines, access controls, and retained observations are enforced |
Callback-oriented integration suits a service that can operate an authenticated receiver and investigate missing callbacks. Amazon SNS deserves consideration when the team already operates AWS logging and access controls; verify the actual delivery-log configuration rather than assuming every attempt has complete evidence. Pull integration suits a worker fleet with established schedules and durable checkpoints, at the cost of observation freshness and repeated reads. None of these choices removes the need to deduplicate observations or prove the link was redeemed separately.
The compliance evidence decision remains conditional.
Require documentation of processing terms, supported regions, retention controls, and access responsibilities that applies to the exact service configuration. A delivery-report API alone supplies none of that assurance. This comparison does not establish healthcare compliance for any candidate. SendGrid changes the channel, so evaluate it only if signup policy permits email verification and the user has supplied an appropriate email address. The trade-off is explicit: it offers an email evidence surface, but the team must maintain a separate correlation and redemption path rather than treating email acceptance as proof of an SMS outcome.
Make the reconciliation decision safe to repeat
Separate the adapter from the account service. The adapter retrieves observations for one provider message identifier and retains the response with a local observation timestamp. It must use the documented response schema; do not guess a delivery-status field or flatten every unknown value into failure. The account service records redemption through its own token-validation transaction.
Use a durable work key derived from the signup attempt and provider message identifier. Replaying a scheduled task should refresh evidence for that same message, not send another verification SMS.
For observation deduplication, use a documented stable event identifier where available; otherwise define and test an application normalization rule before using a digest. Hashing an entire response blindly is a trap: changing retrieval metadata can make the same observation look new.
The complete program below reads the message event resource and writes its unmodified response to standard output. Configure SMS_API_ORIGIN with the approved HTTPS API origin, without a version suffix; supply INFRAI_API_KEY and SMS_MESSAGE_ID through the environment. Run it with Go and direct output to a restricted evidence destination, not a shared console log. No response fields are assumed.
package main
import (
"context"
"fmt"
"io"
"net/http"
"net/url"
"os"
"strconv"
"strings"
"time"
)
func retryDelay(value string, fallback time.Duration) time.Duration {
if n, err := strconv.Atoi(value); err == nil && n >= 0 {
if n > 30 { return 31 * time.Second }
return time.Duration(n) * time.Second
}
if t, err := http.ParseTime(value); err == nil {
d := time.Until(t)
if d < 0 { return 0 }
return d
}
return fallback
}
func run() error {
origin, err := url.Parse(os.Getenv("SMS_API_ORIGIN"))
if err != nil { return err }
if origin.Scheme != "https" || origin.Host == "" ||
origin.User != nil || origin.RawQuery != "" ||
origin.Fragment != "" || strings.Trim(origin.Path, "/") != "" {
return fmt.Errorf("SMS_API_ORIGIN must be an HTTPS origin")
}
key, id := os.Getenv("INFRAI_API_KEY"), os.Getenv("SMS_MESSAGE_ID")
if key == "" || id == "" { return fmt.Errorf("missing key or message ID") }
endpoint := strings.TrimRight(origin.String(), "/") +
strings.Replace("/v1/sms/events/{id}", "{id}", url.PathEscape(id), 1)
client := &http.Client{
Timeout: 10 * time.Second,
CheckRedirect: func(_ *http.Request, _ []*http.Request) error {
return http.ErrUseLastResponse
},
}
for attempt := 0; attempt < 3; attempt++ {
req, err := http.NewRequestWithContext(context.Background(),
http.MethodGet, endpoint, nil)
if err != nil { return err }
req.Header.Set("Authorization", "Bearer " + key)
resp, err := client.Do(req)
if err != nil { return err }
body, readErr := io.ReadAll(io.LimitReader(resp.Body, (1<<20)+1))
resp.Body.Close()
if readErr != nil { return readErr }
if len(body) > 1<<20 { return fmt.Errorf("response exceeds local limit") }
if resp.StatusCode == http.StatusTooManyRequests && attempt < 2 {
delay := retryDelay(resp.Header.Get("Retry-After"),
time.Second * time.Duration(1<<attempt))
if delay > 30*time.Second {
return fmt.Errorf("rate limited; defer worker until Retry-After: %s",
resp.Header.Get("Retry-After"))
}
time.Sleep(delay)
continue
}
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
return fmt.Errorf("event read returned HTTP %d: %s",
resp.StatusCode, body)
}
_, err = os.Stdout.Write(body)
return err
}
return fmt.Errorf("retry budget exhausted")
}
func main() {
if err := run(); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
This is a bounded read, not a daemon. It makes at most 3 attempts, honors short Retry-After delays, and returns longer delays to the worker operator rather than retrying early. Production scheduling must persist that next eligible run time; capture diagnostic output with the same access restrictions as the response. Transport errors exit for investigation or rescheduling. They never trigger another send.
The 10-second timeout and 1 MiB response limit are local example policies, not service limits. A limit violation must leave the checkpoint unresolved. Before retrying a write elsewhere in the workflow, verify that the specific capability supports idempotency and reuse the original operation key. A read does not require a new message or a new verification link.
Verify the clocks and the evidence chain
Exercise duplicate worker runs, a delayed observation, an empty result, and a rate-limited read in a controlled environment. The expected outcome is one signup attempt associated with one original message, with additional observations recorded without creating additional sends. Inspect the account-state history as well as the worker logs. A healthy polling counter can coexist with an incorrect verification transition.
Test the boundary exactly.
At the link deadline, confirm that a delivery receipt cannot redeem the token. At the evidence deadline, confirm that automatic reads stop while retained records remain available under policy. Then replay a previously processed observation and confirm it cannot create a second account transition. These checks give the reviewer concrete evidence about application behavior; screenshots of a provider dashboard do not establish those properties. The production token-validation transaction must reject redemption at or after expiry, regardless of what the polling worker last observed.
Track unresolved attempts by age and distinguish worker execution failures from unknown transport outcomes. Set paging thresholds from the signup service's agreed objectives rather than inventing a universal number. If evidence collection stalls, preserve the unresolved state for investigation.
Don't guess delivery.
Roll back collection without replaying signup
Pause the reconciliation schedule first. Preserve its durable checkpoints and the mapping from attempts to provider identifiers, then inspect the affected time window before resuming reads. Replacing an adapter should replay evidence collection for existing identifiers; it should not replay the send operation.
Rollback must preserve account decisions already committed by valid redemption. Expired links remain expired. If product policy allows a replacement verification link, issue it as a new attempt with its own expiry and a clear relationship to the earlier attempt. That makes the decision explainable later, even when transport evidence arrives out of order.
Top comments (0)