# StackBooks agent tools

Generated from the shared registry (`https://api.stackbooks.app` / `POST /routes/agent/v1/tools/call`).

## `stackbill_add_customer_po_shipped_correction`

Correct a customer PO shipped count.

Records a shipped-count change that no slip carries. It does not move stock.

## `stackbill_answer_past_invoice_import`

Answer questions blocking a past-invoice import batch.

Submits client, deposit, or column_map answers and continues the batch.

## `stackbill_cancel_customer_po`

Cancel a customer purchase order.

Marks the PO cancelled, the same as the screen.

## `stackbill_close_customer_po`

Close a customer purchase order.

Marks the PO closed, the same as the screen. The order is an id or a printed PO number.

## `stackbill_confirm_deposit_match`

Record a bank deposit as payments on the invoices it paid.

One logged action: a payment per invoice dated the deposit's date (method eft), each linked to the statement line. The invoices' balances must add up to the deposit exactly, or one invoice may take the whole deposit as a part payment. Refused with code line_changed, line_already_used, amounts_differ or invoice_not_open. Undo reverses the payments and frees the line.

## `stackbill_convert_quote_to_invoice`

Convert an accepted-path quote to an invoice.

Creates invoice from quote; converting the same quote again returns that invoice. Legacy MCP name: convert_quote_to_invoice.

## `stackbill_create_catalog_item`

Create a catalog item.

Saves a reusable invoice line item the way the Invoice Items screen does.

## `stackbill_create_client`

Create a new client with optional default hourly rate.

Creates a client record; duplicate names may match existing records per server rules. Requires add_clients. Legacy MCP name: create_client.

## `stackbill_create_client_rate`

Create a billing rate for a client.

Adds a rate row the way the client screen does; default toggles other defaults for that client.

## `stackbill_create_customer_po`

Create a customer purchase order.

Creates the same open PO the customer-PO screen saves, and returns its activity-log id.

## `stackbill_create_invoice`

Create an invoice from a single manual line.

Builds a one-line invoice for client (id or name); wallet gating and Auto-Send rules apply. Optional idempotency_key prevents duplicate creates. Legacy MCP name: create_invoice.

## `stackbill_create_quote`

Create a draft quote with one manual line.

Resolves client_id_or_name, creates a draft without Auto-Send behavior. Legacy MCP name: create_quote.

## `stackbill_create_task`

Create a task.

Adds a task row the way the tasks screen saves.

## `stackbill_create_tax`

Create a percentage or fixed tax row.

Requires settings capability. Legacy MCP name: create_tax.

## `stackbill_customer_statement`

Make one client's statement of open invoices as of a date, with a PDF link.

Returns the client's open invoices and aging totals (the same rows as stackbill_list_receivables) plus pdf_url, a link to the statement PDF that expires after 15 minutes; call again for a fresh link. The PDF is kept in the business's private files; nothing else is written and nothing is sent to the client. Needs the see-prices permission.

## `stackbill_delete_catalog_item`

Delete a catalog item.

Removes one item from the shared catalog.

## `stackbill_delete_client`

Archive a client (soft delete).

Requires delete capability and owner setting for agent deletes. Legacy MCP name: delete_client.

## `stackbill_delete_client_rate`

Delete a client's billing rate.

Removes the rate row the client screen removes.

## `stackbill_delete_logo`

Remove the business logo from future documents.

Clears logo fields on the business profile; older logo files are kept.

## `stackbill_delete_session`

Archive a work session.

Requires delete capability. Legacy MCP name: delete_session.

## `stackbill_delete_task`

Delete a task.

Removes the task row the screen deletes.

## `stackbill_delete_tax`

Delete a tax configuration.

Requires delete capability; also enforces settings elsewhere. Legacy MCP name: delete_tax.

## `stackbill_end_session`

End an active work session.

Stops the timer and saves durations the way the session screen does.

## `stackbill_end_session_break`

End the active break on a work session.

Resumes billable time on the session, matching the screen.

## `stackbill_enter_customer_po_number`

Find or make a client's customer PO by its number.

Returns the client's customer PO with this number (matched ignoring 'PO', spaces and #), making one with no lines when there is none. 'No PO' and the like make nothing. Link a document to the returned customer_order_id; the number itself is kept only on the PO.

## `stackbill_fetch_calendar_events`

Fetch calendar events in a date range.

Loads events from the chosen calendar ids between start_date and end_date.

## `stackbill_get_business_profile`

Read invoice business profile fields.

Company and tax fields used on PDFs. Legacy MCP name: get_business_profile.

## `stackbill_get_client`

Get one client and all saved billing rates.

