API cookbook
Bulk import loans via MISMO 3.4
Idempotent bulk import using fingerprint dedup. Parallel, rate-limited, fail-soft.
intermediateTypeScript · Node.js
The single-loan import endpoint is the recommended bulk path. It's idempotent on payload fingerprint (SHA-256), so retries are free. Rate-limit yourself with a small concurrency pool so you don't stampede api-service.
import pLimit from "p-limit";
const limit = pLimit(8);
const files = await fs.readdir("./loans");
const results = await Promise.all(
files.map((f) =>
limit(async () => {
const xml = await fs.readFile(`./loans/${f}`, "utf-8");
const res = await fetch(
"https://api.ratestack.com/v1/loans/import?ownerUserId=" +
encodeURIComponent(OWNER) +
"&importedByUserId=" + encodeURIComponent(ME) +
"&sourceSystem=encompass",
{
method: "POST",
headers: {
"X-API-Key": KEY,
"Content-Type": "application/xml",
},
body: xml,
},
);
return { file: f, status: res.status, body: await res.json() };
}),
),
);
const failures = results.filter(r => r.status >= 400 && r.status !== 422);422 responses (validation failures) are not retriable — the payload is malformed. Surface them to the operator. 5xx are retriable; the fingerprint protects against double-creation.