Ledger API Reference

Manage financial ledgers, account balances, and ledger-related operations in the accounting system.

Base Path: /api/ledger

Overview

The Ledger API provides endpoints for managing financial records including ledger entry creation, retrieval, balance tracking, and export functionality. Supports comprehensive financial reporting and reconciliation.

Key Operations


API Endpoints

POST /api/ledger

Create Ledger Entry

Creates a new ledger entry for financial transaction.

Authentication

Bearer Token or Service Token

Request Body

{
  "customerId": "cust_123",
  "transactionDate": "2026-06-02T10:30:00Z",
  "documentType": "invoice",
  "documentId": "inv_789",
  "description": "Invoice payment received",
  "debit": 329.98,
  "credit": 0,
  "balance": 329.98,
  "currency": "USD",
  "reference": "INV-2026-001"
}

Response

{
  "id": "ledger_1234",
  "customerId": "cust_123",
  "transactionDate": "2026-06-02T10:30:00Z",
  "debit": 329.98,
  "balance": 329.98,
  "createdAt": "2026-06-02T10:30:00Z"
}
GET /api/ledger/{id}

Get Ledger Entry by ID

Gets ledger entry details by ID.

Authentication

Bearer Token or Service Token

Path Parameters

Parameter Type
id string

Response

{
  "id": "ledger_1234",
  "customerId": "cust_123",
  "transactionDate": "2026-06-02T10:30:00Z",
  "documentType": "invoice",
  "documentId": "inv_789",
  "description": "Invoice payment received",
  "debit": 329.98,
  "credit": 0,
  "balance": 329.98,
  "currency": "USD",
  "reference": "INV-2026-001",
  "createdAt": "2026-06-02T10:30:00Z"
}
GET /api/ledger

List Ledger Entries

Gets all ledger entries with filtering and pagination.

Authentication

Bearer Token or Service Token

Query Parameters

Parameter Type Description
$filter string OData filter expression
$orderby string Sort by columns
$skip integer Skip n records
$top integer Take n records

Response

{
  "value": [
    {
      "id": "ledger_1234",
      "customerId": "cust_123",
      "transactionDate": "2026-06-02T10:30:00Z",
      "documentType": "invoice",
      "debit": 329.98,
      "balance": 329.98,
      "reference": "INV-2026-001"
    }
  ],
  "count": 500
}
POST /api/ledger/export

Export Ledger Data

Exports ledger transactions to CSV or Excel format.

Authentication

Bearer Token or Service Token

Request Body

{
  "format": "csv",
  "filters": {
    "customerId": "cust_123",
    "startDate": "2026-01-01",
    "endDate": "2026-06-02"
  },
  "columns": ["id", "transactionDate", "documentType", "description", "debit", "credit", "balance"]
}

Response

File download (CSV/Excel)

GET /api/ledger/{customerId}/balance

Get Account Balance

Gets current account balance for a customer.

Authentication

Bearer Token or Service Token

Path Parameters

Parameter Type
customerId string

Response

{
  "customerId": "cust_123",
  "currentBalance": 1234.56,
  "currency": "USD",
  "lastUpdateDate": "2026-06-02T10:30:00Z",
  "totalDebits": 5000.00,
  "totalCredits": 3765.44
}
GET /api/ledger/document-types

Get Document Types

Gets all available ledger document types.

Authentication

Bearer Token or Service Token

Response

{
  "documentTypes": [
    {
      "id": "invoice",
      "name": "Invoice",
      "description": "Sales invoice ledger entries"
    },
    {
      "id": "receipt",
      "name": "Receipt",
      "description": "Payment receipt ledger entries"
    },
    {
      "id": "credit_memo",
      "name": "Credit Memo",
      "description": "Credit memo ledger entries"
    },
    {
      "id": "debit_memo",
      "name": "Debit Memo",
      "description": "Debit memo ledger entries"
    }
  ]
}

Error Responses

Code HTTP Status Description
LEDGER_ENTRY_NOT_FOUND 404 Ledger entry does not exist
CUSTOMER_NOT_FOUND 404 Customer does not exist
INVALID_AMOUNT 400 Invalid debit or credit amount
INVALID_DOCUMENT_TYPE 400 Invalid document type

Quick Links