DEV Community

GriffinHayes3461
GriffinHayes3461

Posted on

Receipt Evidence for Beginner SMS OTP: Suppression, Status Polling, and Retention

A property manager needs a defensible record that an order receipt followed a settled payment. For a beginner SaaS stack using SMS OTP for login, start with a settlement record and a small receipt ledger, while budgeting suppression decisions and status polling separately. The bill to examine consists of message attempts, status requests, retained evidence, and the staff time needed to reconcile them. In an illustrative workload of 10,000 receipts a month, one status request per minute for 24 hours produces 14.4 million requests. At an assumed 1 KB per stored response, that also creates 14.4 GB of response bodies before indexes, replicas, or backups. These are planning assumptions, not measured traffic or quoted prices. They identify a dominant volume term before anyone starts comparing unit rates.

Short answer: for a beginner SaaS application, select SMS OTP, suppression, and status polling capabilities by the evidence they preserve and the work they bound. Keep authentication decisions separate from receipt delivery, cap polling, and retain a compact explanation of each send decision. For US and EU operations, have the responsible policy owner approve retention and suppression rules before treating a transport status as compliance evidence.

Count the copies.

A cheap-looking message API does not answer who requested a receipt, which settled payment authorized it, whether the recipient was eligible for that channel, or what the application knew when it retried. Those questions drive the storage design. The warehouse pickup-code use case that often motivates an SMS OTP search has a related boundary: a receipt records a transaction, while a pickup code authorizes an action. Neither artifact should silently acquire the other's authority.

How should a beginner SaaS stack separate SMS OTP login from receipt evidence?

Define the claim before collecting its supposed proof. For this property-management design, the intended claim is narrow: a particular payment settlement authorized a particular receipt version, the application evaluated the selected channel under a particular policy version, and it recorded the outcome of its dispatch attempt. A receipt ledger should support that claim even after short-lived diagnostic payloads expire. It cannot establish that a person read a message just because a network request completed.

That distinction matters for email as well as SMS. The Mail Privacy Protection guide describes protection that prevents senders from determining whether a message was opened. An open signal is therefore unsuitable as the required acknowledgment in this design. If the business requires an acknowledgment, define an explicit application action and retain evidence of that action under its own policy. Do not rename a tracking event to satisfy the requirement.

For each receipt, the proposed ledger records a settlement reference, receipt version, channel decision, suppression-policy version, dispatch reference, observation time, and the normalized outcome together with its source. Store an explicit reason when dispatch is withheld. Keep timestamps for both the upstream event and local observation where available; collapsing them into one field makes delayed status updates look like current events. The full recipient address belongs behind restricted access, with an opaque reference in routine operational views. This is a proposed evidence contract, not a claim that a particular jurisdiction requires these exact fields.

Storage durability deserves its own acceptance criterion.

Decide what failures the ledger must survive and how it will be restored, then test those decisions with the settlement-to-receipt relationship intact. A retained row is useful only if the team can retrieve it and explain its provenance.

Bound status polling before retaining its output

The first meaningful change to the opening model is to replace a day of fixed polling with a bounded observation budget. Suppose the same 10,000 receipts permit at most six status requests each, with requests stopping earlier after a documented terminal result. That ceiling is 60,000 requests and, under the same 1 KB assumption, 60 MB of response bodies. Actual request counts depend on early stopping and the transport contract. This comparison describes request and storage volumes; it makes no claim about the relative cost of messaging, storage, and labor in a real deployment.

Six is an example budget, not an industry limit. Choose the observation window from the time within which staff must act, the documented status lifecycle, and any request-rate limits. When the budget expires, record an unresolved outcome and route it to reconciliation. An unresolved result must not automatically authorize another receipt send, because the missing observation does not establish that the earlier attempt failed.

A particularly expensive failure mode is ambiguous acceptance: the dispatch request times out after the remote service may have accepted it. Retrying without a stable attempt identity can produce duplicate receipts, while abandoning the attempt can leave an unexplained gap. Require documented idempotency or a documented reconciliation mechanism at this boundary, and test its retention window against the application's retry window. An internal identifier alone cannot promise deduplication across a remote interface.

The ledger should retain meaningful transitions and the last observation needed for reconciliation, with a bounded diagnostic buffer for recent raw responses. Treat duplicate observations as duplicates, preserve contradictory observations for investigation, and apply an explicit transition policy rather than blindly overwriting a status with whichever response arrives last. The pitfall is subtle: a status field can look tidy after an overwrite while the evidence of an out-of-order update has disappeared.

Evidence choice What it preserves What it costs or gives up
Every raw polling response Detailed snapshots for later parser investigations Repeated payloads, more sensitive data, and a larger deletion surface
Meaningful transitions plus bounded diagnostics A compact chronology with recent troubleshooting context Old payload-level disputes become harder to reconstruct
Final normalized status alone A small operational summary The sequence and basis of intermediate decisions are lost

For a beginner implementation, the middle option is a reasonable design starting point when the approved evidence requirements permit it. It still requires a schema owner and a retention job. Simplicity here means a small, explicit contract that someone can maintain.

The limitation is reconstruction depth. This design is not suitable for an audit requirement that demands every original response: it cannot support byte-for-byte replay after diagnostic deletion. The trade-off is less retained data in exchange for less forensic detail; choose a separately governed raw-evidence archive if exact replay is required.

