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

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

Google Sheets listing-video pipeline facts
Built forCoordinators and teams running listings from a Google Sheet
Add-on or integrationNone — Apps Script + UrlFetchApp
PhotosOne Drive folder per listing, JPEG/PNG, ≤ 6000 px a side
Run limit6 min per execution → submit / poll / merge as separate runs
Daily trigger time90 min (consumer) · 6 hr (Workspace)
Key storageScript Properties, never a cell
Cost1 credit per clip + 1 per reel; failures refunded
No-code alternativeAutomation 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.

Columns in the listing tracker sheet, what the script writes to each and who edits it
ColumnWhat the script writesWho edits it
Listing IDNothingCoordinator
Drive folder IDNothingCoordinator
Photo order (optional)NothingCoordinator, when file names aren't prefixed
StatusReady → Clips submitted → Clips done → Reels submitted → Done, or Needs attentionCoordinator sets Ready; script does the rest
Clip job IDsfile name = job ID pairs, in clip orderScript (a person may clear a bad pair)
MLS reel URLoutput_video_url of the landscape cutScript
Social reel URLoutput_video_url of the portrait cutScript
NoteSkipped files, error_message text, credit shortfallsScript; coordinator reads it

Three functions share the work. None of them waits for a render inside a single run:

Apps Script functions, when each runs, the PhotoAIVideo endpoints it calls and when it stops
FunctionRuns whenEndpointsStops when
submitClips()Custom menu item, or a 15-minute triggerGET /api/v1/credits · GET /api/v1/presigned-urls · PUT presignedUrl · POST /api/v1/videosNo Ready rows left, a few rows handled, a 402, or ~4.5 minutes used
pollJobs()Time-driven trigger, every 5 minutesGET /api/v1/videos/:jobId · GET /api/v1/reels/:jobIdImmediately 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 finishedPOST /api/v1/reels ×2After 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.

Credits spent on the illustrative split-level row across each script run
RunWhat happenedCredits
submitClips(), pass 112_den.heic skipped before upload, Note: Export as JPEG0
submitClips(), pass 1Credit check needs 14 (12 clips + 2 reels) and passes; one count=12 upload call0
submitClips(), pass 112 clip jobs accepted12
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 cut2
First pass, net11 clips, 2 reels (14 charged, 1 refunded)13
Row reset to ReadyOnly the den and landing photos are submitted2
mergeReels(), againBoth cuts rebuilt from 13 IDs2
Listing total13 clips, 4 reels17

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

No. The API turns away images hosted anywhere but its own storage, so the script copies each Drive file to a presigned URL and sends the resulting publicUrl.

That's Apps Script's ceiling for a single execution. Split the job into short trigger runs that each save progress to the sheet and quit before the limit.

No. getAs() only converts between BMP, GIF, JPEG and PNG. Skip the file, flag it in the Note column and ask for a JPEG export.

Every 5 minutes is a sensible default. everyMinutes() accepts only 1, 5, 10, 15 or 30, and the function should exit straight away when no row is waiting.

Yes, with smaller daily allowances: 90 minutes of trigger runtime and 20,000 URL Fetch calls, against 6 hours and 100,000 on Workspace. Google may change these without notice.

Each job is charged when it's accepted and refunded automatically if it fails; the job's error_message explains what went wrong.

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

Google Sheets, Google Drive and Apps Script are trademarks of Google LLC; PhotoAIVideo isn't affiliated with or endorsed by Google.