Resolves client_id_or_name to a Firestore client id, then returns full contact fields, geofence and template settings, plus every rate row. Use when you need rates beyond the default. Ignores unknown keys in the payload. Legacy MCP name: get_client.

## `stackbill_get_client_invoice_columns`

List a client's custom invoice columns.

Reads the custom invoice columns the invoice screen shows for that client.

## `stackbill_get_customer_po`

Get one customer purchase order.

Reads a customer PO by its id or its printed number. More than one number match is refused.

## `stackbill_get_dashboard_stats`

Get StackBill dashboard stats for a date range.

Hours, earnings, invoice count, and recent invoices — read-only.

## `stackbill_get_document_numbering`

Get invoice and quote numbering settings.

Returns stored formats, next numbers, and unparseable-number warnings.

## `stackbill_get_inbound_address`

Read the private address for emailing receipts into the business.

Returns receipts+<code>@in.stackbooks.app. Requires settings permission.

## `stackbill_get_invoice`

Load one invoice with line items and share link if any.

Loads full invoice detail by Firestore id including items and share_url. Legacy MCP name: get_invoice.

## `stackbill_get_mcp_settings`

Get MCP automation settings.

Reads auto-send and destructive-action switches from Settings.

## `stackbill_get_packing_slip`

Get packing slip detail for invoicing.

Loads one slip with items the invoice-from-slip flow uses.

## `stackbill_get_past_invoice_import`

Read past-invoice import batch status.

Returns batch files, questions, and quota summary for a prior import.

## `stackbill_get_preferences`

Read time zone, Powered by, and bank-backed-claims preferences.

Each field includes value and whether it has been set.

## `stackbill_get_quote`

Load one quote with line items.

Full quote by id including items and conversion fields. Legacy MCP name: get_quote.

## `stackbill_get_session`

Get one work session with breaks.

Loads the session detail the timesheet screen opens.

## `stackbill_import_catalog_items`

Import catalog items in bulk.

Creates many catalog items in one logged action, like CSV import on the screen.

## `stackbill_link_customer_po_invoice`

Link an invoice to a customer PO.

Links invoice lines to the PO the way the screen does, without changing the older link tool's result.

## `stackbill_link_customer_po_slip`

Link a packing slip to a customer PO.

Links the slip the way the screen does, including a printed-PO correction when confirmed.

## `stackbill_link_invoice_to_customer_po`

Link invoice lines to a customer purchase order.

Applies line_map between order_id and invoice_id per spec 32 Part D.

## `stackbill_link_slips_to_invoice`

Attach packing slip documents to an invoice.

Links slip_ids to invoice_id with activity logging.

## `stackbill_link_sure_documents`

Link every sure slip and invoice.

Applies the sure links from the links screen. A run that links nothing does not invent an activity id.

## `stackbill_list_active_sessions`

List active work sessions.

Returns open sessions the timesheet home screen polls.

## `stackbill_list_calendars`

List connected calendars.

Returns Google, Microsoft, and iCloud calendars the screen can read.

## `stackbill_list_catalog_items`

List catalog items for invoicing.

Reads users/{business}/items the same way the Invoice Items screen lists them.

## `stackbill_list_client_rates`

List billing rates for a client.

Returns every rate for the client id or name, with default first.

## `stackbill_list_clients`

List clients with default billing rates.

Returns every active client in StackBill with contact fields and default_rate when set. Use before invoicing or quoting to pick a client id or name. Legacy MCP name: list_clients.

## `stackbill_list_customer_po_link_candidates`

List link candidates for a customer PO.

Returns invoices and slips the customer-PO linking screen can attach.

## `stackbill_list_customer_pos`

List customer purchase orders.

Lists open customer POs by default, with limit and cursor. Pass include_closed to see the rest.

## `stackbill_list_document_numbers`

List every PO, packing slip, invoice and quote number by id.

Numbers only, each read from its own document, plus each slip's customer PO id. Use it to show the numbers behind the ids that invoices, quotes and slips link to.

## `stackbill_list_invoice_autofill_candidates`

List invoices that can autofill a packing slip.

Returns the same autofill candidates the slip screen uses for a client.

## `stackbill_list_invoice_slip_link_candidates`

List packing slips that can link to an invoice.

Returns the same slip-link candidates the invoice screen shows. A revised invoice is refused.

## `stackbill_list_invoices`

List invoices with optional status filter.

Returns up to limit (default 20) invoices; totals omitted when the key cannot see prices. Optional business_id matches MCP for acting as a specific business. Legacy MCP name: list_invoices.

## `stackbill_list_quotes`

List quotes with optional status filter.

stackbill_list_quotes returns every quote when limit is omitted. The legacy MCP name list_quotes defaults limit to 20. Agent-created quotes stay draft until shared in UI.

