Payroll posting
For a separate payroll system to book its pay runs. You send the per-run totals as semantic lines (salary_expense, pf_payable, …); FinzBooks maps each to a ledger, creates the standard ones that are missing, and posts one balanced journal. You never need the organization's account ids.
Posting and requesting ledgers use AIBooks.journals.CREATE; reading uses AIBooks.journals.READ. There is no separate payroll scope. These routes do not require an Idempotency-Key: idempotency comes from the reference you send (below).
How a run is booked
POST /payroll/runswith the run's lines. Costs (debits) must equal payables (credits).- Later,
POST /payroll/settlementswhen the payables are paid out of a bank or cash account.
/payroll/ledger-mapLine-type vocabularytoken only (no scope check)Returns each standard line type with the ledger it maps to, its account type and its natural side. Needs a valid token for an organization but no particular scope.
200 OK
{
"code": 0,
"message": "success",
"payroll_ledger_map": {
"types": [
{ "type": "salary_expense", "ledger": "Salaries & Wages", "account_type": "EXPENSE", "side": "debit" },
{ "type": "net_pay_payable", "ledger": "Net Salary Payable", "account_type": "CURRENT_LIABILITIES", "side": "credit" },
…
],
"note": "Unknown types must supply ledger + ledger_type + side to map a custom head."
}
}The standard types:
- Debit (cost):
salary_expense,wages_expense,bonus_expense,overtime_expense,employer_pf_expense,employer_esi_expense,gratuity_expense,staff_welfare_expense,reimbursement_expense - Credit (payable):
net_pay_payable,reimbursement_payable,pf_payable,esi_payable,pt_payable,tds_payable,lwf_payable,gratuity_payable - Credit (recovery against an asset):
loan_recovery,salary_advance_recovery
/payroll/runsPost a payroll runAIBooks.journals.CREATE| Field | Type | Notes |
|---|---|---|
period | string | Required. Label, e.g. 2026-06. |
pay_date | date | Required. Posting date of the journal. |
reference | string | Required, 1 – 120 characters. Your unique pay-run reference. See idempotency below. |
lines[] | array | Required, at least one. |
memo | string? |
Line
| Field | Type | Notes |
|---|---|---|
type | string | Required. A standard type, or a custom head (then ledger, ledger_type and side are required). |
amount | float | Required, greater than 0. |
side | string? | debit or credit. Defaults from the type. |
ledger | string? | Post to this ledger name instead of the standard one. |
ledger_type | string? | Account type for an overridden or new ledger, e.g. EXPENSE. |
party | string? | Per-person sub-ledger, e.g. an employee owed a reimbursement. Appends “— name” to the ledger name. |
note | string? | Line description. |
Extra fields on the body or on a line are ignored, not rejected.
POST /payroll/runs
Authorization: Bearer aibk_pat_…
Content-Type: application/json
{
"period": "2026-06",
"pay_date": "2026-06-30",
"reference": "PAYRUN-2026-06",
"lines": [
{ "type": "salary_expense", "amount": 500000 },
{ "type": "employer_pf_expense", "amount": 30000 },
{ "type": "net_pay_payable", "amount": 440000 },
{ "type": "pf_payable", "amount": 60000 },
{ "type": "tds_payable", "amount": 30000 }
]
}
200 OK
{
"code": 0,
"message": "success",
"payroll_run": {
"reference": "PAYRUN-2026-06",
"journal_id": "je_…",
"period": "2026-06",
"posted": true,
"idempotent_replay": false,
"total_debit": 530000.0,
"total_credit": 530000.0,
"line_count": 5,
"created_ledgers": []
}
}Behaviour
- Idempotent per
reference. Posting the same reference again does not post twice; it returns the existing run withidempotent_replay: true. The reference is stored on the journal, so use one that is unique per run, and do not reuse a run's reference as a settlement reference. - Standard ledgers are created automatically (listed in
created_ledgers). - Custom heads need approval. A line that overrides the ledger, uses
party, or has an unknown type points at a ledger that may not exist. If it does not, a ledger request is filed and the run is not posted: you getposted: false,journal_id: null, apending_ledgerslist (name,request_id,status) and a message. After an admin approves in the app, post the samereferenceagain and it goes through. - Debits must equal credits to the paisa.
Notable errors
400 payroll.invalid— unknown type with no override; unbalanced run (the message gives both totals); no postable lines.
/payroll/runs/{reference}Get a posted runAIBooks.journals.READ200 OK
{
"code": 0,
"message": "success",
"payroll_run": {
"reference": "PAYRUN-2026-06",
"journal_id": "je_…",
"posted": true,
"date": "2026-06-30T00:00:00",
"memo": null,
"total_debit": 530000.0,
"total_credit": 530000.0,
"line_count": 5
}
}Unknown reference: 404 payroll.not_found. A run that is still waiting for ledger approval has no journal and returns this 404.
/payroll/settlementsSettle payables to bank or cashAIBooks.journals.CREATEDebits the payable ledgers and credits the paid-through account in one journal.
| Field | Type | Notes |
|---|---|---|
date | date | Required. |
paid_through | string | Required. Bank or cash ledger, by name or id. |
lines[] | array | Required. Each has type (the payable being settled), amount (greater than 0), and optional ledger, party, note. |
reference | string? | Optional. When sent, posting it again returns the existing journal with idempotent_replay: true. Without it, every call posts a new journal. |
memo | string? |
200 OK
{
"code": 0,
"message": "success",
"payroll_settlement": {
"reference": "PAYRUN-2026-06-PAID",
"journal_id": "je_…",
"posted": true,
"idempotent_replay": false,
"total": 440000.0,
"created_ledgers": []
}
}Errors: 400 payroll.invalid if the paid-through account is not found, a line type is unknown with no ledger, or there is nothing to post.
Ledger requests
Ask the accounting admin to create a ledger ahead of time, then poll until it is approved.
/payroll/ledger-requestsRequest a new ledgerAIBooks.journals.CREATE| Field | Type | Notes |
|---|---|---|
name | string | Required. Ledger name, e.g. Fuel & Petrol. |
type | string | Required. Account type, e.g. EXPENSE, CURRENT_LIABILITIES, CURRENT_ASSETS. |
external_ref | string? | Your own reference; a repeat with the same value returns the earlier request. |
parent | string? | Parent ledger name to nest under. |
note | string? |
200 OK
{
"code": 0,
"message": "success",
"ledger_request": {
"request_id": "lr_…",
"status": "PENDING", // PENDING until an admin approves; APPROVED at once if the ledger exists
"name": "Fuel & Petrol",
"type": "EXPENSE",
"external_ref": "fuel-head",
"account_id": null, // set on approval
"reject_reason": null,
"created_at": "2026-06-30T09:00:00",
"reviewed_at": null
}
}An unknown account type returns 400 ledger_request.invalid.
/payroll/ledger-requestsList ledger requestsAIBooks.journals.READOptional status filter. Lists the requests that came from payroll. Not paginated, and the response is { "data": { "ledger_requests": [ … ] } } (no code or message).
/payroll/ledger-requests/{request_id}Get one ledger requestAIBooks.journals.READReturns { code: 0, ledger_request: {…} }. Poll it for account_id. Unknown id: 404 ledger_request.not_found.