# Find Each Groomer's Overdue Square Invoices and Draft the Reminders, From Your App

Software for mobile dog groomers makes one agent per groomer that reads their Square invoices each week and drafts a reminder for every one past its due date.

[Run this on Rush](https://cloud.getrush.ai/run/follow-up-on-overdue-invoices/square/). Opens the console with this prompt ready to send. Connect Square there first.

## What the agent does

This is for a company that sells booking and route software to mobile dog groomers. Most of its groomers bill regular clients through Square Invoices, because the client pays from a link on their phone. The groomer's week is full of driving and grooming, so an invoice that slips past its due date often sits there for a month. The company wants its app to show, every Monday, which of the groomer's invoices are overdue and a reminder ready to send for each one, without building a Square integration of its own. It saves one agent as a template whose `connections` name `square`, Square's hosted MCP server at `https://mcp.squareup.com/mcp`, which signs in with OAuth. A template names connections its creator has, so the company first connects its own Square account with `POST /me/connections {"type": "mcp", "name": "square", "url": "https://mcp.squareup.com/mcp", "auth": {"mode": "oauth"}}`.

When a groomer turns the feature on, the company's backend makes an agent from the template with `POST /o/{org}/agents {"template": "<template id>", "name": "invoices-<groomer id>"}`, stores the agent id against the groomer, and starts the sign-in with `POST /o/{org}/agents/<agent id>/connections {"type": "mcp", "name": "square"}`. The answer's `authorize_url` opens in a popup in the groomer's signed-in session, where they approve Rush on Square's own page. The company registers no Square app and never holds the groomer's Square token, and the `authorize_url` works once, so it is handed only to that groomer.

Square's server has three tools, and the agent uses them the way Square's README describes: `get_service_info` to see the methods the `invoices` and `locations` services have, `get_type_info` to read the parameters a method takes, and `make_api_request` to call it. It lists the groomer's locations, then searches invoices one location at a time, because Square's `POST /v2/invoices/search` takes one location in `query.filter.location_ids`. It pages with `limit`, up to 200, and `cursor`, and keeps invoices whose `status` is `UNPAID` or `PARTIALLY_PAID`. For each, it reads `payment_requests`: a request whose `due_date` is before today and whose `total_completed_amount_money` is less than its `computed_amount_money` is overdue, by the difference. `primary_recipient` names the client and `public_url` is the Square-hosted page where they pay.

Then it writes a short reminder per client, in the groomer's voice from the template's instructions, naming the invoice number, the amount still owed and the payment link. It sends nothing. The prompt forbids any `make_api_request` call that is not a read: no create, update, publish, cancel or send on an invoice, and no change to its `reminders`, which are the automatic reminders Square sends on its own.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "<agent id>",
  "input": "Today is 2026-11-23. List this groomer's overdue Square invoices. Use get_service_info and get_type_info before each new method. List locations, then for each location call invoices search with query.filter.location_ids set to that one location, limit 200, following cursor. Keep status UNPAID or PARTIALLY_PAID. An invoice is overdue when a payment request's due_date is before today and total_completed_amount_money is less than computed_amount_money. Return JSON: overdue: [{invoice_id, invoice_number, client_name, client_email, due_date, days_overdue, amount_owed, currency, public_url, square_reminders_scheduled (true if the request has reminders), draft_message}], oldest first; total_owed by currency. draft_message is under 60 words, friendly, names the invoice number, amount and public_url. Read only: never call a method that creates, updates, publishes, cancels, sends or deletes anything."
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

Each run answers with one JSON object: the groomer's overdue invoices oldest first, each with the client, the due date, how many days late, the amount still owed, Square's payment link, whether Square already has reminders scheduled for it, and a drafted message. The key's webhook delivers it as `run.completed` with the answer in `data.result` when it fits in 16 KiB, and the company's handler matches `execution_id` to the groomer it started the run for and shows the list in the app.

The groomer reads each draft before it goes, because they know what the agent cannot: the client who paid cash at the van, or the one who asked to pay next week. A `public_url` is a temporary link, so the app sends the reminder soon after the run rather than days later. The company checks the first few groomers' lists against their Square dashboard before turning the feature on for everyone.

## Run it on every Monday, per groomer

The company's scheduler sends one `POST /o/{org}/sessions` per groomer early on Monday in the groomer's time zone, with that groomer's agent id as `agent`, the date in `input`, and a `request_id` that is a UUID v5 of the groomer's id and the week, so a retried job starts no second run. A key runs at most `max_concurrent` sessions at once; the rest are created `queued` and start as slots free, so the scheduler sends every groomer's request in one pass.

Before each run the backend can read `GET /o/{org}/agents/<agent id>`: a groomer whose agent lists `square` under `missing_connections` has not finished signing in, and gets a prompt in the app to connect instead of a run that would be refused.

## Why run it on Rush?

Building this directly means a Square app of the company's own, OAuth for every groomer, token storage and refresh, and code for invoices and payment requests. With one template, Rush holds each groomer's Square sign-in under that groomer's agent, and the company stores only an agent id. A run of one groomer's agent can reach that groomer's Square account and no one else's.

Every run is its own session with its own computer, so a hundred groomers' Monday lists build at the same time and none waits on another. Each session records the Square calls it made and the accounts it acted as, and `GET /o/{org}/sessions?agent=<agent id>` lists one groomer's runs with their `total_cost_usd`, which is what the company needs to price the feature.

## Frequently asked questions

### Why search one location at a time?

Square's reference for `POST /v2/invoices/search` says you can specify only one location, and optionally one customer, per search. A groomer with one van has one location, so this is one search; a business with several locations gets one search per location, which the prompt handles.

### Will this send reminders twice if Square already sends them?

The agent sends nothing. It reports whether each payment request has `reminders` set, which are Square's own automatic reminders, so the app can show the groomer that Square already nudged that client and let them decide whether a personal note helps.

### What happens when a groomer has not connected Square, or stops Rush's access?

A run of an agent whose groomer never finished signing in is refused with `422 CONNECTION_NOT_READY` before a sandbox starts, and the agent's `missing_connections` names `square`. When a groomer stops Rush's access from Square, `GET /o/{org}/agents/<agent id>/connections` shows the connection's `status`, and the app starts a new sign-in; an agent holds one sign-in per MCP server, so connecting again replaces the old one and the agent id stays the same.

### Can the groomer change the tone of the reminders?

The tone comes from the template's instructions, which every agent made from it shares, and a `PATCH` on the template reaches every groomer's next run. A per-groomer preference, such as a sign-off, goes in the `input` the scheduler sends.

## More Square jobs

- [Find Square Items to Reorder](https://getrush.ai/run/inventory-reorder-report/square/)
- [Which Refunds Should a Café Owner Look At This Week? Back-Office Software That Reviews Each Customer's Square Refunds](https://getrush.ai/run/review-weekly-refunds-by-location/square/)
- [Tip Pooling From Square Timecards and Card Tips](https://getrush.ai/run/split-each-weeks-tip-pool/square/)

## The same job in other apps

- [Follow Up on Overdue QuickBooks Invoices Every Week](https://getrush.ai/run/follow-up-on-overdue-invoices/quickbooks/)

## More jobs like this: Run an agent per customer task

- [Generate a Typed API Client from an ASP.NET Core Swagger Document](https://getrush.ai/run/generate-api-clients/aspnet-core/)
- [Generate a Typed API Client for a FastAPI Service](https://getrush.ai/run/generate-api-clients/fastapi/)

## Keep reading

- [Connect Square to Rush once, then name it on any run](https://getrush.ai/integrations/square/)
- [Start your first run from the developer API quickstart](https://getrush.ai/docs/quickstart/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
