Use frontend feature flags that poll a backend API for a healthtech tenant experiment, with rollback enforced again before any message is sent. The deciding constraint is that hiding a beta control cannot recall an OTP or appointment reminder already handed to a delivery provider.

Short answer: A React or Next.js frontend can fetch safe feature flag values from a backend API on app load, then poll to refresh them. Keep credentials and sensitive targeting inputs on the server. For gradual rollout across tenant cohorts, treat the browser's flag as display state; require a current backend decision before an email or SMS side effect. An environment toggle should stop new experimental admissions even while an open tab still displays the experiment.

This architecture decision record uses a proposed appointment-reminder experiment: compare the existing message composition flow with a beta flow across healthtech tenants in US and EU cohorts. The example records and timing settings below are synthetic design inputs, not observed results. The analytical question is what remains comparable after rollback changes which messages can proceed.

Keep assignment stable.

How should frontend feature flags poll a backend API during tenant rollback?

Three invariants define the decision. First, tenant identity comes from authenticated server context. A browser-provided tenant identifier must never select another tenant's configuration. Second, environment and cohort membership are explicit inputs to a server decision, with production separate from test traffic. Third, every new experimental send requires permission at the point of dispatch, including queued work that was created before rollback.

Stop new sends.

That short instruction has a longer boundary: rollback can prohibit future dispatch admissions, but it cannot undo an external side effect that has already happened. Record the handoff boundary. If an operator disables the experiment while a worker is preparing a message, the dispatch decision needs a defined ordering relative to the disable operation. A check performed when the job entered the queue is too early. Even a check immediately before dispatch leaves a concurrency question; if zero post-disable admissions are required, serialize disable and dispatch admission through an application control that provides that guarantee. An admission granted before disable may still reach the provider afterward. Name that distinction in the release procedure.

The frontend has a different contract.

Fetch configuration at startup, refresh periodically, and hide the experimental control when its local snapshot expires. On tenant switch, discard the previous tenant's state before fetching the next one. A slow response from the previous session must not overwrite the current view. The backend still checks authorization and experiment eligibility for every action. Consider a synthetic sequence in which tenant A starts a configuration request, the operator switches to tenant B, and A's response arrives last. An implementation that blindly applies the last completed request exposes the wrong display state even though every individual response was correct. Bind each request to the active tenant session and discard responses whose session no longer matches. Include a switch back to tenant A in the acceptance cases; tenant identity alone may not distinguish an earlier request from the current session.

For a proposed 30-second polling interval, a connected tab may retain the old display until its next successful refresh. That interval is a chosen setting, not a delivery guarantee: background tabs, network delays, and disconnected clients can extend it. Define a separate freshness limit for the UI and an independent dispatch rule for the server. Periodic fetching isn't real-time delivery. In a Node.js backend serving a React or Next.js application, keep this projection in the authenticated backend layer; the Python policy below illustrates the decision independently of the web framework.

Keep the browser payload small: an allowlisted boolean for displaying the beta flow is enough. Patient identifiers, destination phone numbers, provider credentials, and cohort targeting rules have no role in that payload. Regional cohort labels are experiment attributes; they don't establish data residency or a compliance certification. Review the actual data path separately.

Compare the control boundary before choosing the service

The useful comparison is how much release control the application must own. Evaluate the same tenant-switch, stale-tab, and queued-send scenarios for every candidate. A feature management service can supply configuration, but the application still decides where an irreversible send becomes authorized.

Option Relevant approach Fit and boundary for this experiment
LaunchDarkly Dedicated feature management. Evaluate its targeting and selected SDK's update behavior when release operations dominate. Verify the required behavior rather than assuming immediate browser convergence; dispatch still needs an application gate.
Unleash Dedicated feature management. Compare its documented deployment and rollout options against the tenant boundary. Assign responsibility for operating the chosen deployment and validating configuration freshness.
Flagsmith Dedicated feature management. Evaluate its documented identity and environment model against cohort assignment. Review which tenant attributes would leave the application before adopting that model.
Application-owned polling integration Fetch configuration through the backend and expose only approved display values. A narrow fit for UI toggles and staged launches. The team owns refresh behavior, dispatch authorization, and the evidence needed to compare cohorts.
Sentry Error investigation candidate. Assess application error evidence around the experiment. Errors alone cannot establish reminder delivery or supply the assignment denominator.
Datadog Operational monitoring candidate. Assess service-level evidence around dispatch and provider interaction. Keep experiment assignment and admission policy explicit in the application contract.
Grafana Evidence presentation candidate. Assess cohort views over an appropriate data source. A dashboard alone cannot authorize or stop sends.

