Create Ledger Entries

How to Create Ledger Entries via API

This guide will help you create accounting entries (écritures comptables) in Pennylane through our API. We'll go through each step with examples and best practices.

Prerequisites

Before creating ledger entries, you need an OAuth token with ledger scope

1. Identify the Right Journal

First, you need to identify or create the journal where you want to record your entries.

1.1 Get Journals List

curl --request GET \
     --url 'https://app.pennylane.com/api/external/v2/journals' \
     --header 'accept: application/json' \
     --header 'authorization: Bearer xxx'

Response example:

{
  "items": [
    {
      "code": "HA",
      "id": 123456,
      "label": "Achats"
    }
  ]
}

📘

Keep the journal_id for the next steps. Common journals are:

  • HA: Purchases journal
  • VT: Sales journal
  • BQ: Bank journal
  • OD: Operations Diverses (General journal)

2. Get Ledger Accounts

Each entry line must reference a valid ledger account. Let's get the accounts you need.

2.1 Search for Accounts

Example to find bank account (512):

curl --request GET \
     --url 'https://app.pennylane.com/api/external/v2/ledger_accounts?filter=[{"field":"number","operator":"start_with","value":"512"}]' \
     --header 'accept: application/json' \
     --header 'authorization: Bearer xxx'

Response:

{
  "items": [
    {
      "id": 98765,
      "number": "512000",
      "label": "Banque",
      "enabled": true
    }
  ]
}

📘

Common account prefixes:

  • 411: Customer accounts
  • 401: Supplier accounts
  • 512: Bank accounts
  • 706: Revenue accounts
  • 607: Purchase accounts

⚠️

Several IDs can be available in the response for a unique ledger account, take a look at this guide for more informations.

3. Create Your Entry Layout

Let's look at a simple example: recording a customer payment.

3.1 Entry Structure

  • Debit bank account (512)
  • Credit customer account (411)
  • Must be balanced (total debit = total credit)

4. Post Your Entry

4.1 Basic Entry

curl --request POST \
     --url https://app.pennylane.com/api/external/v2/ledger_entries \
     --header 'accept: application/json' \
     --header 'authorization: Bearer xxx' \
     --header 'content-type: application/json' \
     --data '{
       "date": "2025-01-15",
       "label": "Customer payment - Invoice F2025-001",
       "journal_id": 123456,
       "ledger_entry_lines": [
         {
           "debit": "1000.00",
           "credit": "0.00",
           "ledger_account_id": 98765,
           "label": "Bank payment received"
         },
         {
           "debit": "0.00",
           "credit": "1000.00",
           "ledger_account_id": 87654,
           "label": "Customer invoice settlement"
         }
       ]
     }'

Success Response (201):

{
  "id": 456789,
  "label": "Customer payment - Invoice F2025-001",
  "date": "2025-01-15",
  "journal_id": 123456,
  "ledger_entry_lines": [...]
}

4.2 Entry with Attachment

  1. First, upload your supporting document:
curl --request POST \
     --url https://app.pennylane.com/api/external/v2/ledger_attachments \
     --header 'authorization: Bearer xxx' \
     --header 'content-type: multipart/form-data' \
     --form filename=payment.pdf \
     --form file='@payment.pdf'
  1. Then create the entry with the attachment:
curl --request POST \
     --url https://app.pennylane.com/api/external/v2/ledger_entries \
     --header 'authorization: Bearer xxx' \
     --data '{
       "date": "2025-01-15",
       "label": "Customer payment with proof",
       "journal_id": 123456,
       "ledger_attachment_id": 34567,
       "ledger_entry_lines": [...]
     }'

5. Validate Entry Balance

⚠️

The sum of debits must equal the sum of credits. If not, you'll get a 422 error:

{
  "status": 422,
  "error": "Entry lines are not balanced"
}

6. Handle Multi-Currency Entries

For entries in foreign currencies:

{
  "date": "2025-01-15",
  "label": "USD Payment received",
  "journal_id": 123456,
  "currency": "USD",
  "ledger_entry_lines": [...]
}

7. Track Changes

To monitor entry modifications:

curl --request GET \
     --url 'https://app.pennylane.com/api/external/v2/changelogs/ledger_entry_lines?start_date=2025-01-01T00:00:00Z' \
     --header 'authorization: Bearer xxx'

📘

Best Practices

  • Store entry IDs for future reference
  • Use clear, descriptive labels
  • Include supporting documents when available
  • Verify account IDs before using them
  • Keep entries balanced
  • Use the changelog API for synchronization

⚠️

Important Notes

  • Maximum 1000 lines per entry
  • Amounts must use "." as decimal separator
  • Dates must be in YYYY-MM-DD format
  • Entry lines must be balanced
  • You are responsible for data quality and avoiding duplicates

Need help? Contact support with your entry ID for troubleshooting.