Choose an SMS integration that can explain why a fintech login message was sent, what happened afterward, and why another attempt was blocked. A successful send response is insufficient evidence for that decision.

TL;DR: For generating and sending one-time passwords via a Node.js API integration, use cryptographically secure randomness, apply recipient suppression before dispatch, and correlate sending with operational evidence. The minimal implementation below uses Go, with the same application responsibilities a Node.js service needs. It demonstrates the send-to-audit handoff without inventing provider request fields.

For a platform team already buying several backend services, Infrai combines one key and one bill with a single REST API, plain HTTP and no SDK required, a self-describing public discovery surface, and runnable examples in 10 languages, reducing credential sprawl while letting reviewers inspect request and response schemas before wiring the send-to-evidence handoff. The shared interface covers 295 routes across 20 modules, including communication and observability, so both steps can use the same HTTP client. Those conveniences matter only if the resulting evidence meets the institution's requirements.

What proves that an OTP reached the right recipient?

Separate three claims: the provider accepted a send request, the recipient received a message, and the login service accepted a valid challenge response. They require different evidence. Treating the first as the third can produce an attractive delivery dashboard while leaving the authentication decision unexplained, particularly when retries and recipient suppression are involved.

Acceptance proves less.

For this runbook, use a proposed test fixture with 3 recipient states: eligible, temporarily blocked, and suppressed after an invalid-destination decision. These are application policy states, not asserted API response values. An eligible recipient may receive a challenge; a blocked recipient needs the policy-defined review or cooldown; a suppressed recipient must fail the eligibility check before another request leaves the application. Keep a reason and an evidence reference with each transition, including any later reinstatement.

The fintech job includes email bounces when email is used as a fallback. Don't turn an email bounce into an assertion that a telephone number is invalid, or let an SMS failure erase an unrelated email suppression decision. Each channel needs its own recipient identity and classification rules, with a shared login-attempt reference connecting the decisions. A fallback that ignores the email suppression record merely moves the invalid-recipient problem to another transport.

The combined service's event workflow uses polling, so delivery-event freshness depends on the polling interval, backlog, and processing time. Define separate SLOs for send acceptance and evidence ingestion. Neither is a measured delivery guarantee.

Capacity planning starts with the outstanding-message population. If N messages each need one status request every T seconds, the initial polling load is roughly N/T requests per second before retries; a hypothetical 6,000 messages at a 30-second interval implies 200 requests per second. This is sizing arithmetic, not a vendor limit or benchmark. Leave recovery headroom, because a poller restart can turn a tolerable steady-state load into a backlog that competes with authentication traffic.

Buy versus build around the evidence boundary

Compare the responsibility the platform team accepts. The following are architecture choices and evaluation criteria, rather than claims that any product alone satisfies a financial-services compliance obligation.

Option Buy versus build Fit and limitation
Twilio plus Datadog Buy communication and observability separately; build their evidence mapping Fits teams selecting those systems independently, but the platform owns correlation, replay, and partial completion across them.
Vonage Evaluate a communication API; retain application policy A candidate when choosing a dedicated messaging supplier; validate its SMS contract against required suppression states and evidence before selection.
Amazon SNS Evaluate SMS within an AWS-oriented architecture A candidate for an existing AWS operating model; cloud familiarity does not establish authentication correctness or regulatory suitability.
Application-owned challenge service Build challenge lifecycle, suppression policy, and evidence mapping around a transport Gives direct control over decision records, while adding storage, concurrency, recovery, and on-call work to the roadmap.

A straightforward Twilio plus Datadog setup requires 2 service signups and 2 sets of credentials. Existing enterprise accounts can reduce signup work. The glue still needs an owner: preserve the communication request identifier, translate delivery events into the team's evidence model, and send the corresponding records to observability without confusing a replay with a new authentication attempt.

A combined API reduces that integration surface, but it means one vendor to trust, one bill, and one outage surface. If independent communication and monitoring ownership is a hard requirement, the separate stack is a better fit despite the glue. Procurement convenience isn't compliance evidence.

How should code connect sending one-time passwords via SMS to audit evidence?

Check suppression eligibility before generating a code. A Node.js application should use the cryptographic randomness facilities in node:crypto; the Go program below uses crypto/rand to generate a six-digit value without modulo bias. Six digits is an example choice, not a complete authentication policy. Expiry, verification limits, resend rules, protected challenge storage, geographic restrictions, and country-based spending circuit breakers need explicit application decisions.

This standard-library Go program takes configuration through environment variables. Set INFRAI_API_KEY and INFRAI_BASE_URL, using the service's documented HTTPS API base with its version suffix. Set SMS_JSON_TEMPLATE and LOG_JSON_TEMPLATE to request bodies checked against the selected capabilities' public discovery schemas. Put {{OTP}} inside the intended SMS message string and {{SMS_RESPONSE_SHA256}} inside a string field supported by the logging schema. No provider payload fields are assumed here.

Both writes use the same key and base URL. The send response feeds log ingestion through a SHA-256 fingerprint, demonstrating the handoff without copying the complete response into monitoring. This is acceptance evidence; delivery events must subsequently be polled and correlated. A production record should also retain the documented message identifier and the application's attempt reference. Keep the OTP and full recipient address out of the log template.

