> For the complete documentation index, see [llms.txt](https://docs.kick.co/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.kick.co/ai/cli/cli-use-case-library/advanced-scripting.md).

# Advanced Scripting

Most lookup commands accept `--output json` or `--output json-compact` for parsing with `jq`:

**Get transaction count by category** (read):

```bash
kick --workspace <workspace-id> transactions find --output json | \
  jq 'group_by(.category) | map({category: .[0].category, count: length})'
```

**Find largest transactions** (read):

```bash
kick --workspace <workspace-id> transactions find --fields id,date,amount,counterparty --output json | \
  jq 'sort_by(.amount) | reverse | .[0:10]'
```

**Calculate average amount by counterparty** (read):

```bash
kick --workspace <workspace-id> transactions find --fields amount,counterparty --output json | \
  jq 'group_by(.counterparty) | map({counterparty: .[0].counterparty, avg: (map(.amount) | add / length)})'
```

#### Credentials and workspace defaults

For scripts, set a personal access token:

```bash
export KICK_PAT=kick_pat_...
kick whoami
```

To avoid repeating `--workspace` on every command, set a local default:

```bash
kick workspaces use <workspace-id>
```

Or store the default on a named profile:

```bash
kick config set profiles.acme.defaultWorkspaceId <workspace-id>
kick config set defaultProfile acme
kick --profile acme whoami
```

Config is stored locally (not in `~/.kick/config.yaml`). Inspect it with:

```bash
kick config get
```

Pass `--workspace <workspace-id>` explicitly when you work across multiple clients in one script. That is safer than relying on a remembered default.

#### Output modes

* `--output auto` — table in a terminal, structured output when piped
* `--output table` — human-readable table
* `--output json` — formatted JSON on stdout
* `--output json-compact` — compact JSON for agents and scripts
* `--output yaml` — YAML

Diagnostics and errors go to stderr, so you can pipe stdout safely:

```bash
kick --workspace <workspace-id> transactions find --limit 10 --output json | jq '.[0].id'
```

***

#### Scheduling Scripts

Run read-only lookup scripts with cron (Linux/Mac):

```bash
# Edit crontab
crontab -e

# Daily at 9am: Uncategorized transaction alert
0 9 * * * /path/to/daily-uncategorized-alert.sh

# First day of month: Generate monthly P&L JSON
0 8 1 * * /path/to/monthly-pl-reports.sh

# Every Monday: Export to warehouse
0 10 * * 1 /path/to/export-to-warehouse.sh
```

For Windows, use Task Scheduler.

Review write commands manually before scheduling them. Commands that change data require preview confirmation and should not run unattended unless your firm has approved that workflow.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.kick.co/ai/cli/cli-use-case-library/advanced-scripting.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
