# POST /api/v1/journal-entries

> Create journal entry

- **Tag:** journal-entries
- **Operation ID:** `create_journal_entry`

## Description

Create a new double-entry journal entry with balanced line entries.

## Authentication

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

## Request body

Schema: `JournalEntryCreateRequest`

- `description` (string) — Human-readable description of the journal entry. Should describe the transaction being recorded.
- `currency` (string) — Currency for the journal entry (USD, CAD, AUD, EUR, or GBP). Defaults to business default.
- `date` (string · date) — The date when this transaction occurred. Use ISO 8601 date format (YYYY-MM-DD).
- `line_entries` (array · JournalLineEntryCreate) — Array of line entries (minimum 2). Total debits must equal total credits. Each entry requires: amount (integer in cents), debit_credit ('debit' or 'credit'), ledger_id (UUID of target ledger account), description (what this line represents).
- `invoice_id` (string) — Optional UUID of an invoice to link this journal entry to. Useful for tracking revenue recognition.
- `inventory_order_id` (string) — Optional UUID of an inventory order (PO) to link this journal entry to. Useful for the PO audit trail.
- `combine_duplicate_lines` (boolean) — When true, lines sharing the same ledger_id, debit_credit and counterparty_name are summed into one line (descriptions joined with '; ') before validation. When false, duplicate lines are refused with VALIDATION_206.

## Example request

```json
{
  "date": "2024-01-15",
  "description": "Record sale to customer - Invoice #1234",
  "invoice_id": "019ab37c-e5b3-7c49-96e1-7c3b4d9f0e2b",
  "line_entries": [
    {
      "amount": 150000,
      "debit_credit": "debit",
      "description": "Accounts Receivable - Customer ABC",
      "ledger_id": "019ab37c-c309-7698-a8d9-14e0409977d8"
    },
    {
      "amount": 150000,
      "debit_credit": "credit",
      "description": "Sales Revenue",
      "ledger_id": "019ab37c-d4a2-7b38-85f0-6b2a3c8e9f1a"
    }
  ]
}
```

## Responses

### 201 — Successful Response

Schema: `SuccessEnvelope_JournalEntryResponse_`

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

### 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/journal-entries' \
  -H 'Authorization: Bearer dz_your_token' \
  -H 'x-business-id: YOUR_BUSINESS_ID' \
  -H 'Content-Type: application/json' \
  -d '{
  "date": "2024-01-15",
  "description": "Record sale to customer - Invoice #1234",
  "invoice_id": "019ab37c-e5b3-7c49-96e1-7c3b4d9f0e2b",
  "line_entries": [
    {
      "amount": 150000,
      "debit_credit": "debit",
      "description": "Accounts Receivable - Customer ABC",
      "ledger_id": "019ab37c-c309-7698-a8d9-14e0409977d8"
    },
    {
      "amount": 150000,
      "debit_credit": "credit",
      "description": "Sales Revenue",
      "ledger_id": "019ab37c-d4a2-7b38-85f0-6b2a3c8e9f1a"
    }
  ]
}'
```

### JavaScript

```javascript
const response = await fetch('https://api.ondayzero.com/api/v1/journal-entries', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer dz_your_token',
    'x-business-id': 'YOUR_BUSINESS_ID',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
  "date": "2024-01-15",
  "description": "Record sale to customer - Invoice #1234",
  "invoice_id": "019ab37c-e5b3-7c49-96e1-7c3b4d9f0e2b",
  "line_entries": [
    {
      "amount": 150000,
      "debit_credit": "debit",
      "description": "Accounts Receivable - Customer ABC",
      "ledger_id": "019ab37c-c309-7698-a8d9-14e0409977d8"
    },
    {
      "amount": 150000,
      "debit_credit": "credit",
      "description": "Sales Revenue",
      "ledger_id": "019ab37c-d4a2-7b38-85f0-6b2a3c8e9f1a"
    }
  ]
}),
});
const data = await response.json();
```

### Python

```python
import httpx

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

payload = {'date': '2024-01-15',
 'description': 'Record sale to customer - Invoice #1234',
 'invoice_id': '019ab37c-e5b3-7c49-96e1-7c3b4d9f0e2b',
 'line_entries': [{'amount': 150000,
                   'debit_credit': 'debit',
                   'description': 'Accounts Receivable - Customer ABC',
                   'ledger_id': '019ab37c-c309-7698-a8d9-14e0409977d8'},
                  {'amount': 150000,
                   'debit_credit': 'credit',
                   'description': 'Sales Revenue',
                   'ledger_id': '019ab37c-d4a2-7b38-85f0-6b2a3c8e9f1a'}]}

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

## See also

- HTML version: https://www.ondayzero.com/docs/reference/journal-entries/create-journal-entry
- OpenAPI slice: https://www.ondayzero.com/docs/reference/journal-entries/create-journal-entry/openapi.json
- Other endpoints in **journal-entries**: https://www.ondayzero.com/docs/reference/journal-entries (markdown bundle: https://www.ondayzero.com/docs/reference/journal-entries.md, OpenAPI: https://www.ondayzero.com/docs/reference/journal-entries/openapi.json)
- Endpoint catalog: https://www.ondayzero.com/docs/reference/index.md
