execute_script
Execute JavaScript scripts to batch-process Billy API operations, such as loops, aggregations, and reconciliation, with dry-run and mutation logging.
Instructions
Run a short JavaScript (ES2022, top-level await allowed) batch script against the Billy API — use for loops, aggregation and reconciliation instead of many single tool calls (e.g. void 30 entries, post 7 monthly journals, sum postings). In scope: billy (get(path,query?), post(path,body), put(path,body), del(path), request(method,path,{body,query}), fetchAll(path,resourceKey,query?,maxRecords?) [GET-only], getOrganizationId()) and console.log. Return a value or log results. Safety: every mutating HTTP call is logged server-side and the mutation log is ALWAYS returned, even if the script throws; dry_run=true simulates writes without executing them (and skips the approval prompt); in read-only mode non-GET calls are blocked; in confirm mode ONE user approval is requested upfront showing the full script. Limits: default 30s timeout, 50 API calls per run, output capped. Billy gotchas: POST/PUT bodies need singular-key wrapping ({ daybookTransaction: {...} }); Billy silently ignores undocumented query filters; use apiType as idempotency key on daybook transactions.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| script | Yes | JavaScript source. `billy` and `console.log` are in scope. Top-level await allowed. Return a value or console.log results. | |
| dry_run | No | Simulate: non-GET calls are logged and return {dryRun:true} without executing (default false) | |
| timeout_ms | No | Script timeout in ms (default 30000) | |
| max_api_calls | No | API call budget per run (default 50) |