Automate Listing Videos From Google Sheets With Apps Script
How do you make listing videos from a Google Sheet with the PhotoAIVideo API?
A script bound to your listing sheet reads each Ready row, re-uploads that listing's Drive photos through PhotoAIVideo presigned URLs (the API rejects external image links), and starts one 1-credit clip per photo. Because Apps Script ends every run at 6 minutes, a 5-minute trigger then polls the jobs and merges finished clips into reels.
Last reviewed · By Zach Calhoon, Founder
Written for listing coordinators and brokerage ops staff who already track listings in a sheet and file photos in Drive. This is Google Sheets real estate video automation with no add-on; endpoint details are on the Real Estate Video API hub.
Sheet pipeline at a glance
| Built for | Coordinators and teams running listings from a Google Sheet |
|---|---|
| Add-on or integration | None — Apps Script + UrlFetchApp |
| Photos | One Drive folder per listing, JPEG/PNG, ≤ 6000 px a side |
| Run limit | 6 min per execution → submit / poll / merge as separate runs |
| Daily trigger time | 90 min (consumer) · 6 hr (Workspace) |
| Key storage | Script Properties, never a cell |
| Cost | 1 credit per clip + 1 per reel; failures refunded |
| No-code alternative | Automation Mode in the app |
Is there a PhotoAIVideo add-on for Google Sheets?
No. PhotoAIVideo has no Sheets add-on, no Google integration and no partnership with Google. This is ordinary Apps Script, opened from Extensions → Apps Script in your sheet, sending HTTPS requests to the public REST API with UrlFetchApp. Your Google account is the only thing it runs on: no server and no workflow tool.
If you only need a video now and then, skip the script. Upload the photos in the app and use Automation Mode. The sheet route pays off once listings already flow through a tracker.
What does the listing tracker spreadsheet need?
The sheet is the job queue. One row per listing, and every job ID sits in a cell where a coordinator can see it, rather than in script properties, which hold at most 9 KB per value and 500 KB per store.
| Column | What the script writes | Who edits it |
|---|---|---|
| Listing ID | Nothing | Coordinator |
| Drive folder ID | Nothing | Coordinator |
| Photo order (optional) | Nothing | Coordinator, when file names aren't prefixed |
| Status | Ready → Clips submitted → Clips done → Reels submitted → Done, or Needs attention | Coordinator sets Ready; script does the rest |
| Clip job IDs | file name = job ID pairs, in clip order | Script (a person may clear a bad pair) |
| MLS reel URL | output_video_url of the landscape cut | Script |
| Social reel URL | output_video_url of the portrait cut | Script |
| Note | Skipped files, error_message text, credit shortfalls | Script; coordinator reads it |
Three functions share the work. None of them waits for a render inside a single run:
| Function | Runs when | Endpoints | Stops when |
|---|---|---|---|
| submitClips() | Custom menu item, or a 15-minute trigger | GET /api/v1/credits · GET /api/v1/presigned-urls · PUT presignedUrl · POST /api/v1/videos | No Ready rows left, a few rows handled, a 402, or ~4.5 minutes used |
| pollJobs() | Time-driven trigger, every 5 minutes | GET /api/v1/videos/:jobId · GET /api/v1/reels/:jobId | Immediately if no row is waiting; otherwise when every waiting row is checked or time runs short |
| mergeReels(row) | Called by pollJobs() once a row's clips are all finished | POST /api/v1/reels ×2 | After both merge jobs are accepted and their IDs are saved |
Why does the work have to be split into three functions?
Apps Script kills any execution after 6 minutes, and the API docs give no finish time for a job, so waiting on renders inside one run risks hitting that wall. So submitClips() takes a few Ready rows and returns; pollJobs() checks status on a time-driven trigger made with ScriptApp.newTrigger('pollJobs').timeBased().everyMinutes(5).create(), since everyMinutes accepts only 1, 5, 10, 15 or 30; and mergeReels() fires when a row's last clip lands. Each run reads the clock as it loops and quits around four and a half minutes, leaving the remaining rows for its next turn.
Budget the trigger clock, not just credits. Google caps total trigger runtime at 90 minutes a day for gmail.com accounts and 6 hours on Workspace, and URL Fetch calls at 20,000 against 100,000. A poll that wakes with nothing to check still spends runtime, so pollJobs() should scan the Status column and return at once when no row is waiting. Delete the trigger when the queue empties, or limit it to office hours. Google says on its quotas page that these numbers can change without notice; overrunning one throws an exception and halts the run.
How do Drive photos get to the API?
Google Drive listing photos to video takes a copy step. The API reads only images on its own storage and turns away outside links, so a Drive share link can't go in imageUrl. Ask for up to 20 upload slots in one free call, then do a UrlFetchApp presigned upload of each file's bytes:
const API = 'https://app.photoaivideo.com'
const OK_TYPES = ['image/jpeg', 'image/png']
function uploadPhotos(files, key) {
const photos = files.filter((f) => OK_TYPES.includes(f.getMimeType()))
const res = UrlFetchApp.fetch(API + '/api/v1/presigned-urls?count=' + photos.length, {
headers: { Authorization: 'Bearer ' + key },
muteHttpExceptions: true,
})
const uploads = JSON.parse(res.getContentText()).uploads
return photos.map((file, i) => {
const put = UrlFetchApp.fetch(uploads[i].presignedUrl, {
method: 'put',
contentType: file.getMimeType(),
payload: file.getBlob().getBytes(),
muteHttpExceptions: true,
})
if (put.getResponseCode() >= 300) throw new Error('Upload failed: ' + file.getName())
return { name: file.getName(), imageUrl: uploads[i].publicUrl }
})
}Only JPEG and PNG are accepted, so the filter runs before anything is spent. Apps Script's getAs() converts only between BMP, GIF, JPEG and PNG, which means an iPhone HEIC file can't be fixed in the script: skip it and write "Export as JPEG" in the Note column. The FSBO platforms page explains the iPhone "Most Compatible" camera setting that avoids HEIC. Keep photos to 6000 pixels or fewer on each side; larger ones fail and are refunded.
How do you start a clip and read the answer safely?
By default UrlFetchApp throws on any error status, which would end the run mid-row. Passing muteHttpExceptions: true hands back the response instead, so the apps script video API call can branch on the code:
function startClip(imageUrl, prompt) {
const key = PropertiesService.getScriptProperties().getProperty('PHOTOAIVIDEO_KEY')
const res = UrlFetchApp.fetch(API + '/api/v1/videos', {
method: 'post',
headers: { Authorization: 'Bearer ' + key },
contentType: 'application/json',
payload: JSON.stringify({ prompt, imageUrl, effects: ['push_in'], duration: 5, model: 'hypernova' }),
muteHttpExceptions: true,
})
const code = res.getResponseCode()
if (code < 300) return { jobId: JSON.parse(res.getContentText()).jobId }
switch (code) {
case 402: return { halt: 'Out of credits' }
case 401:
case 403: return { halt: 'API key problem' }
default: return { note: res.getContentText().slice(0, 300) }
}
}A 402 means the balance ran dry; its body reports required and remaining, so write "Out of credits" on the row and stop the run. A 400 names the allowed values for a mistyped effect code or a duration other than 4, 5 or 6. A 401 or 403 points at the key or at API access that isn't switched on. When pollJobs() later finds a failed job, it copies error_message into Note; every such message confirms the refund. Before touching a row, read GET /api/v1/credits and compare remainingCredits with the photo count plus two reels.
Where should the API key live, and whose quota is spent?
Add the key under Project Settings → Script Properties as PHOTOAIVIDEO_KEY. Never type it into a cell, where anyone with view access reads it, or into the code, where it travels with every copy of the project.
Script properties are shared by everyone who uses the script, and installable triggers always run as the person who created them. Pick one owner to install the triggers; that account's daily quotas are what the queue consumes. Teammates only change rows.
How do finished clips become an MLS reel and a social reel?
Clip order follows the file names in the Drive folder, so coordinators prefix them 01_, 02_ and so on, with the exterior first as the establishing shot. A Photo order column overrides that when renaming isn't practical.
mergeReels() posts the same ordered IDs twice, 1 credit each, without regenerating any clip. The MLS version is landscape and unbranded:
const mlsCut = {
videoJobIds: orderedJobIds,
orientation: 'landscape',
musicType: 'no_music',
}
UrlFetchApp.fetch(API + '/api/v1/reels', {
method: 'post',
headers: { Authorization: 'Bearer ' + key },
contentType: 'application/json',
payload: JSON.stringify(mlsCut),
muteHttpExceptions: true,
})The social version switches to portrait, adds the address as textOverlay and an ending card. Write each output_video_url into its column. The docs don't state how long hosted files are kept, so also save the MP4 into the listing folder with UrlFetchApp and DriveApp when it stays under the 50 MB response limit; for anything larger, keep the link and download it by hand.
What does one row look like from Ready to Done?
Illustrative example — not a real listing, sheet or customer. A 1970s split-level whose folder holds 13 files, 01_front through 13_backyard. 12_den.heic fails the type check, so it never uploads and costs nothing. The remaining twelve pass a 14-credit check and share one count=12 request.
| Run | What happened | Credits |
|---|---|---|
| submitClips(), pass 1 | 12_den.heic skipped before upload, Note: Export as JPEG | 0 |
| submitClips(), pass 1 | Credit check needs 14 (12 clips + 2 reels) and passes; one count=12 upload call | 0 |
| submitClips(), pass 1 | 12 clip jobs accepted | 12 |
| pollJobs() | Stair-landing photo fails as too large; error_message copied to Note | −1 refunded |
| mergeReels() | 11 IDs merged twice: landscape MLS cut, portrait social cut | 2 |
| First pass, net | 11 clips, 2 reels (14 charged, 1 refunded) | 13 |
| Row reset to Ready | Only the den and landing photos are submitted | 2 |
| mergeReels(), again | Both cuts rebuilt from 13 IDs | 2 |
| Listing total | 13 clips, 4 reels | 17 |
With the landing photo shrunk and the den exported as JPEG, the coordinator flips Status back to Ready. Because the Clip job IDs cell already pairs eleven file names with finished jobs, only two photos go up. Finished renders live on the examples page, and plans and credits are on the pricing page.
What stays outside PhotoAIVideo
The sheet and its script choose the photos, their sequence and camera moves, and where each link ends up. PhotoAIVideo renders clips and reels and reports job status; it does nothing else here.
Frequently Asked Questions
Try it on one row first
Create a key, save it in Script Properties and mark a single listing Ready before you install the polling trigger.
Sources
- Apps Script: Quotas for Google services: 6-minute runs, daily trigger runtime, URL Fetch and Properties limits; accessed November 30, 2026.
- Apps Script: UrlFetchApp: fetch parameters, payload types, muteHttpExceptions; accessed November 30, 2026.
- Apps Script: Properties service: script vs user properties, Project Settings; accessed November 30, 2026.
- Apps Script: ClockTriggerBuilder: allowed everyMinutes values; accessed November 30, 2026.
- Apps Script: Installable triggers: time-driven triggers and whose account they run under; accessed November 30, 2026.
- Apps Script: DriveApp File: getBlob, getMimeType, getAs image formats; accessed November 30, 2026.
- PhotoAIVideo API v1 docs: auth, credits, presigned uploads, clip and reel jobs, errors; accessed November 30, 2026.
Google Sheets, Google Drive and Apps Script are trademarks of Google LLC; PhotoAIVideo isn't affiliated with or endorsed by Google.