## `stackbill_list_receivables`

List what each client owes, aged, as of a date.

Open issued invoices grouped by client, oldest debt first: totals per currency, aging buckets (0-30, 31-60, 61-90, over 90 days from the invoice date), and each invoice's PO, dates, age, days past due, total, paid and balance as of the date. Drafts, void, deleted and replaced invoices are left out. Money fields are null when the key cannot see prices. Read-only.

## `stackbill_list_recent_sessions`

List recent work sessions.

Returns the recent-session strip on the timesheet screen.

## `stackbill_list_sessions`

List work sessions in a recent window.

Filters by optional client id/name. Legacy MCP name: list_sessions.

## `stackbill_list_tasks`

List tasks.

Returns pending or completed tasks with optional status filter.

## `stackbill_list_taxes`

List tax configurations for invoicing.

Ordered list for the business profile taxes collection. Legacy MCP name: list_taxes.

## `stackbill_list_uninvoiced_slips`

List packing slips not yet on a live invoice.

Returns the uninvoiced slip picker, including slips held back by customer-PO rules.

## `stackbill_list_unlinked_documents`

List documents eligible for slip-invoice linking.

Read-only not-linked list for the linking workflow.

## `stackbill_log_session`

Log a billable work session.

Provide end_time or duration_hours from start_time. Legacy MCP name: log_session.

## `stackbill_make_customer_po_from_documents`

Make a customer PO from slips and invoices.

Creates the closed PO the links screen makes from the chosen documents.

## `stackbill_merge_clients`

Start merging duplicate client records.

Starts a merge of from_ids into keeper_id; bookkeeping and links follow server rules. Legacy MCP name: merge_clients.

## `stackbill_preview_customer_po_invoice_link`

Preview linking an invoice to a customer PO.

Shows the line map the linking screen computes before the user confirms.

## `stackbill_preview_document_numbering`

Preview the next document number for a proposed format.

Requires the settings capability. Does not save.

## `stackbill_read_customer_po`

Read a customer PO from a file or text.

Extracts PO fields from text, a base64 file, or a file URL. It does not save a PO.

## `stackbill_record_invoice_payment`

Record a payment on an invoice.

Posts payment with optional idempotency_key for safe retries. method: cash, e_transfer, eft, cheque, card, other (aliases: direct deposit, wire, interac, check, …). Legacy MCP name: record_invoice_payment.

## `stackbill_remove_customer_po_shipped_correction`

Remove a customer PO shipped correction.

Deletes one shipped-count correction from the PO.

## `stackbill_remove_invoice_payment`

Reverse one payment on an invoice.

Appends a reversal entry; needs StackBill edit, not agent delete. Legacy MCP name: remove_invoice_payment.

## `stackbill_reopen_customer_po`

Reopen a customer purchase order.

Marks a closed PO open again, the same as the screen.

## `stackbill_resolve_client`

Resolve or create a client from name and contact hints.

Runs the same resolver the UI uses; interactive can prompt for disambiguation in supported flows. Legacy MCP name: resolve_client.

## `stackbill_restore_client`

Restore an archived client.

Clears deleted_at on an archived client the way the archive screen restores.

## `stackbill_restore_session`

Restore an archived work session.

Clears deleted_at on a soft-deleted session like the archive restore control.

## `stackbill_revise_invoice`

Revise an issued invoice.

Creates the next draft revision of an issued invoice, the same as the invoice screen.

## `stackbill_revise_quote`

Revise an issued quote.

Creates the next draft revision of an issued quote, the same as the quote screen.

## `stackbill_rotate_inbound_address`

Make a new inbound receipt address; the old one stops working at once.

Logged and undoable. Requires settings permission.

## `stackbill_seed_document_numbering`

Set the next invoice or quote number.

Seeds the counter when no higher number is already issued or reserved.

## `stackbill_set_client_main_email`

Set a client's primary invoice email.

Promotes an address already in the client's email list to the main email field.

## `stackbill_set_home_currency`

Set the business home currency.

Merges currency on preferences/global; other apps' fields stay untouched.

## `stackbill_set_powered_by`

Show or hide Powered by StackBill.

Writes only show_powered_by.stackbill on global preferences.

## `stackbill_set_time_zone`

Set the business time zone.

Writes time_zone on preferences/global when the app seeds device zone.

## `stackbill_share_invoice`

Issue or renew the public share link for an invoice.

Respects Auto-Send and paid-plan gates. Legacy MCP name: share_invoice.

## `stackbill_share_invoice_link`

Issue an invoice and get its share link.

Issues the invoice and makes or renews its public share link, the same as the screen's Copy link, and returns the link with a ready-to-send line. Nothing is emailed; pass the link on yourself. To have StackBooks email the client, use stackbill_share_invoice.

