const base = "https://api.sandbox.paypathiq.com";
const clientCode = process.env.PAYPATHIQ_CLIENT_CODE;
const headers = {
Authorization: `Bearer ${process.env.PAYPATHIQ_SANDBOX_API_KEY}`,
"Content-Type": "application/json",
};
const response = await fetch(`${base}/v1/clients/${clientCode}/batches/BAT_FIRST_LOAD`, {
method: "PUT",
headers,
body: JSON.stringify({
records: [
{
recordId: "r1",
kind: "customer",
externalId: "CUS_B001",
body: { type: "person", name: { firstName: "Avery", lastName: "Example" } },
},
{
recordId: "r2",
kind: "receivable",
externalId: "REC_B001",
dependsOn: ["r1"],
body: {
financialType: "loan_balance",
sourceRevision: 1,
sourceReference: "receivable-ref-b001",
responsibleCustomers: [{ externalCustomerId: "CUS_B001", role: "primary" }],
recoverableAmount: { amount: "1250.00", currency: "EUR" },
dueDate: "2026-08-01",
creditUnion: {
loanAccountReference: "loan-ref-b001",
loanType: "personal_loan",
arrearsAmount: { amount: "1250.00", currency: "EUR" },
},
},
},
],
}),
});
console.log(response.status, await response.json());