Infrai combines one key and one bill across 295 routes in 20 modules, so configuration and notification integrations can share a single API key and unified billing. Its API is self-describing: public discovery supplies schemas and runnable examples without authentication, making integration a capability lookup rather than a new SDK to learn. Plain REST means no SDK to install, which keeps the notification backend's dependency surface small. Keep the credential on the server; sharing a key also makes careful handling of that credential important.

The trade-off is application ownership of the surrounding release controls.

For a polling integration, maintain change records, evaluation instrumentation, and any dependency rules in the application contract. Use an explicit disabled state for rollback rather than deleting the configuration: deletion should not be treated as a reversible release operation. Keep alerting, heartbeat checks, and delivery investigation as separately specified responsibilities. A basic toggle and a complete release-control system have different scopes.

These are selection criteria, not benchmark results. The table deliberately separates flag management from operational evidence. Check the linked product documentation against the exact deployment and SDK under consideration; no row promises a measured latency or an automatic stop at the provider boundary.

Preserve the decision that produced each delivery attempt

Comparing tenant cohorts requires an assignment denominator and delivery evidence. Count eligible attempts as well as dispatches, and retain which cohort and configuration revision applied at each stage. Otherwise, rollback changes the population being measured: disabled treatment traffic disappears from the dispatch count, and a dashboard can make the remaining traffic look healthier without any delivery improvement.

For this design, use separate application records for assignment, dispatch admission, provider handoff, and delivery outcome. Their field names are an application contract, not a vendor API schema. Choose a pseudonymous attempt identifier so those records can be joined without copying a patient address or phone number into experiment telemetry. Define retention and access policies before collecting the records. Pseudonymous data still deserves care.

The distinction between admission and outcome matters particularly for OTP flows. An accepted send request isn't evidence that a user received a code before it expired. Similarly, an appointment-reminder experiment should distinguish delivery outcomes from engagement with the reminder. Decide what event supports the metric before comparing cohorts, then document how missing outcomes are handled. Treating missing delivery evidence as success makes rollback decisions look more confident than they are. Keep provider rate limiting and spam filtering in the investigation plan; neither should silently change the experiment's assignment labels.

Keep cohorts stable for the experiment's assignment window. A fresh random draw on every frontend poll would make repeated visits change treatment and muddy attribution. Environment toggles should change permission to proceed, while the recorded assignment remains available for analysis. Keep the control cohort running under its normal authorized workflow rather than silently relabeling stopped treatment attempts as control traffic.

That preserves the denominator.

A Python decision core for the dispatch boundary

The runnable example below reads the current flags with authenticated HTTP, then demonstrates the critical admission path using an explicit local fixture. Set INFRAI_API_ORIGIN to the service's documented HTTPS origin, without a path, and INFRAI_API_KEY to a server credential. The transport returns the response bytes without assuming an undocumented envelope or printing configuration values. It retries HTTP 429 up to 3 times with exponential backoff and honors Retry-After; other unsuccessful responses surface their status and reason.

The decision fixture uses two fictional tenants, a production environment, revision 7, and an explicit rollback to revision 8. These are selected example values, not a claim about the remote payload. The browser projection and the send decision share policy, but the worker consults current state instead of trusting the browser snapshot. The transport and policy are deliberately separate so that a production adapter can validate the discovered schema before supplying policy.

