# Brix Accounting API — Journal Entries

Read-only API for browsing general-ledger journal entries created by the system when invoices are posted, bills are received, payments are recorded, or entries are reversed on void.

Manual journal entry creation is not supported through this API.

---

## Base URL

```
{BASE_URL}/api/v1/journal-entries
```

| Environment | Example |
|-------------|---------|
| Local | `http://127.0.0.1:8000/api/v1/journal-entries` |

---

## Authentication

All endpoints require:

| Header | Value |
|--------|-------|
| `Authorization` | `Bearer {token}` |
| `Accept` | `application/json` |

Obtain a token via `POST /api/v1/login`. See [auth-and-users.md](./auth-and-users.md).

**Middleware:** `auth:sanctum`, `company` — results are scoped to the authenticated user's company.

---

## List journal entries

```
GET /api/v1/journal-entries
```

### Query parameters

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `start_date` | date (`YYYY-MM-DD`) | No | Include entries on or after this date |
| `end_date` | date (`YYYY-MM-DD`) | No | Include entries on or before this date. Must be on or after `start_date` |
| `account_id` | integer | No | Limit to entries that touch this GL account |
| `is_auto_generated` | boolean | No | When `true`, only system-generated entries; when `false`, only manual entries (none today) |
| `reference_transaction_id` | integer | No | Limit to entries linked to this spine `transactions.id` (e.g. invoice or payment). Useful from the [sales transactions](./sales-transactions.md) hub **View journal** action |
| `per_page` | integer | No | Page size (1–100). Defaults to `50` |

### Example

```http
GET /api/v1/journal-entries?start_date=2026-06-01&end_date=2026-06-30
Authorization: Bearer {token}
Accept: application/json
```

### Response `200 OK`

```json
{
  "data": [
    {
      "id": 1,
      "je_number": "JE-0001",
      "txn_date": "2026-06-10",
      "memo": "Invoice INV-0001",
      "is_auto_generated": true,
      "reference_transaction_id": 5,
      "source": {
        "type": "INVOICE",
        "id": 1,
        "number": "INV-0001",
        "transaction_id": 5
      },
      "created_by": {
        "id": 1,
        "name": "Admin"
      },
      "totals": {
        "debit": "168.0000",
        "credit": "168.0000",
        "is_balanced": true
      },
      "lines": [
        {
          "line_number": 1,
          "account_id": 4,
          "account_number": "1100",
          "account_name": "ACCOUNTS_RECEIVABLE",
          "account_type": "ASSET",
          "account_sub_type": "ACCOUNTS_RECEIVABLE",
          "posting_type": "DEBIT",
          "amount": "118.0000",
          "entity_type": "CUSTOMER",
          "entity_id": 1,
          "description": "Invoice INV-0001"
        }
      ],
      "created_at": "2026-06-10T12:00:00.000000Z"
    }
  ],
  "meta": {
    "current_page": 1,
    "last_page": 1,
    "per_page": 50,
    "total": 2
  }
}
```

---

## Show journal entry

```
GET /api/v1/journal-entries/{id}
```

Returns a single journal entry with all lines and account details.

### Error responses

| Status | Condition |
|--------|-----------|
| `404` | Entry not found or belongs to another company |

---

## Source document types

The `source` object links a journal entry back to the business document that triggered it (via `reference_transaction_id`):

| `source.type` | Triggered by |
|---------------|--------------|
| `INVOICE` | `POST /invoices/{id}/post` or invoice void reversal |
| `BILL` | `POST /bills/{id}/receive` or bill void reversal |
| `PAYMENT` | `POST /customer-payments` |
| `BILL_PAYMENT` | `POST /bill-payments` |
| `JOURNAL_ENTRY` | Reversal of another journal entry |

---

## Related docs

- [invoices.md](./invoices.md)
- [bills.md](./bills.md)
- [customer-payments.md](./customer-payments.md)
- [bill-payments.md](./bill-payments.md)
- [reports.md](./reports.md) — [Profit and loss detail](./reports.md#profit-and-loss-detail) and [Balance sheet detail](./reports.md#balance-sheet-detail) group lines by account
