Transactions: Import transactions from CSV
import_transactions Bulk-import transactions into one account from CSV text.
Parity with the REST ``/api/v1/data/import_transactions/`` upload,
adapted for a chat agent: pass the CSV as text (not a file). All rows
are created atomically under a row lock and the account balance is
updated in one pass.
CSV format: a header row then ``date,description,amount,type``.
- date: YYYY-MM-DD (also accepts MM/DD/YYYY or MM/DD/YY)
- amount: positive number ($ and commas are stripped)
- type: deposit/income/credit → deposit; withdrawal/expense/debit →
withdrawal; blank → ``default_type``. (No transfers — import each
side as a deposit/withdrawal.)
Rows that can't be parsed are skipped and reported in ``errors``;
valid rows still import.
On debt accounts the deposit/withdrawal meaning is inverted (a
``deposit`` is a charge that increases the debt,
a ``withdrawal`` is a payment that decreases it) — the balance math is
identical either way. Future-dated rows are created but not applied to
the balance until their date arrives (matching single-transaction
creation).
Args:
account_id: Target account (the caller's own, active).
csv_text: The CSV content as a string (header + rows). Max 1000
rows per call — split larger files.
default_type: Type for rows with a blank ``type`` column
("deposit" or "withdrawal", default "withdrawal").
Returns:
``{"success": True, "imported_count": N, "error_count": M,
"errors": [...up to 20...], "new_account_balance": ...,
"account_name": ...}`` on success, or ``{"error": "..."}`` (account
not found, empty/invalid CSV, monthly-limit exceeded, or no valid
rows).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| csv_text | Yes | ||
| account_id | Yes | ||
| default_type | No | withdrawal |