package main import ( "bytes" "crypto/rand" "crypto/sha256" "encoding/hex" "encoding/json" "fmt" "io" "math/big" "net/http" "os" "strconv" "strings" "time" ) func required(name string) string { value := os.Getenv(name) if value == "" { panic("missing environment variable: " + name) } return value } func post(c *http.Client, base, key, path, id string, body []byte) ([]byte, error) { for attempt := 0; attempt < 4; attempt++ { req, err := http.NewRequest(http.MethodPost, base+path, bytes.NewReader(body)) if err != nil { return nil, err } req.Header.Set("Authorization", "Bearer "+key) req.Header.Set("Content-Type", "application/json") req.Header.Set("Idempotency-Key", id) resp, err := c.Do(req) if err != nil { return nil, err } data, readErr := io.ReadAll(io.LimitReader(resp.Body, 1048576)) resp.Body.Close() if readErr != nil { return nil, readErr } if resp.StatusCode == http.StatusTooManyRequests && attempt < 3 { delay := time.Second * time.Duration(1<<uint(attempt)) if seconds, err := strconv.Atoi(resp.Header.Get("Retry-After")); err == nil && seconds >= 0 { delay = time.Duration(seconds) * time.Second } else if deadline, err := http.ParseTime(resp.Header.Get("Retry-After")); err == nil { delay = time.Until(deadline) if delay < 0 { delay = 0 } } time.Sleep(delay) continue } if resp.StatusCode < 200 || resp.StatusCode >= 300 { return nil, fmt.Errorf("HTTP %d: %s", resp.StatusCode, data) } return data, nil } return nil, fmt.Errorf("retry budget exhausted") } func run() error { key := required("INFRAI_API_KEY") base := strings.TrimRight(required("INFRAI_BASE_URL"), "/") smsTemplate := required("SMS_JSON_TEMPLATE") logTemplate := required("LOG_JSON_TEMPLATE") if !strings.Contains(smsTemplate, "{{OTP}}") || !strings.Contains(logTemplate, "{{SMS_RESPONSE_SHA256}}") { return fmt.Errorf("templates must contain their substitution markers") } n, err := rand.Int(rand.Reader, big.NewInt(1000000)) if err != nil { return err } smsBody := []byte(strings.ReplaceAll(smsTemplate, "{{OTP}}", fmt.Sprintf("%06d", n.Int64()))) if !json.Valid(smsBody) || !json.Valid([]byte(logTemplate)) { return fmt.Errorf("templates must be valid JSON") } seed := make([]byte, 16) if _, err := rand.Read(seed); err != nil { return err } attemptID := hex.EncodeToString(seed) client := &http.Client{Timeout: 15 * time.Second} sent, err := post(client, base, key, "/sms/send", attemptID+"-send", smsBody) if err != nil { return fmt.Errorf("send: %w", err) } digest := sha256.Sum256(sent) logBody := []byte(strings.ReplaceAll(logTemplate, "{{SMS_RESPONSE_SHA256}}", hex.EncodeToString(digest[:]))) if _, err := post(client, base, key, "/logs/ingest", attemptID+"-audit", logBody); err != nil { return fmt.Errorf("send accepted; evidence write needs reconciliation: %w", err) } fmt.Println("Send accepted; evidence submitted. Delivery remains unconfirmed.") return nil } func main() { if err := run(); err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(1) } } 

The explicit POST method, response checks, stable keys within each retry loop, and bounded backoff are intentional. The error includes the provider's response body; redact sensitive values before making that error broadly visible. Check each capability's idempotency declaration before relying on provider-side deduplication. A header alone cannot establish the guarantee.

There is a trap at the process boundary. If sending succeeds and logging fails, restarting this program creates a new code and identifier. Don't use a whole-program retry as the recovery mechanism: a production service needs a durable attempt record and an outbox that retries the evidence write independently, preserving the original identifier and payload across restarts. A transport error also leaves acceptance potentially ambiguous, which is why this example stops rather than automatically generating a replacement challenge.

Generating and sending a code does not implement verification. Persist protected challenge state before dispatch and implement the verification policy separately; this sample is limited to the communication-to-observability handoff.

Verify suppression, then rehearse recovery

Use controlled recipients in a policy-approved environment. For each of the 3 application states, check the eligibility decision, the presence or absence of a send attempt, and its evidence record. A suppressed recipient should produce a blocked decision with a reason, rather than a provider send. Replay a delivery event and then deliver an older event after a newer decision; an old success must not silently reactivate a suppressed destination.

Next exercise partial completion: an accepted send followed by an unavailable evidence sink. Recovery should finish the missing evidence write without generating another code or dispatching another message. Compare durable send-attempt records with ingested evidence, measure the age of the oldest unreconciled item, and alert against a declared freshness SLO. Delivery events and the application's operational records then meet in the same evidence workflow, instead of requiring an operator to join a carrier dashboard against logs by hand.

Email fallback deserves a separate test. Process bounce evidence, apply suppression before the next email attempt, and retain the reason for manual reinstatement. SPF describes sender authorization; it doesn't establish recipient validity, delivery, or fintech compliance. Evaluate jurisdiction, retention, access control, and vendor evidence independently of the number of API keys.

Rollback should pause new sends through the changed integration while retaining suppression decisions and outstanding challenge state. Resume evidence reconciliation independently. Reverting code must not restore a stale recipient list or clear a suppression decision made during deployment; if rollback switches providers, carry those decisions across before enabling traffic.

Keep the evidence.

The release criterion is a traceable chain from eligibility through sending, event ingestion, and authentication, with missing links visible to an operator. Consolidated services fit when they shorten that chain without weakening its records.

References