# Transaction Management

## Export uncategorized transactions for review

To pull transactions that still need a category before you close a period, fetch JSON for the date range and filter client-side. The CLI does not support a `category=null` filter flag.

**The Script**

```bash
#!/bin/bash
# export-uncategorized.sh

WORKSPACE_ID="<workspace-id>"
SINCE="2026-01-01"
UNTIL="2026-01-31"
OUTPUT_FILE="uncategorized-$(date +%Y%m%d).json"

kick --workspace "$WORKSPACE_ID" transactions find \
  --since "$SINCE" \
  --until "$UNTIL" \
  --fields id,date,amount,counterparty,category,bank_description \
  --output json \
  | jq '[.[] | select(.category == null or .category == "")]' \
  > "$OUTPUT_FILE"

count=$(jq 'length' "$OUTPUT_FILE")

echo "Exported $count uncategorized transactions to $OUTPUT_FILE"

if [ "$count" -gt 0 ]; then
  echo "Review and update categories in Kick before closing the period"
fi
```

**How to Customize**

* Add `--limit` and follow the next-page hint in stderr when you have more rows than one page
* Pipe to CSV with `jq -r` if your team reviews in a spreadsheet
* Tighten the filter to large amounts: `select((.category == null or .category == "") and (.amount | fabs) > 1000)`

**What It Outputs**

* JSON array of uncategorized transactions
* Console message with the count

## Inspect a transaction before updating it

To review one transaction and apply a change, fetch it first. Updates require a payload file and preview confirmation.

**The Script**

```bash
#!/bin/bash
# inspect-and-update-transaction.sh

WORKSPACE_ID="<workspace-id>"
TRANSACTION_ID=12345
PAYLOAD_FILE="transaction-update.json"

echo "Current transaction (read):"
kick --workspace "$WORKSPACE_ID" transactions get "$TRANSACTION_ID" --output json | jq .

if [ ! -f "$PAYLOAD_FILE" ]; then
  echo "Create $PAYLOAD_FILE with the fields you want to change, then re-run."
  exit 1
fi

echo ""
echo "Preview update (write):"
kick --workspace "$WORKSPACE_ID" transactions update \
  --transaction-id "$TRANSACTION_ID" \
  --payload-file "$PAYLOAD_FILE"
```

**How to Customize**

* Add `--confirmation-token <token>` on a second run after you review the preview
* Log activity after the update with `kick activity list --resource-id "$TRANSACTION_ID"`

**What It Outputs**

* Full transaction JSON from the read step
* Preview output from the write step (review before confirming)

## Find duplicate transactions

To flag likely duplicates in a period, group transactions by date, amount, and counterparty.

**The Script**

```bash
#!/bin/bash
# find-duplicates.sh

WORKSPACE_ID="<workspace-id>"
SINCE="2026-01-01"
UNTIL="2026-01-31"

echo "Finding potential duplicates..."

kick --workspace "$WORKSPACE_ID" transactions find \
  --since "$SINCE" \
  --until "$UNTIL" \
  --fields id,date,amount,counterparty \
  --output json | \
jq -r '
  group_by([.date, .amount, .counterparty]) |
  map(select(length > 1)) |
  .[] |
  "Potential duplicates:\n" +
  (map("  ID: \(.id) | \(.date) | \(.amount) | \(.counterparty)") | join("\n")) +
  "\n"
'
```

**How to Customize**

* Include `bank_description` in the group key for stricter matching
* Export matches to CSV for your reconciliation worksheet
* Narrow the date range when paging through large workspaces

**What It Outputs**

```
Potential duplicates:
  ID: 123 | 2026-01-15 | -500.00 | Amazon
  ID: 456 | 2026-01-15 | -500.00 | Amazon
```
