API cookbook
Capture an immutable rate-quote snapshot for disclosure
Snapshot a quote at the moment of disclosure, persist it tied to the LE/CD, and reproduce on demand for audit.
intermediateTypeScript
Pricing-derived TRID disclosure fields (rate, points, lender credit) should reference an immutable quote snapshot. The pattern:
// At the moment of disclosure
const quote = await ratestack.pricing(input, { mode: "BEST_EX" });
const snapshot = {
quoteId: quote.id,
ratesheetVersion: quote.ratesheetVersion,
capturedAt: new Date().toISOString(),
correlationId: quote.correlationId,
// The full trace for audit reproducibility
trace: quote.bestEx.adjustments,
};
// Persist the snapshot keyed to the LE/CD record
await db.disclosures.insert({ leId, cdId, snapshot });
// To reproduce later: replay against the captured ratesheetVersion
const replayed = await ratestack.pricing(input, {
mode: "BEST_EX",
asOf: snapshot.capturedAt, // engine resolves the active ratesheet at that time
});
// replayed.bestEx.finalPrice should equal the disclosed priceThe replay endpoint guarantees reproduction so long as the underlying ratesheet versions remain accessible (indefinite retention is the default).