# POST /api/v1/ledgers

> Create ledger

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

## 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.
- `account_number` (string) — Optional account number/code for chart-of-accounts numbering.
- `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').
- `cash_flow_section` (CashFlowSectionEnum) — Cash flow statement section (a local-only field).
- `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.
- `depreciation_tag` (DepreciationTagEnum) — Marks this account as holding capitalizable spend: 'depreciable' or 'amortizable'. Tagged accounts can source fixed assets from their transactions.

## Example request

```json
{
  "editable": true,
  "financial_account_type": "bank_account",
  "name": "Chase Business Checking"
}
```

## Responses

### 201 — Successful Response

Schema: `SuccessEnvelope_LedgerResponse_`

- `success` (boolean)
- `message` (string)
- `code` (string)
- `data` (LedgerResponse)

### 400 — Bad Request - Invalid input

Schema: `ErrorResponse`

- `error` (string · required) — Error category: `validation_error`, `unauthorized`, `forbidden`, `not_found`, `conflict`, `rate_limited`, `server_error`, or `service_unavailable`.
- `message` (string · required) — Human-readable explanation, safe to show to end users.
- `code` (string · required) — Stable machine-readable code in `CATEGORY_NNN` form (e.g. `NOT_FOUND_006`, `AUTH_010`, `GEN_002`).
- `request_id` (string) — Correlation id for support requests. Echoes the `x-request-id` request header when one was supplied.
- `errors` (object) — Field-level validation messages keyed by field name. Present on 400/422 validation failures only.

### 401 — Unauthorized - Missing or expired token, an MCP OAuth token used against the REST API, or no access to this business

Schema: `ErrorResponse`

- `error` (string · required) — Error category: `validation_error`, `unauthorized`, `forbidden`, `not_found`, `conflict`, `rate_limited`, `server_error`, or `service_unavailable`.
- `message` (string · required) — Human-readable explanation, safe to show to end users.
- `code` (string · required) — Stable machine-readable code in `CATEGORY_NNN` form (e.g. `NOT_FOUND_006`, `AUTH_010`, `GEN_002`).
- `request_id` (string) — Correlation id for support requests. Echoes the `x-request-id` request header when one was supplied.
- `errors` (object) — Field-level validation messages keyed by field name. Present on 400/422 validation failures only.

### 403 — Forbidden - Insufficient permissions

Schema: `ErrorResponse`

- `error` (string · required) — Error category: `validation_error`, `unauthorized`, `forbidden`, `not_found`, `conflict`, `rate_limited`, `server_error`, or `service_unavailable`.
- `message` (string · required) — Human-readable explanation, safe to show to end users.
- `code` (string · required) — Stable machine-readable code in `CATEGORY_NNN` form (e.g. `NOT_FOUND_006`, `AUTH_010`, `GEN_002`).
- `request_id` (string) — Correlation id for support requests. Echoes the `x-request-id` request header when one was supplied.
- `errors` (object) — Field-level validation messages keyed by field name. Present on 400/422 validation failures only.

### 422 — Validation Error

Schema: `ErrorResponse`

- `error` (string · required) — Error category: `validation_error`, `unauthorized`, `forbidden`, `not_found`, `conflict`, `rate_limited`, `server_error`, or `service_unavailable`.
- `message` (string · required) — Human-readable explanation, safe to show to end users.
- `code` (string · required) — Stable machine-readable code in `CATEGORY_NNN` form (e.g. `NOT_FOUND_006`, `AUTH_010`, `GEN_002`).
- `request_id` (string) — Correlation id for support requests. Echoes the `x-request-id` request header when one was supplied.
- `errors` (object) — Field-level validation messages keyed by field name. Present on 400/422 validation failures only.

## 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 '{
  "editable": true,
  "financial_account_type": "bank_account",
  "name": "Chase Business Checking"
}'
```

### 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({
  "editable": true,
  "financial_account_type": "bank_account",
  "name": "Chase Business Checking"
}),
});
const data = await response.json();
```

### Python

```python
import httpx

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

payload = {'editable': True,
 'financial_account_type': 'bank_account',
 'name': 'Chase Business Checking'}

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 (markdown bundle: https://www.ondayzero.com/docs/reference/ledgers.md, OpenAPI: https://www.ondayzero.com/docs/reference/ledgers/openapi.json)
- Endpoint catalog: https://www.ondayzero.com/docs/reference/index.md