Separate authentication, suppression, and receipt authority

SMS OTP belongs to the authentication decision, not to the settlement record. Specify which actions require another authentication factor and what successful verification authorizes; do not label a login flow as two-factor merely because it sends a code. A receipt should be triggered by the authoritative settlement event rather than by an OTP success event. If a warehouse also issues pickup codes, give redemption its own state and expiry decisions instead of treating the receipt identifier as a pickup credential.

Suppression needs the same care. Define how recipient preferences, channel eligibility, and mandatory communications interact for this particular message category, with policy review resolving the legal questions. Do not assume that a marketing preference has an identical effect on every transactional notice, or that calling a notice transactional settles the issue. Record the policy decision and its reason before dispatch. If the selected channel is unavailable under that policy, expose a documented reconciliation path to the property team.

Keep secrets short-lived.

The receipt ledger should contain the authentication outcome reference where needed, not the raw OTP. Nor should raw codes leak into status-response logs. The following Python example illustrates the deliberately narrow distinction between a dispatch decision and an observation; the example values are synthetic, and the policy decision is an input supplied by the approved policy evaluator.

from dataclasses import dataclass


@dataclass(frozen=True)
class ReceiptDecision:
    settlement_ref: str
    receipt_version: int
    policy_version: str
    channel_allowed: bool


def initial_evidence(decision: ReceiptDecision) -> dict:
    return {
        "settlement_ref": decision.settlement_ref,
        "receipt_version": decision.receipt_version,
        "policy_version": decision.policy_version,
        "dispatch_decision": (
            "eligible" if decision.channel_allowed else "withheld"
        ),
        "transport_outcome": "unobserved",
    }


example = ReceiptDecision(
    settlement_ref="property-order-1042-settlement-1",
    receipt_version=1,
    policy_version="receipt-policy-v3",
    channel_allowed=True,
)
assert initial_evidence(example)["transport_outcome"] == "unobserved"
Enter fullscreen mode Exit fullscreen mode

This function intentionally makes no persistence or delivery guarantee.

A production implementation needs an atomic way to associate the settlement decision with pending dispatch work, plus recovery behavior for interrupted workers. Review that boundary as a data-consistency problem: replaying a settlement event should find the existing receipt decision, while a new receipt version should require an explicit business reason. Consider a worker that records an attempt, submits the message, and loses its connection before receiving an acknowledgment: the recovery process needs the recorded attempt identity and the remote interface's documented lookup or deduplication contract before deciding what to do. Deleting that identity with the diagnostic response would remove the very evidence needed to distinguish a retry from a new send. Keep the dispatch identity in the durable ledger, with the receipt version and settlement reference, even when repeated raw status responses are scheduled for deletion.

Test recovery, then decide what to delete

Selection becomes concrete when candidate interfaces must pass the same failure exercises. Test an accepted send with a lost response, duplicate settlement events, status observations arriving out of order, suppression changing before dispatch, and exhaustion of the polling budget. Require an expected ledger result for each case. A beginner team benefits more from being able to explain these five outcomes than from accumulating integration options it cannot operate.

Deployment should preserve the evidence contract across version changes. Exercise old status payloads against the new parser before rollout, make normalization changes traceable, and verify that a rollback can still read the records written during the deployment. Useful operational measures include unresolved receipt count, age of the oldest unresolved attempt, duplicate dispatch attempts, and missing settlement references; avoid putting recipient addresses or OTP values into metric labels. These measures tell the property team where work is accumulating without turning monitoring into another unbounded evidence archive.

Browser behavior is a separate boundary. MDN's Fetch API documentation distinguishes network failures from HTTP error responses: a fulfilled fetch promise is not sufficient evidence that the server returned a successful status. A receipt-status page must inspect the response status and handle its application-level result. Even then, it has learned what the application reported, not whether the recipient read the receipt. Keep the authoritative chronology on the server, where closing a browser does not stop reconciliation.

Retention has to cover the other copies too.

Before deployment, assign owners to deletion in the primary ledger, diagnostic logs, exported evidence, and recoverable backups, with documented handling for applicable preservation requirements. US and EU labels alone do not establish a universal retention duration or a complete compliance policy. The unresolved input is the approved schedule for this message category, including the obligations relevant to the property business and its recipients.

The decision rule is evidence first: choose the smallest SMS OTP and receipt-delivery design whose authentication boundary, suppression decisions, bounded status polling, and recovery records the team can demonstrate. A low unit rate cannot repair an unexplained settlement-to-receipt gap.

The deliberate cut is to stop retaining every identical polling response and every old diagnostic payload. Keep the approved receipt evidence and the transitions needed to explain it; expire the rest on the approved schedule. The cost is explicit: when an old parser dispute surfaces, staff may be able to reconstruct the decision but cannot replay the original response byte for byte. If that loss is unacceptable for a defined audit claim, retain the necessary raw evidence for that claim and account for its additional copies.

References

The Mail Privacy Protection guide supports the limit on email-open evidence. The Fetch API reference supports the distinction between request completion and HTTP success. The workload calculations, retention model, and receipt ledger above are explicit design examples rather than performance measurements or claims of legal sufficiency.

Further reading

Top comments (0)