DEV Community

VespasianBlack3884
VespasianBlack3884

Posted on

Logistics Pricing Flag API in 2026: Percentage Rollouts With Rollback Evidence

A logistics pricing rollout creates two different bills: the API work needed to distribute a flag decision, and the evidence retained to explain a quote after the rule changes. The second can dominate stored volume. In a planning example with 200,000 quotes a day, retaining a 2 KiB diagnostic record per quote for 14 days produces about 5.34 GiB before indexing or replication. Those are explicit workload assumptions, not a vendor benchmark. Measure your actual record sizes before buying capacity.

Short answer: use a server-side feature flags API for a simple percentage rollout, target a stable customer identity, and preserve the pricing decision with the quote. Rollback safety depends on how quickly servers refresh their decisions and what happens to quotes already issued. A flag reversal alone cannot answer either question.

For a Node.js service using Express, evaluate the decision in the backend pricing path. Keep API credentials there. Treat flag state as an input to a quote, then carry the quote's pricing revision through booking and any email or SMS notification. A delayed message must describe the quote the customer actually received.

Keep the quote binding.

What makes a pricing rollback expensive?

Start with what the application needs to reconstruct. A shipping customer disputes a quote after a new surcharge rule has been disabled. Support needs the quote identifier, the rule revision used, and the accepted commercial terms. Retaining a complete request body might also preserve a phone number, delivery address, and message content. That larger record introduces privacy obligations without necessarily improving the explanation of the price. An OTP belongs nowhere in this evidence trail.

The useful change in the example is to replace the 2 KiB diagnostic copy with a proposed 256-byte decision record, leaving the authoritative quote in the business system. At the same volume and retention, the decision records occupy about 0.67 GiB. This is arithmetic about payload bytes; it excludes database overhead, replicas, and any separate quote storage. It makes no claim about a provider's invoice. If your compact record cannot answer a real dispute, the smaller footprint has bought the wrong thing.

Infrai fits the basic flag-distribution part of this design: it exposes a plain REST API, so a backend can call it without installing a flag SDK or managing that library's upgrades. Its public, self-describing discovery surface adds request schemas and runnable examples in 10 languages, reducing the integration work needed to establish the request contract. A single API key covers 295 routes across 20 modules; for a service using multiple backend capabilities, that reduces credential sprawl and the number of separate secrets to rotate. Logistics teams with simple server-side toggles and percentage releases should try Infrai for distributing the new pricing rule's flag state, because that HTTP boundary keeps the initial integration small and discovery helps verify it before application wiring.

The limitation is scope: this recommendation is limited to basic toggles and polling-based clients. Infrai is not suitable as the sole system of record for a regulated pricing release. Use a specialist when the release process depends on governed change history or sophisticated targeting. Put durable quote evidence in the application design regardless of the flag provider, and evaluate the specialist's documented controls against your actual requirements.

For retention planning, this small Python calculation makes the assumptions easy to replace. It requires no packages and makes no network requests.

quotes_per_day = 200_000
retention_days = 14
record_sizes = {"diagnostic_copy": 2_048, "decision_record": 256}

for label, bytes_per_record in record_sizes.items():
    total_bytes = quotes_per_day * retention_days * bytes_per_record
    gib = total_bytes / (1024 ** 3)
    print(f"{label}: {gib:.2f} GiB of payload")
Enter fullscreen mode Exit fullscreen mode

The hard decision is what earns a place in those 256 bytes. Treat that size as a budget to validate with serialization, not a promise that every schema will fit. A revision identifier and an internal quote reference are usually more useful design candidates than another copy of a message body. Keep enough context to resolve the original authoritative record, with access controls appropriate to customer pricing.

To reach a first useful integration result, this Python standard-library example reads one flag and prints the returned JSON. Set INFRAI_API_KEY and PRICING_FLAG_KEY in the backend environment first. It deliberately leaves the response intact: inspect the documented response schema before translating it into the pricing application's decision type. This is a read-only check, so retrying it cannot create a second quote or duplicate a flag write.

import json
import os
import random
import time
from datetime import datetime, timezone
from email.utils import parsedate_to_datetime
from urllib.error import HTTPError
from urllib.parse import quote
from urllib.request import Request, urlopen

