fastify-xplaid
liabilities.get
Get credit card, mortgage, and student loan liability data for accounts on a Plaid Item.
liabilities.get
Returns liability data for credit cards, mortgages, and student loans linked to a Plaid Item — including balances, APRs, payment due dates, and loan details. Requires the liabilities product to have been enabled when creating the Link token.
Signature
fastify.xplaid.liabilities.get(
accessToken: string,
options?: {
accountIds?: string[]
}
): Promise<{
accounts: PlaidAccount[]
liabilities: {
credit: CreditCardLiability[] | null
mortgage: MortgageLiability[] | null
student: StudentLoan[] | null
}
item: PlaidItem
requestId: string
}>
Params
| Name | Type | Required | Description |
|---|---|---|---|
accessToken | string | Yes | The Item's permanent access token. |
options.accountIds | string[] | No | Restrict results to specific account IDs. Omit to return liabilities for all accounts. |
Returns
Promise<{ accounts, liabilities, item, requestId }>
liabilities.credit — CreditCardLiability[]
| Field | Type | Description |
|---|---|---|
account_id | string | Account ID for this card. |
aprs | APR[] | APR details — includes apr_type, apr_percentage, balance_subject_to_apr. |
is_overdue | boolean | null | Whether the account is currently overdue. |
last_payment_amount | number | null | Amount of the most recent payment. |
last_payment_date | string | null | Date of the most recent payment. |
last_statement_balance | number | null | Balance at last statement close. |
last_statement_issue_date | string | null | Date of last statement. |
minimum_payment_amount | number | null | Current minimum payment due. |
next_payment_due_date | string | null | Due date for the next payment. |
liabilities.mortgage — MortgageLiability[]
| Field | Type | Description |
|---|---|---|
account_id | string | Account ID for this mortgage. |
account_number | string | null | Loan account number. |
current_late_fee | number | null | Any outstanding late fee. |
interest_rate | object | { percentage, type }. |
last_payment_amount | number | null | Last payment amount. |
loan_term | string | null | Term of the loan. |
maturity_date | string | null | Loan maturity date. |
next_monthly_payment | number | null | Next scheduled payment. |
origination_date | string | null | Date the mortgage was originated. |
origination_principal_amount | number | null | Original principal. |
past_due_amount | number | null | Amount past due. |
property_address | object | null | Property address fields. |
liabilities.student — StudentLoan[]
| Field | Type | Description |
|---|---|---|
account_id | string | Account ID for this loan. |
account_number | string | null | Loan account number. |
disbursement_dates | string[] | null | Dates funds were disbursed. |
expected_payoff_date | string | null | Projected payoff date. |
guarantor | string | null | Loan guarantor name. |
interest_rate_percentage | number | Current interest rate. |
is_overdue | boolean | null | Whether overdue. |
last_payment_amount | number | null | Last payment amount. |
last_payment_date | string | null | Last payment date. |
loan_name | string | null | Name/type of the loan. |
minimum_payment_amount | number | null | Current minimum due. |
next_payment_due_date | string | null | Next payment due date. |
outstanding_interest_amount | number | null | Accrued interest not yet paid. |
servicer_address | object | null | Loan servicer address. |
Throws
[xPlaid] accessToken is required and must be a non-empty string— whenaccessTokenis missing or empty.- Plaid API errors wrapped via
wrapPlaidError— shape:{ message, statusCode, plaidError }. PRODUCTS_NOT_SUPPORTEDPlaid error ifliabilitieswas not included in the Link token's products.ITEM_LOGIN_REQUIREDPlaid error if the Item needs re-authentication.
Examples
Basic — credit card payments due
const { liabilities } = await fastify.xplaid.liabilities.get(accessToken);
if (liabilities.credit) {
for (const card of liabilities.credit) {
console.log(`Minimum due: $${card.minimum_payment_amount}`);
console.log(`Due date: ${card.next_payment_due_date}`);
console.log(`Overdue: ${card.is_overdue}`);
}
}
Realistic — debt summary route
fastify.get("/finances/debts", async (request, reply) => {
const item = await db.plaidItems.findFirst({ where: { userId: request.user.id } });
if (!item) return reply.status(404).send({ error: "No linked account" });
try {
const { accounts, liabilities } = await fastify.xplaid.liabilities.get(
decrypt(item.accessToken)
);
const accountMap = Object.fromEntries(accounts.map((a) => [a.account_id, a]));
const creditCards = (liabilities.credit ?? []).map((c) => ({
name: accountMap[c.account_id]?.name,
balance: accountMap[c.account_id]?.balances.current,
minimumDue: c.minimum_payment_amount,
dueDate: c.next_payment_due_date,
isOverdue: c.is_overdue,
apr: c.aprs?.find((a) => a.apr_type === "purchase_apr")?.apr_percentage,
}));
const studentLoans = (liabilities.student ?? []).map((l) => ({
name: l.loan_name,
interestRate: l.interest_rate_percentage,
minimumDue: l.minimum_payment_amount,
dueDate: l.next_payment_due_date,
outstandingInterest: l.outstanding_interest_amount,
payoffDate: l.expected_payoff_date,
}));
const overdueCards = creditCards.filter((c) => c.isOverdue);
if (overdueCards.length > 0) {
request.log.warn({ count: overdueCards.length }, "User has overdue credit cards");
}
return { creditCards, studentLoans, mortgages: liabilities.mortgage ?? [] };
} catch (error) {
if (error.plaidError) {
const { error_type, error_code } = error.plaidError;
if (error_type === "ITEM_ERROR") {
return reply.status(428).send({ error: "reauth_required", error_code });
}
request.log.error({ error_code }, "Liabilities fetch failed");
return reply.status(error.statusCode ?? 500).send({ error: error.message });
}
throw error;
}
});
Check for overdue accounts
const { liabilities } = await fastify.xplaid.liabilities.get(accessToken);
const overdue = [
...(liabilities.credit ?? []).filter((c) => c.is_overdue),
...(liabilities.student ?? []).filter((l) => l.is_overdue),
];
if (overdue.length > 0) {
await notifyUser(`You have ${overdue.length} overdue payment(s).`);
}
See Also
- accounts.get — Account metadata and balance snapshots.
- accounts.getBalance — Real-time balance refresh.
- investments.getHoldings — Investment portfolio data.
- link.createToken — Must include
"liabilities"inproducts. - fastify-xplaid overview — Plugin setup and options.
AI Context
package: "@xenterprises/fastify-xplaid"
method: fastify.xplaid.liabilities.get(accessToken, options?)
use-when: Get credit card, mortgage, and student loan liability data — requires "liabilities" product
returns: { liabilities: { credit, mortgage, student }, accounts }
