What the agent does
This is for an IT support company that looks after small offices: a dental lab, a law office's front desk, an architecture studio of eight people. Its client portal already tracks devices and tickets. What its clients keep asking is which of their files are open to the world, because someone shared a price list or a payroll sheet with "anyone with the link" to send it quickly and never turned it off. The company saves one agent as a template whose connections name google-drive, and makes one agent from it per client office with POST /o/{org}/agents {"template": "<template id>", "name": "drive-review-<client id>"}. The office manager connects the office's Google account from the portal: the backend calls POST /o/{org}/agents/<agent id>/connections {"type": "app", "name": "google-drive"} and opens the returned authorize_url in a popup, where Google's own consent page names Rush as the app asking.
The agent reads Drive through the Drive REST API, which Rush signs as that office's account outside the sandbox. It calls GET https://www.googleapis.com/drive/v3/files with a q of visibility = 'anyoneWithLink' and trashed = false, and again with visibility = 'anyoneCanFind'. Google's search reference lists those two values beside domainCanFind, domainWithLink and limited. It sets pageSize to 1000, Drive's maximum, follows pageToken until the list ends, and sets includeItemsFromAllDrives and supportsAllDrives so files in shared drives the account can see are included. For each file it keeps the name, type, owners, last modified time and its web link.
Then it sorts. Files modified in the last seven days go first, because a file shared this week is most likely a mistake someone still remembers making. It groups the rest by owner, flags names that suggest sensitive content (payroll, salary, passwords, bank, contract, patient, invoice) for the office manager to look at first, and counts spreadsheets and documents separately from images and PDFs.
The agent cannot change any sharing setting, and the prompt does not ask it to. Rush's Google Drive sign-in asks Google for drive.readonly, drive.file and spreadsheets: reading every file the account can see, editing files Rush itself created, and editing the contents of Sheets. Google's sharing endpoints take only drive or drive.file, so sharing on a file the office owns is outside what that token can change, and turning off a link stays with the person who owns the file. The prompt forbids every edit, Sheets included.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "<agent id>",
"input": "List this office's Google Drive files that anyone with the link can open. Call GET https://www.googleapis.com/drive/v3/files with q \"visibility = 'anyoneWithLink' and trashed = false\", then again with \"visibility = 'anyoneCanFind' and trashed = false\"; pageSize 1000, follow pageToken, includeItemsFromAllDrives=true and supportsAllDrives=true; fields: nextPageToken, files(id,name,mimeType,owners(displayName,emailAddress),modifiedTime,webViewLink). Today is 2026-11-23. Return JSON: new_this_week (modifiedTime in the last 7 days), look_first (names containing payroll, salary, password, bank, contract, patient or invoice), by_owner: [{owner, count, files}], each file {name, mimeType, owner, modifiedTime, webViewLink, visibility}; totals by visibility. Do not create, edit, move, share or delete any file."
}- 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.
- 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.
- 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 a JSON list of the office's link-shared files: the ones changed this week first, then the ones whose names suggest something sensitive, then every file grouped by owner, with its type, last change and link, and a total for each visibility. The portal's webhook handler matches the run's execution_id to the client office it started it for and shows the list on that office's security page.
The office manager goes through it with the file owners. Most link-shared files are meant to be: a menu, a brochure, a form. The ones that are not get their sharing changed in Drive by the person who owns them. The IT company reviews the first few offices' lists by opening some of the files' sharing settings, to confirm the list matches what Drive shows.
The list covers what the connected Google account can see: files it owns, files shared with it, and shared drives it belongs to. Files that other people in the office own and never shared with that account are not in it, so an office that wants full coverage connects an account that sees the shared folders everyone works in.
Run it on every Monday, per client office
The portal's scheduler sends one POST /o/{org}/sessions per client office each Monday, with that office's agent id as agent, the date in input, and a request_id that is a UUID v5 of the office's id and the week, so a retried job starts no second run. Offices past the key's concurrent limit are created queued and start as earlier runs finish.
An office can also ask for a fresh list from the portal after a clean-up, which sends the same request at once and shows the answer when the webhook arrives.
The use case this job follows, with its automation and trigger: Run an agent per customer task.
Why run it on Rush?
Doing this with a script means a Google Cloud project with a verified OAuth app, a consent screen per client, refresh tokens to store and rotate, and a server that holds all of them. With a template, each office signs in on Google's page to Rush's app, Rush keeps and refreshes the token under that office's agent, and the IT company stores an agent id. A run of one office's agent never sees another office's Drive or the company's own.
Each office's weekly review runs in its own computer at the same time as the others, and each session records the account it acted as in accounts, so GET /o/{org}/sessions?account=<email> answers which runs used a given Google account. The run's total_cost_usd is per office, which is how the company prices the review into its plan.
Frequently asked questions
Can the agent turn off link sharing for us?
No. Rush's Google Drive sign-in asks for drive.readonly, drive.file and spreadsheets. Google's sharing endpoints take only drive or drive.file, so the token can change sharing only on files Rush created. Sharing on the office's own files is changed by their owners in Drive.
Does this find files shared inside our Google Workspace domain?
Not with this query. Google's search terms also have domainWithLink and domainCanFind for files open to everyone in the organization. Add a third call with one of those to the prompt if the office wants that list too.
What if the office uses a personal Gmail account rather than Workspace?
The same query works: visibility is a Drive search term, not a Workspace feature. A personal account has no shared drives, so that part of the list is simply empty.
How does the office stop the review?
The IT company deletes that office's agent with DELETE /o/{org}/agents/<agent id>, which also disconnects its Google account. Google ends Rush's access for every Google app of that account at once, so any other Google app the office connected to the same agent goes with it.
More Google Drive jobs
More jobs like this: Run an agent per customer task
- Which Client Trips Had a Flight or Hotel Change Overnight? A Travel-Advisor App Reads Each Advisor's Gmail Every Morning (Gmail)
- Which Klaviyo Flows Quietly Stopped Sending? An Email Reporting App's Weekly Check of Each Store's Live Flows (Klaviyo)
- Which Wedding Inquiries Haven't I Answered? Studio Software That Checks Each Photographer's Gmail Every Morning (Gmail)