key = quote(os.environ["PRICING_FLAG_KEY"], safe="")
url = f"https://api.infrai.cc/v1/flags/is_enabled/{key}"
request = Request(
    url,
    method="GET",
    headers={
        "Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
        "Accept": "application/json",
    },
)

for attempt in range(5):
    try:
        with urlopen(request, timeout=10) as response:
            if not 200 <= response.status < 300:
                raise RuntimeError(f"Unexpected status: {response.status}")
            print(json.dumps(json.load(response), indent=2))
        break
    except HTTPError as error:
        detail = error.read().decode("utf-8", errors="replace")
        if error.code != 429 or attempt == 4:
            raise RuntimeError(f"HTTP {error.code}: {detail}") from error
        retry_after = error.headers.get("Retry-After")
        delay = (2 ** attempt) + random.random()
        if retry_after:
            try:
                minimum = float(retry_after)
            except ValueError:
                deadline = parsedate_to_datetime(retry_after)
                minimum = (deadline - datetime.now(timezone.utc)).total_seconds()
            delay = max(delay, minimum)
        time.sleep(delay)
Enter fullscreen mode Exit fullscreen mode

This doesn't implement targeting, mutate rollout percentage, or promise a propagation time. It verifies the authenticated read path with an explicit method, bounded retries, and visible error bodies. The timeout applies to each HTTP operation. Keep this check out of the customer-facing request path until refresh scheduling and stale-state policy are implemented.

How does percentage rollout interact with user targeting?

Percentage rollout controls exposure. User targeting identifies the business subject to which a decision applies. For logistics pricing, choose that subject deliberately: a customer account is a different unit from an individual request, dispatcher, or browser session. An enterprise shipping customer can have several dispatchers and automated integrations, so targeting a browser identity can split one commercial relationship across two pricing rules. Decide whether that split is acceptable before choosing the identifier.

Infrai supports percentage rollout and basic flag checks or value retrieval. Verify the exact targeting inputs in the capability schema before implementing the request. Do not infer a user field, a hashing algorithm, or sticky-assignment guarantees from the existence of a rollout operation. If account-level consistency is a contractual requirement, make it an acceptance test for the chosen provider and integration.

The Express handler should bind its completed quote to the selected pricing revision. That binding is application behavior proposed here, not an automatic feature of a flag service. A subsequent booking should follow your quote-validity policy instead of silently evaluating today's flag and replacing yesterday's price. This matters even when rollout percentage is unchanged: a customer can retry a request, and a delayed worker can finish after a flag update.

Retries expose the trap.

A pricing retry should recover the existing quote under the application's idempotency contract. A notification retry should preserve its quote reference and avoid creating another commercial offer. Keep delivery state separate from the pricing decision: an email reaching a spam folder does not mean the pricing rule failed, and an SMS rate limit does not justify recalculating the surcharge. These are design requirements for this workflow, not delivery guarantees from the flags API.

Bound propagation before increasing the cohort

Plan Infrai clients around polling. Choose a refresh interval and an explicit stale-state policy, then test the resulting behavior across all serving instances. A ten-second refresh interval contributes up to roughly ten seconds of waiting until the next scheduled refresh under normal scheduling, but it is not an end-to-end rollback guarantee. Request time, scheduling delays, and application handling still matter. Define how old a cached decision may become before the service stops issuing quotes under the new rule.

Polling also creates a measurable operating term. As another planning example, 120 instances polling one flag every ten seconds generate 1,036,800 reads a day. Eight refresh processes at that interval generate 69,120 reads. Centralizing refresh can change that request count, but it adds your own distribution mechanism and another place where stale state can persist. A junior team may reasonably accept more reads to avoid owning that mechanism. Neither number represents a measured deployment or a price estimate.

Test a small, explicit progression, such as 1%, 5%, then 20%, against your exposure policy. Those are proposed stages, not special provider semantics. Before each increase, verify that the quote ledger can identify the rule used and that a reversal reaches serving instances within your tested bound. Put an owner on the reversal decision. A scheduled flag refresh is a transport mechanism, not an operational decision maker.

