A support notification's storage bill includes retained request bytes, rendered HTML previews, copies, and the work needed to retrieve and control access to them. For a developer-tools contact form, start by counting those bytes: in an illustrative workload of 10,000 submissions per day, a 20 KB request-and-preview bundle retained for 30 days occupies 6 GB before replication or other copies. Retaining the same bundle for 7 days occupies 1.4 GB. These are decimal-unit calculations for a proposed workload, not measured traffic or a provider quote; they identify the payload-retention term worth changing before debating storage rates.
Short answer: prefer a bounded, 7-day diagnostic payload window plus a separately governed decision record over indefinite payload archives when investigating email API JSON errors. Validate JSON syntax first, required template variables second, and HTML rendering third; preserve the result of each stage so a support team can explain a routing decision without keeping every message forever. Seven days is an example operational choice, not a compliance deadline. Extend it when an identified obligation or investigation requires the original content.
The contact form's job is to route a developer's request to the right support queue and notify that queue. Its evidence requirement is narrower than a complete mailbox: establish which routing rule and template revision were evaluated, what failed, and whether a notification was accepted.
Keeping everything feels reassuring.
It proves little if the archive cannot distinguish a rejected request from a successfully rendered notification.
What evidence survives when the payload expires?
The useful comparison is between retaining raw content indefinitely and separating short-lived diagnostic content from longer-lived decision evidence. Neither storage policy establishes compliance by itself. The team responsible for the applicable obligations must define the purpose, access rules, deletion procedure, and retention period for each record class, including any hold that suspends ordinary deletion.
For this design, the compact record contains a submission identifier, event identifier, validation stage, outcome, routing-rule revision, template revision, selected queue identifier, and timestamps. Keep error field names where needed, but exclude submitted values from routine error records. A contact message can contain credentials or customer information; an error logger should not become the least controlled copy of the contact form.
| Retention choice | Evidence available | Failure mode or limit | Appropriate condition |
|---|---|---|---|
| Indefinite request and preview archive | Original content remains available for reinspection | Growing content exposure; old content still needs the matching rules and template to explain behavior | A documented obligation justifies retaining original content and its dependencies |
| Seven-day diagnostic payload window | Recent failures can be reproduced from restricted originals | Exact content cannot be recovered after expiry | Investigation normally starts inside the window, with a defined hold process |
| Separate decision record | Validation and queue-selection outcomes remain inspectable | Cannot prove the complete original message or visual appearance | The evidence question concerns processing decisions rather than message content |
Retain the revisions too.
A record that says “template revision 12” becomes weak evidence if revision 12 can be overwritten. Make referenced routing and template artifacts immutable for their required lifetime, and define what must remain reproducible after deletion of the submitted content. A digest can help compare a later candidate artifact with an earlier digest, but it cannot reconstruct an expired message or, on its own, establish who submitted it. Consider a hypothetical review after the diagnostic window: a developer asks why a billing-related contact reached the general support queue. The surviving record should identify the selected queue and routing revision, allowing the reviewer to inspect that revision's behavior; if the complaint depends on a phrase inside the expired message, however, the record cannot settle whether that phrase was present. Retaining an outcome code does not preserve the evidence needed to reevaluate every possible input-dependent decision. This approach is not suitable for obligations that require the complete original submission beyond seven days. The trade-off is reduced content retention in exchange for a narrower set of questions the surviving record can answer. The evidence boundary needs to be explicit before anyone calls the archive auditable.
Separate malformed JSON from missing template variables
An HTTP 400 response indicates that the server cannot or will not process a request because of a perceived client error; RFC 9110 does not make that response a diagnosis of malformed JSON. A syntactically valid object with a missing template variable is a different failure from an invalid JSON document, and an API's documented error contract determines how each is reported. Do not infer the processing stage from the status code alone.
In a Node.js caller, inspect the serialized request body and its declared content type at the outgoing boundary, using restricted diagnostic capture when original content is necessary. A server-side object dump is insufficient evidence of the bytes transmitted. RFC 8259 supplies the syntax rules: JSON object member names are strings, and trailing commas are outside its grammar. Fix serialization before examining HTML.
Next check the template's declared inputs. For this contact form, suppose the contract requires case_id, queue_name, and summary; these are example application fields, not a commercial API schema. Define whether nulls, empty strings, extra fields, and wrong types are permitted.
Missing and empty are different states.
An object can pass JSON parsing while remaining unusable for the intended notification, so the decision record should say which contract failed without copying the contact message into the error description.
The following Python example illustrates the validation boundary. It deliberately accepts only a JSON object whose required values are nonempty strings; it does not render HTML, persist evidence, or send a notification. The language of the caller does not change the wire-format or template-contract checks.
import json
REQUIRED = ("case_id", "queue_name", "summary")
def validate_notification(raw: str) -> dict:
try:
data = json.loads(raw)
except json.JSONDecodeError:
return {"stage": "json", "outcome": "invalid_syntax"}
if not isinstance(data, dict):
return {"stage": "contract", "outcome": "object_required"}
invalid = [
key for key in REQUIRED
if not isinstance(data.get(key), str) or not data[key].strip()
]
if invalid:
return {
"stage": "contract",
"outcome": "invalid_required_fields",
"fields": invalid,
}
return {"stage": "contract", "outcome": "accepted"}
This example is deliberately limited. Python's default JSON decoder accepts some nonstandard numeric constants, so it is not a complete strict RFC 8259 conformance gate. Select and test the production parser's behavior against the actual request contract, and apply input-size limits before parsing. The compact return value demonstrates what an evidence record can contain without retaining summary.
Preview the same revision that will be sent
Once the contract passes, render the exact template revision with the validated values and record the rendering outcome separately. Escape untrusted contact text for its output context. The OWASP Cross Site Scripting Prevention Cheat Sheet explains why HTML text, attributes, and other contexts need different handling; a contact-form summary should not silently become executable markup in an internal preview.
A preview is evidence of a rendering attempt, not proof of delivery or of identical display in every recipient client. Keep submission, rendering, provider acceptance, and any later delivery evidence as distinct states. If a timeout leaves acceptance uncertain, retries need an application-level duplicate policy tied to the event identifier; otherwise a single developer's contact request can produce multiple queue notifications while the audit record appears to describe only one.
The routing decision belongs upstream of the notification. Resolve the support queue from validated, trusted routing inputs and a versioned rule, then pass its display name into the template. Letting rendered prose determine the destination makes a wording change alter workflow behavior, which is precisely the kind of dependency an evidence review should expose.
Test the expiration boundary before deployment
Test a malformed document, a valid object missing queue_name, an empty summary, and contact text containing HTML metacharacters. Each should produce an identifiable stage result without leaking values into ordinary logs. Then test an expired payload: the decision record should still resolve to the retained routing rule and template revision, while access to deleted content should fail as intended.
Deletion needs an inventory.
Check preview stores, request logs, failed-job stores, exports, and backups against the stated retention policy rather than treating removal from one table as complete erasure. The operational burden of that inventory, access review, and evidence retrieval belongs beside byte storage in the cost analysis, even though this example assigns no invented hourly rate to it.
Deploy changes to the validation contract and evidence schema together, so operators can interpret records created on either side of the release. Monitor counts by validation stage, unresolved notification outcomes, duplicate suppression, and deletion completion. Exclude message bodies from metric labels. Compact records improve routine inspection, but additional schemas and revision management create work for the team; that work is justified only if it answers the actual evidence questions.
Stop keeping what cannot justify its retention
Choose the 7-day diagnostic window when it fits the investigation process and the relevant retention obligations, and retain separately governed decision evidence for the period those obligations require. If reviewers need the original message beyond that window, the design needs a documented longer period or a scoped hold. Indefinite accumulation is an expensive substitute for deciding what must be proved.
Under this policy, routine raw request bodies and rendered previews expire after their diagnostic window. That gives up exact replay of an old malformed body and inspection of its precise rendered content; a later dispute may be answerable only through the validation outcome, queue decision, and retained revisions. Accept that loss explicitly. A smaller archive is defensible only when the surviving evidence is enough for the question being asked.
References
The JSON grammar, HTTP status semantics, and output-encoding guidance support the technical distinctions above. The workload, field names, and seven-day window are illustrative design choices, not requirements imposed by these sources.
Further reading
- RFC 8259, The JavaScript Object Notation (JSON) Data Interchange Format: https://www.rfc-editor.org/rfc/rfc8259.html
- RFC 9110, HTTP Semantics, including 400 Bad Request: https://www.rfc-editor.org/rfc/rfc9110.html#section-15.5.1
- OWASP Cross Site Scripting Prevention Cheat Sheet: https://cheatsheetseries.owasp.org/cheatsheets/Cross_Site_Scripting_Prevention_Cheat_Sheet.html
Top comments (0)