## `stackbill_share_quote`

Issue or renew the public share link for a quote.

Makes or renews the quote's share link the way the Send sheet does, and returns the introduction plus the link.

## `stackbill_start_past_invoice_import`

Upload paths already in Storage: start a past-invoice import batch.

Starts spec 30 Phase B import from uploaded files (PDF, CSV, XLSX). Uses the same routes as the Invoices screen. Returns batch status and action_id.

## `stackbill_start_session`

Start an active work session.

Starts a session on the timer screen path; use before breaks or end_session.

## `stackbill_start_session_break`

Start a break on a work session.

Pauses billable time on an active session, matching the screen.

## `stackbill_suggest_deposit_matches`

List unused bank deposits with the open invoices each may have paid.

Reads imported bank statement lines where money came in and nothing is explained yet. For each, suggests one open invoice whose balance equals the deposit, or an exact combination of one client's open invoices, dated on or after the invoice and within 180 days of it. When several fit, only those whose client is named in the description are offered; if none is named, all are offered and none is preferred. Records nothing: confirm with stackbill_confirm_deposit_match.

## `stackbill_undo_client_change`

Undo one client profile change.

Reverses a single change_id from the client's change history, the same as the screen undo.

## `stackbill_undo_client_merge`

Undo a recent client merge by merge id.

Reverts the merge if still reversible. Legacy MCP name: undo_client_merge.

## `stackbill_unlink_customer_po_invoice`

Unlink an invoice from a customer PO.

Removes the invoice link the screen removes.

## `stackbill_unlink_customer_po_slip`

Unlink a packing slip from a customer PO.

Removes the slip link the screen removes.

## `stackbill_unlink_slips_from_invoice`

Remove slip links from an invoice.

Unlinks slip_ids from invoice_id.

## `stackbill_update_business_profile`

Update invoice business profile fields.

Partial merge into business profile document. Legacy MCP name: update_business_profile.

## `stackbill_update_catalog_item`

Update a catalog item.

Changes fields on one users/{business}/items document.

## `stackbill_update_client`

Update client contact fields by id or name.

Only supplied fields change; client_id_or_name is resolved like get_client. Legacy MCP name: update_client.

## `stackbill_update_client_invoice_columns`

Replace a client's custom invoice columns.

Saves the custom invoice columns the invoice screen saves for that client.

## `stackbill_update_client_rate`

Update a client's billing rate.

Changes rate fields the client screen saves.

## `stackbill_update_customer_po`

Update a customer purchase order.

Changes the same fields the customer-PO screen saves. The order is an id or a printed PO number.

## `stackbill_update_document_numbering`

Update invoice and quote numbering formats.

Saves formats and re-bootstraps counters the way Document Numbering in Settings does.

## `stackbill_update_invoice`

Change invoice notes, due date, or status.

Partial update by invoice_id; only provided fields change. Legacy MCP name: update_invoice.

## `stackbill_update_invoice_po_number`

Enter the customer PO number on an invoice.

Finds or makes the client's customer PO with that number and links the invoice to it, as the invoice screen does. On a sent invoice a different PO makes a revision.

## `stackbill_update_mcp_settings`

Update MCP automation settings.

Saves the switches the Settings MCP panel shows. An API key can switch one off; only a person signed in can switch one on (agent_settings_need_person).

## `stackbill_update_quote`

Update quote notes, validity, or status.

Partial update by quote_id. Legacy MCP name: update_quote.

## `stackbill_update_session`

Update session notes or end time.

Partial update by session_id. Legacy MCP name: update_session.

## `stackbill_update_task`

Update a task.

Changes task fields the screen saves.

## `stackbill_update_tax`

Update a tax configuration.

Partial update by tax_id. Legacy MCP name: update_tax.

## `stackbill_upload_logo`

Upload the business logo.

Accepts a base64 PNG, JPEG, or WebP image; same limits as the settings screen.

## `stackbill_void_invoice`

Void an invoice.

Voids the invoice the way the screen does: keeps the number, drops it from income, and revokes the share link.

## `stackbill_void_quote`

Void a quote.

Voids the quote the way the screen does: keeps the number and revokes the share link.

## `stackbooks_accept_member_invite`

Accept a member invitation token.

Caller must be signed in with the invited verified email.

## `stackbooks_answer_business_question`

Answer a business-profile question.

Writes business record answers used by invoices and tax setup.

## `stackbooks_answer_question`

Answer an open bookkeeper question. One answer applies to every line in covered_line_ids.

Commits through bookkeeper apply. One answer applies to every statement line in covered_line_ids. Idempotent when idempotency_key is supplied.

## `stackbooks_approve_pending`

