Accounting Data Model: How Entities Connect

Understanding how accounting entities relate to each other is essential for building a correct integration. This guide explains the Apideck unified accounting data model, how entities reference each other, and how data flows through the system.


Entity Relationship Overview

The Apideck Accounting API models the core entities found across all major accounting systems. Here's how they connect:

Company
├── Ledger Accounts (chart of accounts)
├── Customers
├── Suppliers
├── Tax Rates
├── Tracking Categories
│
├── Accounts Receivable (AR)
│   ├── Invoices → line items ref accounts
│   │   ├── Payments (via allocations)
│   │   └── Credit Notes (refunds)
│   └── Aged Debtors (aging analysis)
│
├── Accounts Payable (AP)
│   ├── Bills → line items ref accounts
│   │   └── Bill Payments (via allocations)
│   ├── Expenses (already-paid transactions)
│   ├── Purchase Orders
│   └── Aged Creditors (aging analysis)
│
├── General Ledger
│   ├── Journals (groupings/books)
│   └── Journal Entries (debit/credit pairs)
│
├── Banking
│   ├── Bank Accounts
│   ├── Bank Feed Accounts
│   └── Bank Feed Statements
│
├── Financial Reporting
│   ├── Profit and Loss
│   └── Balance Sheet
│
└── Organization
    ├── Departments
    ├── Locations
    └── Subsidiaries

Every transaction entity (invoices, bills, expenses, journal entries) references ledger accounts via account_id on line items. Payments link to their parent transaction via allocations. Tax rates and tracking categories are applied at the line-item level.


Core Entities

Ledger Accounts (Chart of Accounts)

The chart of accounts is the foundation of every accounting system. All transactions ultimately reference ledger accounts.

FieldDescription
idUnique identifier
nominal_codeAccount number/code (e.g., "6200")
nameAccount name (e.g., "Travel Expenses")
typeAccount type: asset, liability, equity, revenue, expense, bank, other
sub_typeMore specific classification
statusactive or archived
currencyAccount currency

API: GET /accounting/ledger-accounts

Referenced by: Invoices, Bills, Expenses, Journal Entries, Payments (as line item account_id or payment account)


Invoices (Accounts Receivable)

Invoices represent money owed to your customer's business from their clients.

FieldDescriptionReferences
idUnique identifier
customer_idWho owes the moneyCustomer
line_items[].account_idRevenue account for each lineLedger Account
line_items[].tax_rate_idTax rate appliedTax Rate
line_items[].tracking_categoriesCategorization dimensionsTracking Categories
ledger_account_idDefault receivable accountLedger Account

API: GET /accounting/invoices

Status flow: draftauthorisedpaid (status is computed based on payment allocations)


Bills (Accounts Payable)

Bills represent money your customer's business owes to suppliers/vendors.

FieldDescriptionReferences
idUnique identifier
supplier_idWho is owed the moneySupplier
line_items[].account_idExpense account for each lineLedger Account
line_items[].tax_rate_idTax rate appliedTax Rate
line_items[].tracking_categoriesCategorization dimensionsTracking Categories

API: GET /accounting/bills

Status flow: draftauthorisedpaid


Payments (Accounts Receivable)

Payments record money received against invoices.

FieldDescriptionReferences
idUnique identifier
customer_idWho made the paymentCustomer
account.idBank account receiving paymentLedger Account (type: bank)
allocations[].idInvoice being paidInvoice
allocations[].amountAmount applied to that invoice

API: GET /accounting/payments

Key concept: A single payment can be allocated across multiple invoices (partial payments and overpayments are handled via allocations).


Bill Payments (Accounts Payable)

Bill payments record money paid against bills.

FieldDescriptionReferences
idUnique identifier
supplier_idWho received the paymentSupplier
account.idBank account used for paymentLedger Account (type: bank)
allocations[].idBill being paidBill
allocations[].amountAmount applied to that bill

API: GET /accounting/bill-payments


Expenses

Expenses represent purchases that are already paid (cash, credit card, or check transactions).

FieldDescriptionReferences
idUnique identifier
account_idPayment account (bank/card)Ledger Account (type: bank)
supplier_idMerchant or vendorSupplier
line_items[].account_idExpense category accountLedger Account (type: expense)
line_items[].tax_rate_idTax rate appliedTax Rate
line_items[].tracking_categoriesCategorization dimensionsTracking Categories

API: GET /accounting/expenses


Journal Entries

Journal entries are the most fundamental accounting record — every transaction in an accounting system ultimately creates journal entries with debits and credits that must balance.

FieldDescriptionReferences
idUnique identifier
journal_idParent journal/bookJournal
line_items[].account_idAccount being debited or creditedLedger Account
line_items[].typedebit or credit
line_items[].tracking_categoriesCategorization dimensionsTracking Categories

API: GET /accounting/journal-entries

Key rule: Total debits must equal total credits in every journal entry.


Journals

Journals are groupings or books that organize journal entries (e.g., "Sales Journal", "Purchase Journal", "General Journal").

FieldDescription
idUnique identifier
nameJournal name

Relationship: Journals contain Journal Entries (journal_entry.journal_idjournal.id). Journals are referenced via the journal_id field on journal entries rather than through a separate API endpoint.


Credit Notes

Credit notes represent refunds or adjustments against invoices (AR).

FieldDescriptionReferences
idUnique identifier
customer_idCustomer receiving the creditCustomer
line_items[].account_idAccount for the creditLedger Account
allocations[].idInvoice being creditedInvoice

