Short answer: keep marketplace receipt backups in a private object store, record the intended expiry beside each object, and let one accountable deletion control remove them after 30 days. Use bucket access policy to prevent public reads; use observability to prove the retention clock actually ran.
A receipt archive is not ordinary application media. A seller may need the original file for an audit, support may need a short restore window, and the same document can contain names, addresses, and order details. The least complex useful design is a private bucket with a 30-day retention rule, an immutable-looking receipt key, and a daily check that compares the inventory with the deletion outcome. No public URLs. No vague ownership of the expiry clock.
| Control | Pick this when | What to observe |
|---|---|---|
| Object-store lifecycle rule | The store can enforce expiry from object age and the policy is the source of truth | policy revision, objects reaching 30 days, deletion counts |
| Application deletion worker | Expiry depends on receipt state or a legal hold stored by the app | eligible records, delete attempts, retry queue, object-not-found results |
| Hybrid catalog plus lifecycle rule | You need audit evidence without making the app responsible for every delete | catalog-to-object matches and daily aged-object totals |
The lifecycle rule is usually the right default for a fixed 30-day window. An application worker earns its complexity only when its decision needs business data. The catch is that a fixed rule cannot express a case-specific hold unless the storage policy and object layout provide a separate path for those records.
The expiry clock needs one owner.
1. What should a private backup lifecycle delete after 30 days?
Delete the receipt object, its temporary derivatives, and any catalog entry whose only purpose is to locate that object. Keep a separate, minimal audit event if the business needs evidence that deletion occurred; do not keep another copy of the original receipt by accident. This distinction matters: deleting receipts/ while leaving exports/ or an event attachment untouched turns a 30-day promise into a naming convention.
Use a key that makes the retention scope obvious to humans and automation. For example, receipts/2026/09/merchant_42/order_9182/original.pdf exposes the class of data without placing a customer name in the path. A bucket policy should deny anonymous reads and grant the receipt-processing identity only the actions it needs for the relevant prefix. The OWASP File Upload Cheat Sheet recommends storing uploads outside the webroot or on a separate host and controlling access rather than exposing uploaded files directly.
The policy choice is simple, but the clock is not. Define whether the 30 days start at upload completion, receipt issuance, or successful processing. Pick one timestamp, write it to the catalog, and use the same interpretation in tests and dashboards. If a regulator or contract sets a different retention period, the policy owner needs to resolve that requirement before deployment; an engineer cannot infer it from the object creation date.
2. How should a Node.js application choose the deletion clock owner?
A storage lifecycle rule is a good fit when every receipt archive has the same 30-day lifetime. It keeps deletion close to the bytes, so a missed application deployment does not automatically create an immortal archive. Treat the rule as infrastructure configuration: review it, version it, and alert when the deployed policy differs from the approved 30-day rule.
Choose an application worker when deletion depends on a hold, a dispute, or a receipt that has not yet completed processing. The worker must be idempotent. A second delete request should converge on the same desired state, because retries and duplicate scheduler runs are normal operating conditions.
Use a hybrid approach when auditors need a readable trail. The object store owns age-based deletion, while a small catalog records objectKey, receivedAt, expiresAt, and a deletion observation. The catalog is evidence, not a second archive.
Here is a TypeScript shape for the catalog check. It deliberately uses an interface rather than pretending every object store has the same SDK or policy syntax.
interface ReceiptArchive { objectKey: string; receivedAt: Date; expiresAt: Date; deletionObservedAt?: Date; } interface ObjectStore { exists(key: string): Promise<boolean>; } export async function observeExpiry( archive: ReceiptArchive, store: ObjectStore, now: Date, ): Promise<ReceiptArchive> { if (now < archive.expiresAt) return archive; const stillExists = await store.exists(archive.objectKey); if (stillExists) return archive; return { ...archive, deletionObservedAt: now }; } This check does not delete anything. It answers a different operational question: did the retention control produce the expected state? That separation keeps a monitoring job from quietly becoming a second, competing deletion system.
3. Make the private bucket policy narrow enough to review
A private bucket is not a bucket with an obscure name. Public access must be disabled, and the processing identity should receive a narrow allow-list: write the receipt at intake, read it only for authorized processing or restore, and remove it only through the selected retention control. Avoid broad wildcard permissions that make every service in the account a receipt reader.
For an app-owned worker, the policy intent can be reviewed as typed configuration before it is translated into a platform-specific policy document:
type Capability = "write" | "read" | "delete"; const receiptPolicy = { bucket: "marketplace-receipt-archive", publicAccess: false, grants: [ { identity: "receipt-ingest", prefix: "receipts/", capabilities: ["write"] }, { identity: "receipt-restore", prefix: "receipts/", capabilities: ["read"] }, { identity: "retention-controller", prefix: "receipts/", capabilities: ["delete"] }, ] satisfies Array<{ identity: string; prefix: string; capabilities: Capability[] }>, }; void receiptPolicy; Keep backup restoration off the normal download path. An authorized service can create a short-lived, logged retrieval path after it has checked the request. The exact mechanism depends on the chosen object store, so review that platform's access-control documentation instead of copying a policy from a different provider.
4. Test the expiry boundary and alert on the gap
The dangerous test is the one that only uploads and downloads a file. Test the boundary at 29 days, at the selected 30-day expiry moment, and after the storage platform's documented lifecycle evaluation window. The retention control may be scheduled rather than instantaneous; an alert should account for that documented window instead of flagging every object at the first second past expiresAt.
Track four numbers daily: receipt objects older than their configured expiry, catalog rows without an object, objects without a catalog row, and deletion observations. A sudden rise in any one of them gives the operator a concrete investigation path. A dashboard that only charts total bytes does not prove a deletion policy is working.
Make the daily check usable during an ordinary on-call shift. Start with the count of objects that are past expiresAt, then sample their catalog records rather than opening receipt files. If the catalog says an object is expired but the object remains, first check the deployed lifecycle policy revision and the provider's documented evaluation window. If the object is gone but the catalog is still live, mark the deletion observation and investigate why reconciliation lagged. If objects lack catalog rows, identify the writer identity and the prefix involved; this often points to a bypass of the normal intake path, which is a more useful finding than a generic retention alert. Record the query time, policy revision, count, and resulting ticket or change record. The resulting dashboard tells an operator where the gap is: policy, catalog, object inventory, or authorization. It also gives a reviewer evidence that the 30-day rule is operating as designed without exposing the receipts themselves.
For the worker option, emit an event with the object key's non-sensitive identifier, the scheduled expiry, the attempt time, and the result class. Do not log receipt contents or signed retrieval URLs. OWASP's guidance on file uploads is a useful reminder that file handling includes storage and access controls, not only input validation.
One small test catches a common mistake: force a duplicate run and assert that the catalog ends with one deletion observation. Another tests a missing object. Both outcomes are expected states in a distributed system, not excuses to skip reconciliation.
5. Limits: when a 30-day private archive is the wrong choice
Thirty days is unsuitable when accounting, tax, dispute, or contractual rules require a longer hold. In that case, keep the bucket private but use the approved retention schedule and document the policy owner. A lifecycle rule should not override a legal obligation just because it is easy to configure.
A single shared bucket can also be the wrong boundary for a marketplace with strong tenant isolation requirements. Separate prefixes and carefully scoped identities may be sufficient for some teams; separate buckets or accounts can make isolation and review clearer for others, with more operational overhead.
Finally, do not use a backup archive as a general document store. A receipt processing system needs a clear source of truth, a restoration procedure, and a deletion record. The archive is there for a bounded audit purpose.