Not available on API keys.

Approving runs only when a person signs in and taps Approve on the activity feed. List and decline still work on keys.

## `stackbooks_bin_business_document`

Move a business document to the bin for 30 days.

The file stays in storage until the purge. Undo of this action puts the document back.

## `stackbooks_cancel_member_invite`

Cancel a pending member invitation.

Requires manage_members.

## `stackbooks_decline_pending`

Decline an agent request.

Marks the request declined so the caller sees approval_declined. Requires manage_members or ownership.

## `stackbooks_file_business_document`

File a business document from an https URL and read it.

Downloads a public https URL, stores it on the business, then reads it before returning. Send a URL, never the file's base64.

## `stackbooks_get_business_answers`

Read stored business-profile answers.

Returns jurisdiction, structure, year end, tax numbers, and filing place when set, plus which fields are still unanswered.

## `stackbooks_get_business_document`

Get one business document and the route that streams its file.

Returns the stored record. Fetch url with the same credentials to open the bytes. There is no signed URL.

## `stackbooks_get_business_question`

Fetch the next business-profile question for an app moment.

Wraps the shared business answers engine used across suite apps.

## `stackbooks_get_membership_access`

Get the caller's access in the current business.

Returns business_id, permissions, and whether the caller is the owner.

## `stackbooks_get_pending_approval`

Look up one approval request and its outcome.

Returns pending, approved, declined or expired with a stable code.

## `stackbooks_get_sales_order`

Get one sales order by id.

Same shape as list entries: no price fields.

## `stackbooks_get_started`

Suite orientation for the authenticated API key.

Returns the business, key holder context, permission summary, short conventions note, per-app example tool names, which suite apps are in use vs not, and URLs to start each app. No arguments; always available to agents.

## `stackbooks_get_system_health`

Check required backend secrets for system health.

Same as GET /dashboard/health; no business data is read or written.

## `stackbooks_get_year_end_package`

Read a year-end package's numbers, pages, and checks.

Returns one fiscal year's filed accountant package: merged GIFI lines with pages, GST returns, and plain-word validation checks.

## `stackbooks_invite_member`

Invite someone by email.

Requires manage_members. Call stackbooks_list_roles first for valid role_id values. Sends the same invite email as the Members screen.

## `stackbooks_link_documents`

Link a packing slip, invoice or customer PO to another.

Uses one logged action. Supports slip–PO, slip–invoice and invoice–PO. typed_po_number links or creates the client's PO (No PO words link nothing).

## `stackbooks_list_activity`

List recent activity log entries for this business.

Owner sees all entries; members see entries for apps their role can view. Redacts prices when see_prices is off.

## `stackbooks_list_business_documents`

List business documents for the current business.

Lists the company's filed papers, optionally one kind, or the bin when bin is true. Each row includes the file route in url.

## `stackbooks_list_link_candidates`

List open client documents to link (numbers only).

Returns id, number or phone-order label, date and status for open customer POs, packing slips or invoices for one client. Same data as the Create link question.

## `stackbooks_list_member_invites`

List open member invitations.

Requires manage_members; same as the Members screen invite list.

## `stackbooks_list_members`

List people in the business.

Active members may read; does not include removed members.

## `stackbooks_list_my_businesses`

List businesses this person belongs to.

Personal index of businesses; same as the business switcher.

## `stackbooks_list_pending_approvals`

List actions waiting for owner approval.

Shows pending agent requests for this business. Requires manage_members or ownership.

## `stackbooks_list_questions`

List open bookkeeper questions for the business.

Suite-wide questions index; same data as stackspent_list_open_questions.

## `stackbooks_list_roles`

List roles available for member invites.

Returns preset and custom roles (role_id, name, apps, capabilities). Requires owner or manage_members.

## `stackbooks_list_sales_orders`

List open sales orders (customer POs without prices).

Each row is a customer PO with lines and quantities left to ship. No prices, totals or terms. Filter by client_id and status=open.

## `stackbooks_list_year_end_packages`

List accountant year-end packages filed for this business.

Each package groups documents by fiscal year end with a state: reading, needs a look, or ready.

## `stackbooks_read_business_document`

Read a filed business document into kind, dates, and quoted facts.

Runs the document read and stores facts only in the allowed shapes. A failed read can be called again.

## `stackbooks_refresh_member_invite_link`

Make a new accept link for a pending invitation.

Requires manage_members. Returns accept_link once; invalidates any earlier link.

## `stackbooks_remove_member`

Remove a member from the business.

Requires manage_members; cannot remove the owner.

## `stackbooks_restore_business_document`

Move a binned business document back into the live list.

Restores the Firestore record. The file was never deleted by the bin.

