# POST /api/v1/ledgers

> Create ledger

- **Tag:** ledgers
- **Operation ID:** `create_ledger_api_v1_ledgers_post`

## Description

Create a new account in the chart of accounts.

## Authentication

Bearer token in `Authorization` header.
Required header: `x-business-id: <business uuid>`.

## Request body

Schema: `LedgerCreateRequest`

- `name` (string · required) — Ledger name (e.g., 'Operating Cash', 'Sales Revenue').
- `currency` (string) — Currency for this account (USD, CAD, AUD, EUR, or GBP). Defaults to business default.
- `editable` (boolean) — Whether journal entries can be manually posted to this account.
- `type` (string) — Account type: asset, liability, equity, revenue, expense. Required in Custom Mode.
- `description` (string) — Optional description of the account's purpose.
- `status` (string) — Account status: 'active' or 'inactive'. Inactive accounts hidden from dropdowns.
- `debit_credit` (string) — Normal balance: 'debit' (assets/expenses) or 'credit' (liabilities/equity/revenue). Required in Custom Mode.
- `sort_code` (integer) — Sort code for chart ordering (e.g. 1000 for assets, 4000 for revenue). Required in Custom Mode.
- `sub_type` (string) — Sub-classification (current_assets, operating_expenses, etc.). Required in Custom Mode.
- `report_cash_flow` (boolean) — Include in cash flow statement. Required in Custom Mode.
- `financial_account_type` (string) — Templated Mode: bank_account, credit_card, payments, payroll, loan, prepaid_card, accounts_receivable, accounts_payable.
- `parent_id` (string) — UUID of parent ledger for sub-accounts (e.g., 'Operating Expenses' → 'Office Supplies').
- `cfs_class` (CashFlowClassEnum) — Indirect-method cash flow classification. Determines which row of the Statement of Cash Flows this account populates. If omitted, the system derives it from `type`/`sub_type`/`financial_account_type` on first save; un-derivable rows must be set explicitly to pass cash-flow validation.

## Responses

### 201 — Successful Response

Schema: `LedgerResponse`

- `id` (string · required) — Ledger UUID.
- `teal_ledger_id` (string) — Linked Teal accounting system ID.
- `name` (string · required) — Account name.
- `currency` (string) — Currency for this account (USD, CAD, AUD, EUR, or GBP).
- `type` (string · required) — Account type: asset, liability, equity, revenue, expense.
- `balance` (integer) — Current balance in cents (may be negative).
- `parent_id` (string) — Parent ledger UUID for sub-accounts.
- `description` (string) — Account description.
- `status` (string) — Status: 'active' or 'inactive'.
- `debit_credit` (string) — Normal balance: 'debit' or 'credit'.
- `sort_code` (string) — Sort code for chart ordering.
- `sub_type` (string) — Sub-classification for reporting.
- `report_cash_flow` (boolean) — Whether included in cash flow statement.
- `cash_flow_section` (CashFlowSectionEnum) — Cash flow statement section: 'operating', 'investing', 'financing', or 'excluded'.
- `cfs_class` (CashFlowClassEnum) — Indirect-method cash flow classification used to populate the Statement of Cash Flows.
- `editable` (boolean) — Whether journal entries can be manually posted to this account.
- `financial_account_type` (string) — Template type if created in Templated Mode.
- `is_required` (boolean) — True for system-required accounts that cannot be deleted.
- `system_key` (string) — Immutable key for system/base ledgers (e.g. 'accounts_receivable'). Null for user-created ledgers.
- `teal_account_link_id` (string) — UUID of the TealAccountLink if this ledger is connected to a bank/Plaid source account. Null for unlinked ledgers.
- `business_id` (string) — Business UUID.
- `created_at` (string · date-time) — Creation timestamp.
- `updated_at` (string · date-time) — Last update timestamp.

### 400 — Bad Request - Invalid input

### 401 — Unauthorized - Authentication required

### 403 — Forbidden - Insufficient permissions

### 422 — Validation Error

Schema: `HTTPValidationError`

- `detail` (array · ValidationError) → `ValidationError`
  - `loc` (array · string | integer · required)
  - `msg` (string · required)
  - `type` (string · required)
  - `input` (object)
  - `ctx` (object)

## Code samples

### cURL

```bash
curl -X POST 'https://api.ondayzero.com/api/v1/ledgers' \
  -H 'Authorization: Bearer dz_your_token' \
  -H 'x-business-id: YOUR_BUSINESS_ID' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "string"
}'
```

### JavaScript

```javascript
const response = await fetch('https://api.ondayzero.com/api/v1/ledgers', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer dz_your_token',
    'x-business-id': 'YOUR_BUSINESS_ID',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
  "name": "string"
}),
});
const data = await response.json();
```

### Python

```python
import httpx

headers = {
    "Authorization": "Bearer dz_your_token",
    "x-business-id": "YOUR_BUSINESS_ID",
}

payload = {
  "name": "string"
}

response = httpx.post("https://api.ondayzero.com/api/v1/ledgers", headers=headers, json=payload)
data = response.json()
```

## See also

- HTML version: https://www.ondayzero.com/docs/reference/ledgers/create-ledger
- OpenAPI slice: https://www.ondayzero.com/docs/reference/ledgers/create-ledger/openapi.json
- Other endpoints in **ledgers**: https://www.ondayzero.com/docs/reference/ledgers