API: GET /accounting/credit-notes


Purchase Orders

Purchase orders represent approved requests to buy goods or services from suppliers. They precede bills in the procurement workflow.

FieldDescriptionReferences
idUnique identifier
supplier_idVendor fulfilling the orderSupplier
line_items[].account_idExpense account for each lineLedger Account
line_items[].tax_rate_idTax rate appliedTax Rate

API: GET /accounting/purchase-orders


Banking

Bank Accounts

Bank accounts represent the financial accounts held at banks or financial institutions.

FieldDescriptionReferences
idUnique identifier
account_idLinked ledger accountLedger Account (type: bank)
currencyAccount currency
institution_nameBank name

API: GET /accounting/bank-accounts

Bank Feed Accounts & Statements

Bank feeds enable automatic import of bank transactions into the accounting system. Bank feed accounts represent connected bank accounts, and bank feed statements contain the individual transactions.

APIs: GET /accounting/bank-feed-accounts | GET /accounting/bank-feed-statements

See the Xero Bank Feeds guide for a detailed implementation walkthrough.


Financial Reporting

Profit and Loss

The profit and loss (P&L) statement summarizes revenues, costs, and expenses over a period — showing whether the business made a profit or loss.

API: GET /accounting/profit-and-loss

Balance Sheet

The balance sheet provides a snapshot of assets, liabilities, and equity at a specific point in time.

API: GET /accounting/balance-sheet

Aged Debtors & Aged Creditors

Aging reports show outstanding AR (debtors) and AP (creditors) broken down by how long they've been outstanding — essential for cash flow management.

APIs: GET /accounting/aged-debtors | GET /accounting/aged-creditors


Supporting Entities

EntityPurposeAPI
CustomersCounterparties for AR (invoices, payments)GET /accounting/customers
SuppliersCounterparties for AP (bills, bill payments, expenses)GET /accounting/suppliers
Tax RatesVAT/GST rates applied to line itemsGET /accounting/tax-rates
Tracking CategoriesDimensions like departments, projects, locationsGET /accounting/tracking-categories
DepartmentsOrganizational departments for categorizationGET /accounting/departments
LocationsBusiness locations for multi-site trackingGET /accounting/locations
SubsidiariesLegal entities within a multi-company setupGET /accounting/subsidiaries
AttachmentsReceipts and documents linked to transactionsPOST /accounting/attachments
Invoice ItemsProduct/service catalog items for invoicesGET /accounting/invoice-items

Common Workflows

Expense Reconciliation Flow

This is the most common workflow for expense management platforms:

1. Create Bill ──────────────────────┐
   POST /accounting/bills            │
   (references: supplier_id,         │
    line_items[].account_id,         │ Returns bill.id
    line_items[].tax_rate_id)        │
                                     │
2. Create Bill Payment ◀─────────────┘
   POST /accounting/bill-payments
   (references: account.id = bank account,
    allocations[].id = bill.id,
    allocations[].amount)

   → Bill status automatically updates to "paid"

Invoice Payment Flow

1. Create Invoice ───────────────────┐
   POST /accounting/invoices         │
   (references: customer_id,         │ Returns invoice.id
    line_items[].account_id)         │
                                     │
2. Create Payment ◀──────────────────┘
   POST /accounting/payments
   (references: account.id = bank account,
    allocations[].id = invoice.id,
    allocations[].amount)

   → Invoice status automatically updates to "paid"

Direct Journal Entry Flow

For advanced use cases where you need full control over debits and credits:

POST /accounting/journal-entries
{
  "journal_id": "purchase-journal",
  "line_items": [
    { "account_id": "6200", "type": "debit",  "total_amount": 100.00 },
    { "account_id": "1000", "type": "credit", "total_amount": 100.00 }
  ]
}

How Entities Map Across Providers

Apideck EntityQuickBooksXeroExact OnlineNetSuite
Ledger AccountAccountAccountGLAccountAccount
InvoiceInvoiceInvoiceSalesEntryInvoice
BillBillBillPurchaseEntryVendor Bill
Credit NoteCredit MemoCredit NoteCredit Memo
PaymentPaymentPaymentReceivablesListCustomer Payment
Bill PaymentBill PaymentPayment (AP)PayablesListVendor Payment
ExpensePurchaseBank Transaction❌ (use Bill)Expense Report
Purchase OrderPurchase OrderPurchase OrderPurchaseOrderPurchase Order
Journal EntryJournal EntryManual JournalGeneral Journal EntryJournal Entry
CustomerCustomerContact (customer)Account (customer)Customer
SupplierVendorContact (supplier)Account (supplier)Vendor
Profit and LossProfit and LossProfit and LossIncome Statement
Balance SheetBalance SheetBalance SheetBalance Sheet

ID References in API Responses

Every entity includes IDs that reference related entities. Here's how to follow the chain:

// Fetch a bill
const bill = await apideck.accounting.billsOne({ id: 'bill-123' })

// Follow references
const supplier = await apideck.accounting.suppliersOne({
  id: bill.data.supplier_id
})

// Get account details for each line item
for (const item of bill.data.line_items) {
  const account = await apideck.accounting.ledgerAccountsOne({
    id: item.account_id
  })
  console.log(`${item.description}: ${account.data.name} (${account.data.nominal_code})`)
}

// Find payments for this bill
const billPayments = await apideck.accounting.billPaymentsAll()
const paymentsForBill = billPayments.data.filter((p) =>
  p.allocations?.some((a) => a.id === 'bill-123')
)