## `stackbooks_save_business_document_facts_to_profile`

Save incorporation number or date from a document onto the business profile.

Writes incorporation_number and/or incorporation_date on users/{businessId}/profile/business from the document read. Only fields listed in fields are saved.

## `stackbooks_undo_action`

Undo a logged action by action_id.

Uses the same rules as the Activity screen undo control.

## `stackbooks_unlink_documents`

Remove a link between a packing slip, invoice or customer PO.

Undoable logged write for the same pairs as stackbooks_link_documents.

## `stackbooks_update_business_document`

Change a business document's kind, title, notes, or dates.

A person's kind, title, or dates are kept on a later read. Notes are the owner's own words.

## `stackbooks_update_member_relationships`

Update a member's funding-party relationships.

Requires manage_members.

## `stackbooks_update_member_role`

Change a member's role.

Requires manage_members; cannot exceed the grantor's own permissions.

## `stackbooks_use_business_document_facts`

Write document facts into business answers (jurisdiction, structure, year end, tax number).

Uses the same validation as business questions. Bulk use only for empty fields; a differing jurisdiction or structure needs its own call.

## `stackslip_list_packing_slips`

List recent packing slip ids and numbers.

Newest-first up to limit (default 20); optional business_id matches MCP. Legacy MCP short name: list_packing_slips.

## `stackslip_revise_packing_slip`