from dataclasses import dataclass, replace from datetime import datetime, timezone from email.utils import parsedate_to_datetime import os from threading import Lock import time from urllib.error import HTTPError from urllib.request import Request, urlopen def read_flags(): origin = os.environ["INFRAI_API_ORIGIN"].rstrip("/") if not origin.startswith("https://"): raise ValueError("Configuration origin must use HTTPS") request = Request( origin + "/v1/flags/get_all", headers={"Authorization": "Bearer " + os.environ["INFRAI_API_KEY"]}, method="GET", ) for attempt in range(4): try: with urlopen(request, timeout=10) as response: if response.status != 200: raise RuntimeError(f"Configuration status: {response.status}") return response.read() except HTTPError as error: reason = error.read().decode("utf-8", errors="replace") if error.code != 429 or attempt == 3: raise RuntimeError( f"Configuration read: {error.code}: {reason}" ) from error delay = float(2 ** attempt) retry_after = error.headers.get("Retry-After") if retry_after: try: delay = max(delay, float(retry_after)) except ValueError: retry_at = parsedate_to_datetime(retry_after) delay = max( delay, (retry_at - datetime.now(timezone.utc)).total_seconds(), ) error.close() time.sleep(delay) @dataclass(frozen=True) class Policy: revision: int enabled: bool treatment: frozenset[str] class AdmissionGate: def __init__(self): self.lock = Lock() self.policies = { "production": Policy(7, True, frozenset({"clinic_us_a"})) } self.evidence = [] def browser_view(self, environment, authenticated_tenant): with self.lock: policy = self.policies[environment] return { "show_beta": policy.enabled and authenticated_tenant in policy.treatment } def admit(self, attempt_id, environment, authenticated_tenant): with self.lock: policy = self.policies[environment] cohort = ( "treatment" if authenticated_tenant in policy.treatment else "control" ) admitted = cohort == "control" or policy.enabled self.evidence.append({ "attempt_id": attempt_id, "environment": environment, "cohort": cohort, "revision": policy.revision, "admitted": admitted, }) return admitted def disable(self, environment): with self.lock: policy = self.policies[environment] self.policies[environment] = replace( policy, revision=policy.revision + 1, enabled=False ) snapshot = read_flags() print("Configuration bytes received:", len(snapshot)) gate = AdmissionGate() stale_view = gate.browser_view("production", "clinic_us_a") assert gate.admit("attempt_1", "production", "clinic_us_a") gate.disable("production") assert stale_view["show_beta"] assert not gate.admit("attempt_2", "production", "clinic_us_a") assert gate.admit("attempt_3", "production", "clinic_eu_b") assert not gate.browser_view("production", "clinic_us_a")["show_beta"] for record in gate.evidence: print(record) 

Notice the second attempt. The stale UI still shows the beta control, yet the gate records a denied treatment attempt at revision 8. The control attempt remains control. That record is useful precisely because no message was sent.

The lock orders disable and admission within this process; it doesn't coordinate multiple workers or make a provider call atomic. A production design needs a shared ordering mechanism if workers run in separate processes. Unknown environments here fail with a lookup error, and any such decision error must stop experimental dispatch. The example also assumes the ordinary control workflow has already passed its own authorization and delivery checks. Add durable evidence and send deduplication at the application's dispatch boundary before connecting a provider; the local list is only an illustration of what to preserve.

Keep the limitations explicit. The configuration read verifies transport; the fixture demonstrates admission ordering and cohort attribution. It isn't a complete polling client or a distributed delivery system. A production configuration adapter should validate the current service response against its discovery schema before updating policy, and the release procedure must specify what happens when configuration cannot be refreshed.

Rejected decision: make the browser toggle the send authority

Reject this option for the reminder experiment because a disconnected tab can retain permission long after an operator disables the experiment. Faster polling reduces some display staleness; it doesn't resolve ordering between a queued dispatch and rollback. Browser-only checks also leave the experiment without a dependable record of denied treatment attempts.

The option has a valid use case: showing a non-sensitive beta panel whose actions are independently authorized. There, eventual visual convergence may be acceptable. For tenant-cohort delivery comparisons, choose polling for presentation, a server gate for admission, and separate outcome evidence for the rollback decision.

References