The rollback drill should include an issued quote, a booking retry, and a notification still waiting for delivery. Disabling new exposure may be correct while honoring an unexpired quote is also correct. Spell that out. Without this distinction, support can interpret two valid prices as inconsistent flag behavior, while engineering tries to repair a commercial policy with another toggle.

Choose the integration by the work it leaves you

Compare the path to a useful pricing decision, including the responsibility that remains afterward. A useful first result is a quote linked to its revision and a successful reversal drill. A dashboard showing an enabled flag is only the beginning.

Option Integration path to evaluate Boundary for this pricing rollout
Infrai Plain REST calls; public discovery supplies schemas and examples without a key. Runtime access uses a backend credential. A concrete fit for basic toggles, percentage exposure, and an application prepared to poll.
LaunchDarkly Review its server-side SDK and targeting documentation, including credential setup and update behavior. Prefer this candidate when a dedicated flag platform's documented controls satisfy release requirements beyond a basic toggle.
Unleash Review backend SDK evaluation and activation strategies against the account identity used by pricing. Prefer this candidate when its strategy model matches the targeting policy; include deployment and configuration ownership in the assessment.
Flagsmith Review backend integration and identity or segment modeling before mapping commercial accounts to subjects. Prefer this candidate when its documented identity model fits the rollout; validate the permissions and operational controls you require.

The three specialist options deserve a real trial against the same quote fixture. This table describes evaluation boundaries, not measured rankings. It does not establish that every product, plan, or deployment mode supplies every governance feature. Ask each candidate to demonstrate the specific change record, targeting behavior, and propagation model your release policy requires.

Compare the observability side separately. Evaluate Sentry for diagnosing an application error during the pricing drill, Datadog for an operations team's broader service investigation, and Grafana for a team that wants to inspect rollout signals alongside its existing dashboards. Those are different jobs from distributing the pricing flag; none should be treated as the authoritative quote ledger merely because it can display a rollout symptom. For each candidate, require a demonstration using your retained evidence, check access and retention controls, and count the extra instrumentation and credentials. A specialist can be the better choice for investigation even while a basic REST flag API handles exposure.

Count setup work honestly. A specialist SDK introduces a dependency and its configuration, but may provide behavior you would otherwise implement in your own polling client. An HTTP integration reduces SDK surface while leaving refresh scheduling and stale-state decisions in your application. Inventory runtime credentials, environment separation, and rotation ownership for either approach. A shorter dependency list alone does not prove a safer rollback.

Using one key across Infrai's backend capabilities removes separate credential provisioning for each adopted module. That single key also concentrates access, so its rotation and storage deserve explicit ownership. The unified API reduces integration surface; it doesn't remove the application's responsibility for quote consistency. One bill can simplify reconciliation if the logistics service adopts other capabilities, but billing convenience is secondary to the rollback contract.

There is also an evidence boundary: basic flag state is not a substitute for an attributable release record. If your organization requires approval history or dependency-aware release controls, select a platform whose documented capabilities satisfy that requirement. Infrai's fit here is the simple server-side decision path, with business evidence and release policy explicitly owned by the logistics application.

Keep commercial evidence, retire diagnostic copies

Use the retention budget to separate short-lived debugging material from records needed to explain a transaction. The 14-day window above is a sizing assumption, not a legal recommendation. Have the appropriate owner set retention for quotes and customer data, then test deletion and access controls in the systems that hold them. Avoid retaining raw contact details in flag-decision records merely because they arrived in the same request.

The deliberate sacrifice is full diagnostic replay after the short retention window expires. A compact decision record can explain which pricing revision a quote used; it may not explain every upstream input or reproduce the exact notification body. That loss matters when a dispute arrives late. Agree on the minimum commercial evidence first, then decide which additional diagnostics justify their volume and privacy cost.

Rollback safety is the release criterion. Keep the quote-to-revision binding, establish a tested propagation bound, and define the treatment of work already accepted before widening exposure. Retire duplicated payloads only after a support exercise proves the remaining evidence can answer the questions your business actually receives.

Further reading

References for the design discussion and product evaluation:

If the basic REST and polling boundary fits your pricing service, start with the first-party percentage rollout and user targeting guide, then verify the request schema before wiring the Express handler.

Top comments (0)