Revise a sent packing slip (creates PS-###-U1).

Creates a new slip document; links and billed invoice follow in the same action.

## `stackslip_void_packing_slip`

Void a packing slip (slips are never deleted).

The slip keeps its number, its stock goes back, it stops counting on its customer PO and its share link stops showing it. A slip billed on a live invoice is refused (slip_on_invoice): void or revise that invoice first. The slip is its id or its printed number.

## `stackspent_add_card_to_account`

Put a card on a statement account.

Attaches a card by last four to a main card. Folds that card's existing statement imports into the account's months (same PDF hash or contained period), skipping charges already counted on the month; imports with no month move onto the account. Refusal ambiguous_month: more than one month matched. card_holder_differs: holder clash.

## `stackspent_answer_question`

Answer a bookkeeper question (bookkeeper role). One answer applies to every line in covered_line_ids.

Commits answer with remember once or item. One answer applies to every statement line in covered_line_ids. May return ApplyRejected codes.

## `stackspent_batch_receipts`

Scan one or more receipt URLs like the upload screen batch.

receipt_urls are https URLs (same as hand-in); at most 20 per call. Optional persist=expense runs the scan/save pipeline. One action_id undoes every expense the call saved; nothing saved means action_id is null and no activity row.

## `stackspent_bin_expense`

Bin or restore an expense.

Set restore true to put a binned expense back.

## `stackspent_cancel_statement_batch`

Cancel a stuck statement upload batch.

Writes failed with error_code cancelled when the batch needs an answer, failed, or has been processing with no updates for over an hour. A batch that is still running returns batch_running.

## `stackspent_commit_statement_document`

Save the lines of a statement that was read.

Saves the checked reading of a PDF or photo statement and creates its lines.

## `stackspent_commit_statement_file`

Save a CSV or OFX statement's lines.

Creates the import and its lines, pairs certain receipts, and files bank-settled matches, as the statement screen does. source_file may be a stored path or a public https URL.

## `stackspent_confirm_statement_match`

Confirm a proposed statement line match.

Writes links via StackSpent Functions after a successful match.

## `stackspent_convert_line`

Convert a statement line to an expense.

Converts an unreviewed statement line with the same write the statement screen uses.

## `stackspent_correct_expense`

Correct, split, or set business use on an expense.

action correct|split|business_use. correct: patch fields allowed on screen routes only. split: plan with creates, updates, bins, statement_line only (hard deletes refused).

## `stackspent_create_purchase_order`

Create a draft purchase order for a supplier.

Supplier by id or name; optional existing open PO. Requires idempotency_key.

## `stackspent_delete_statement_import`

Delete a statement import and its lines.

Refused while any line on it became an expense. Matched expenses keep their receipt and lose the line link.

## `stackspent_ensure_expense_schedules`

Ensure official expense category schedules are loaded.

Calls the shared ensure pipeline for a country and business structure.

## `stackspent_file_bank_settled`

File bank-settled receipt expenses with the bookkeeper.

Posts to /agent/statements/file-bank-settled.

## `stackspent_get_decision_package`

Fetch a bookkeeper decision package by subject.

Reads from StackSpent /agent/bookkeeper/package.

## `stackspent_get_inbound_address`

Read the private address for emailing receipts into the business.

Returns receipts+<code>@in.stackbooks.app. Requires settings permission.

## `stackspent_get_purchase_order`

Get one purchase order by id or printed number.

Returns lines, deliveries and amendments.

## `stackspent_get_receipt_image`

Get a short-lived link to an expense's receipt image.

Read only. Returns {url, expires_in_minutes} for the receipt photo or PDF of one expense (binned expenses too), so a printed amount or GST number can be checked against the receipt. The link works for 15 minutes; ask again for a new one. Needs permission to see prices.

## `stackspent_get_statement_original`

Open the uploaded files for one statement import.

Read only. Returns each original PDF or image in page order with short-lived download links, or missing: true when Storage no longer has the file. Works for live imports and removed ones. Needs permission to see prices.

## `stackspent_hand_in_receipt`

Hand in a receipt or document as an expense.

Structured hand-in when the agent already extracted merchant, amount, currency, and date.

## `stackspent_ignore_line`

Ignore a statement line.

Ignores a statement line with the same write the statement screen uses.

## `stackspent_import_statement`

Import a statement file.

Imports statement files through the screen batch, joining one card's pieces by its last four digits. Each file may be a stored path from any of this business's earlier statement batch uploads (paths on existing imports' source_files), or a public https URL (fetched into the batch folder before processing). When a file's hash already exists on the account, missing on-account card sections are filled in; refusal code lines_on_other_import means delete the other import named in the error first. Omit account_id or send read_it to let the app read each statement's card. The import is asynchronous: the first call usually returns status processing with a batch_id. Poll stackspent_statement_batch_status with that batch_id until status is done, needs_answer, or failed. If status is needs_answer, call again with the same files, the batch_id, and answers keyed by each question's unit_id. For card_on_account, key answers as `{unit_id}:{last4}` with owner_party_id (null when not known) or make_separate: true.

## `stackspent_list_account_months`

Load statement month groups for a funding account.

Calls GET /agent/accounts/months with account_id.

## `stackspent_list_duplicate_cards`

Find card records that look like one card recorded more than once.

Read only. Returns {groups}: card records with the same last four and overlapping dates, including old records that were archived without being joined to the live card, each with a suggested keep_id, the accounts, whether the owners match, whether the brands differ, and why. Pass a group's keep_id and the other ids to stackspent_merge_payment_accounts once the owner agrees.

## `stackspent_list_expenses`

List expenses, newest first, a page at a time.

Returns {expenses, next_cursor}. Pass next_cursor back as cursor until it is null to read every expense. Optional filters: date_from / date_to (expense date), funding_account_id (includes accounts merged into it) and has_receipt. Each row carries fundingAccountId (the kept account), hasReceipt and statementLineId.

## `stackspent_list_open_questions`

List open bookkeeper questions for the business.

Reads from shared Firestore bookkeeper question index.

## `stackspent_list_owed_to_people`

List what the company owes people (balances and ledger).

Calls GET /agent/owed-to-people with optional as_of (YYYY-MM-DD).

## `stackspent_list_payables`

List supplier payables balances, or one vendor's open items.

Calls GET /agent/payables; optional vendor_id for vendor detail.

## `stackspent_list_payer_mismatches`

List receipts whose payer contradicts the statement account owner.

Read only. A receipt on any card (including a second card on a statement account) whose payer is not the account owner's party. Each row has the card, the recorded payer, the expected account owner, and why. Correct one with stackspent_whose_card once the owner agrees.

## `stackspent_list_payment_accounts`

List every payment account (cards, bank accounts, cash).

Read only. Returns {accounts}: id, type, label, last4, brand, owner, active dates, archived, the accounts merged into it, and how many statement months are imported. Includes accounts with no expenses yet.

## `stackspent_list_purchase_orders`

List purchase orders for this business.

Open POs by default; optional status filter. Uses limit and cursor.

## `stackspent_list_removed_statements`

List statement imports that were deleted but can be restored.

Read only. Newest first: account label, period, line count, when and who removed it, and the action_id for stackbooks_undo_action. Needs permission to see prices.

## `stackspent_list_statement_lines`

List the bank or card statement lines of one payment account.

Read only. Returns {lines, next_cursor}, oldest first, for one account and optionally one month (year_month) or date_from / date_to, filtered by status (unmatched = not yet explained). Each line has id, date, amount, description, status, expense_ids, import_id and updated_at: pass id and updated_at to stackspent_confirm_statement_match, or id to stackspent_convert_line / stackspent_ignore_line.

## `stackspent_list_suppliers`

List suppliers by name.

Helps pick a supplier before creating a PO.

## `stackspent_mark_purchase_order_sent`

Mark a draft purchase order as sent.

Plain mark-sent when the supplier already has the PO another way.

## `stackspent_match_statement`

Match bank statement lines to expenses.

Read-only: returns suggested line-to-expense pairings from StackSpent Functions; does not write links. Use stackspent_confirm_statement_match to persist a choice.

## `stackspent_merge_payment_accounts`

Merge duplicate records of one card into one account.

One logged, undoable action. The merged records are archived and kept, never deleted; no expense or statement line is rewritten, and reads resolve to the kept account. No brand rule blocks a merge — pass brand when the owner picks which network to keep, and owner_party_id when the holders differ. Refuses different last fours (not_same_card) except the typo path from edit (from_typo_edit). confirm_different_brands is ignored (kept for compatibility). Nothing is removed, so it does not need the agent-delete switch.

## `stackspent_owed_to_people`

Record owed-to-people ledger changes, owner flow, or project expense type.

operation add_ledger_entry|edit_ledger_entry|delete_ledger_entry (reverses the entry in place; original kept)|delete_entry (same as delete_ledger_entry)|owner_flow|project_expense_type. Uses the same Functions routes as the insights and statement screens.

## `stackspent_payables`

Patch supplier payments, allocations, converts, assign supplier, or statement-line payment.

operation patch_payment|set_allocations|unlock_allocations|delete_payment (reverses the payment in place; record kept)|convert_to_expense|convert_to_payment|assign_supplier|statement_line_payment|remove_statement_line_payment (unlinks the line; reverses the payment in place when it only existed for that line).

## `stackspent_projects`

Create, edit, delete, or assign a project.

operation add|edit|delete|assign. Assign sets the project on an expense through the screen write.

## `stackspent_promote_statement_expense`

Attach a parked receipt to the expense its statement line made.

Puts the receipt on the no-receipt expense from a statement line and closes the parked receipt.

## `stackspent_record_purchase_order_delivery`

Record goods received against a purchase order.

Takes delivery_id for safe retries.

## `stackspent_refile_statement_import_on_account`

Re-file a misfiled statement import onto an account month.

Deletes the wrong import and commits its stored reading onto a target account import with a card_id.

## `stackspent_remove_card_from_account`

Detach a card from its statement account.

Clears on_account_id. Does not move statement lines.

## `stackspent_resume_statement_commit`

Finish saving a statement that stopped part way.

Creates the lines still missing from an import left saving and marks it imported.

## `stackspent_rotate_inbound_address`

Make a new inbound receipt address; the old one stops working at once.

Logged and undoable. Requires settings permission.

## `stackspent_save_parked_receipt`

Save a parked receipt as its own expense.

Creates the expense (or each split photo part) and closes the parked receipt.

## `stackspent_set_aside`

Keep or bin a set-aside document.

Keeps a set-aside document as an expense or bins it, using the payables screen write and the activity log. Bin needs delete.

## `stackspent_set_bank_backed_claims`

Set bank-backed GST claim flag for the accountant.

Posts preferences to StackSpent Functions.

## `stackspent_set_decision`

Set a bookkeeper decision on a receipt.

Posts to /agent/bookkeeper/set-decision with answeredBy derived from caller.

## `stackspent_share_purchase_order`

Share a purchase order with the supplier.

Issues a draft PO when needed, returns share and PDF URLs. Requires idempotency_key.

## `stackspent_sort_no_receipt_lines`

Sort statement lines that have no receipt.

Uses the same sort path as the statement review screen (history, rules, bookkeeper).

## `stackspent_stage_statement_import`

Send an uploaded PDF or photo statement to be read.

Creates the statement import for files already stored under the import's folder; reading starts on the server. Each source file may be a stored path or a public https URL (fetched and stored before reading).

## `stackspent_statement_batch_status`

Check an in-flight statement batch import.

Calls GET /agent/statements/batch/:id for status, file read progress, errors, and pending questions.

## `stackspent_supplier_payment`

Record a supplier payment.

Records a payment to a supplier through the payables screen write, and returns the activity-log action_id.

## `stackspent_type_purchase`

Type in a purchase without a receipt photo.

Creates a no-receipt business expense; requires see_prices.

## `stackspent_update_payment_account`

Edit a card or bank record (card: brand, debit, nickname, holder, last 4; bank: kind, nickname, holder).

One logged, undoable action. For cards, moves the fingerprint index when brand or last four change and refuses a last-four typo onto another live card (merge_required). A holder change may require payer correction. For bank accounts, kind must be chequing, savings, or credit_line; card fields are refused.

## `stackspent_vendors`

Add, edit, or merge vendors.

operation add|edit|merge with fields declared per operation.

## `stackspent_whose_card`

Record who paid for an expense.

Sets paidByPartyId only; never sets tax treatment.

## `stackstock_availability`

Read stock availability snapshot.

Uses StockEngine.availability() for the business.
