Learn · Developers

How to create videos from Google Sheets automatically

Contents

A lot of video work starts in a spreadsheet. An events team keeps its speakers in a Google Sheet. A store keeps its products there, an agency its clients, a school its classes.

Each row already holds everything one video needs: a name, a title, a date, a photo link. What’s missing is a way to turn every row into a finished video without opening an editor 40 times.

The answer has two parts. You design the video once as a template, with a placeholder for each column. Then something reads the rows and asks Shotstack’s video editing API to render the template once per row.

That “something” can be one of four things, and this guide shows all four:

  • Code inside the sheet: an Apps Script. It adds a Videos menu, makes a video for each new row and writes the video link back into the row.
  • Code outside the sheet: a Python script that reads the sheet with the gws command-line tool, makes a video for each new row and writes the link back. It runs on your own machine or a server.
  • No code: a Make, n8n or Zapier workflow that watches the sheet for new rows.
  • An AI assistant: an assistant such as Claude reads the sheet and renders the videos through the Shotstack connector, from one message.

The example is a speaker list for a conference. Every row becomes a square speaker announcement video.

TL;DR

  • Save one Shotstack template with a merge field for each column: a name column fills {{NAME}}, a photo column fills {{PHOTO}}.
  • Apps Script is the most complete option for a sheet you keep adding to. It costs nothing beyond your renders, writes the link back to each row, and a time-driven trigger makes it pick up new rows by itself.
  • A Python script with the gws command-line tool does the same from your own machine or a server, and writes all the links back in one request per run.
  • Make, n8n or Zapier do the same with no code. Shotstack has a guide for each, linked below.
  • An AI assistant with the Google Drive and Shotstack connectors needs nothing built. It suits a one-off batch of a few dozen rows. In my test, Claude read the sheet, rendered every row and saved the links to a new sheet, because the Drive connector can’t edit cells.
  • Write the CDN link back to the sheet, not the temporary render link. The CDN copy stays until you delete it.

Which way to use

Apps ScriptPython scriptMake, n8n or ZapierAI assistant
What you set upPaste about 100 lines of code into the sheetInstall gws, sign in once, run a Python scriptA workflow with 3 to 5 stepsTwo connectors, once
New rowsPicked up by a time-driven triggerPicked up each time the script runsPicked up by the workflow’s triggerOnly when you ask
Video linkWritten back to the rowWritten back to the rowWritten back to the rowListed in the chat or saved to a new sheet
Extra costNone (Google’s free quotas)NoneThe workflow tool’s planYour assistant’s plan
Best forA sheet your team keeps filling inDevelopers who keep code in a repository or run jobs on a serverTeams that already use one of these toolsOne batch, now

All four use the same template and the same sheet. You can start with the AI assistant to check the videos, then add the Apps Script once the sheet becomes a regular job.

What you need

  • A Shotstack account. Sign up for free and copy the production API key from the dashboard. Renders use credits; see pricing.
  • A Google Sheet you can edit.
  • A public link for every image or video the template uses. The render servers download the files from the internet, so a link that only works when you’re signed in won’t work.

Set up the sheet

Put the column names in row 1. Every column you want in the video gets a name. Then add three more columns for the script to fill in: status, render_id and video_url.

nameroletalkdatephotostatusrender_idvideo_url
Amara OkaforStaff engineer, Lumen FreightHow we ship 10,000 videos a dayThu 13 May, 10:30https://…
Tomas LindqvistHead of platform, Brightwell HealthPostgres & the “boring” stack: what we’d keepThu 13 May, 13:00https://…

The column names are the link between the sheet and the template. Each name in capitals is the merge field it fills: name fills {{NAME}} and date fills {{DATE}}. A column called photo url would fill {{PHOTO_URL}}.

The date column in my sheet holds real dates, formatted to show as “Thu 13 May, 10:30”. Keep that in mind for the script below: Google stores a date as a number.

Save a video template with merge fields

A Shotstack template is a saved edit that you render again and again with different data. Every value that changes per row is a merge field, a placeholder in double braces. The merging data guide explains how they work.

Here is the speaker template. It is a 7 second, 1080 × 1080 video: the photo fills the left side, and the name, role, talk title and time slide in on the right.

JSON
{
  "name": "Speaker announcement",
  "template": {
    "timeline": {
      "background": "#0F1A2B",
      "fonts": [
        {"src": "https://fonts.gstatic.com/s/inter/v20/UcCo3FwrK3iLTfvlaQc78lA2.ttf"},
        {"src": "https://fonts.gstatic.com/s/montserrat/v31/JTUSjIg1_i6t8kCHKm45xW5rygbi49c.ttf"}
      ],
      "tracks": [
        {
          "clips": [
            {
              "asset": {
                "type": "rich-text",
                "text": "SPEAKER  ·  FERNWAY DEV DAY 2027",
                "font": {"family": "UcCo3FwrK3iLTfvlaQc78lA2", "size": 20, "weight": "700", "color": "#F2B544"},
                "style": {"letterSpacing": 3, "lineHeight": 1.1},
                "align": {"horizontal": "left", "vertical": "middle"},
                "animation": {"preset": "fadeIn", "duration": 0.6, "style": "word", "direction": "up"}
              },
              "start": 0.2,
              "length": 6.8,
              "width": 470,
              "height": 60,
              "position": "center",
              "offset": {"x": 0.222, "y": 0.37},
              "transition": {"out": "fade"}
            }
          ]
        },
        {
          "clips": [
            {
              "asset": {
                "type": "rich-text",
                "text": "{{NAME}}",
                "font": {"family": "JTUSjIg1_i6t8kCHKm45xW5rygbi49c", "size": 76, "weight": "800", "color": "#FFFFFF"},
                "style": {"lineHeight": 1.1},
                "align": {"horizontal": "left", "vertical": "middle"},
                "animation": {"preset": "slideIn", "duration": 0.6, "style": "word", "direction": "up"}
              },
              "start": 0.5,
              "length": 6.5,
              "width": 470,
              "height": 200,
              "position": "center",
              "offset": {"x": 0.222, "y": 0.17},
              "transition": {"out": "fade"}
            }
          ]
        },
        {
          "clips": [
            {
              "asset": {
                "type": "rich-text",
                "text": "{{ROLE}}",
                "font": {"family": "UcCo3FwrK3iLTfvlaQc78lA2", "size": 30, "weight": "400", "color": "#A9B4C6"},
                "style": {"lineHeight": 1.1},
                "align": {"horizontal": "left", "vertical": "middle"},
                "animation": {"preset": "slideIn", "duration": 0.6, "style": "word", "direction": "up"}
              },
              "start": 0.9,
              "length": 6.1,
              "width": 470,
              "height": 90,
              "position": "center",
              "offset": {"x": 0.222, "y": 0.03},
              "transition": {"out": "fade"}
            }
          ]
        },
        {
          "clips": [
            {
              "asset": {
                "type": "rich-text",
                "text": "{{TALK}}",
                "font": {"family": "JTUSjIg1_i6t8kCHKm45xW5rygbi49c", "size": 38, "weight": "700", "color": "#F2B544"},
                "style": {"lineHeight": 1.1},
                "align": {"horizontal": "left", "vertical": "middle"},
                "animation": {"preset": "slideIn", "duration": 0.6, "style": "word", "direction": "up"}
              },
              "start": 1.3,
              "length": 5.7,
              "width": 470,
              "height": 220,
              "position": "center",
              "offset": {"x": 0.222, "y": -0.14},
              "transition": {"out": "fade"}
            }
          ]
        },
        {
          "clips": [
            {
              "asset": {
                "type": "rich-text",
                "text": "{{DATE}}",
                "font": {"family": "UcCo3FwrK3iLTfvlaQc78lA2", "size": 30, "weight": "600", "color": "#0F1A2B"},
                "style": {"lineHeight": 1.1},
                "align": {"horizontal": "left", "vertical": "middle"},
                "animation": {"preset": "fadeIn", "duration": 0.6, "style": "word", "direction": "up"},
                "background": {"color": "#FFFFFF", "opacity": 1, "borderRadius": 32},
                "padding": {"left": 24, "right": 24}
              },
              "start": 1.8,
              "length": 5.2,
              "width": 330,
              "height": 64,
              "position": "center",
              "offset": {"x": 0.157, "y": -0.35},
              "transition": {"out": "fade"}
            }
          ]
        },
        {
          "clips": [
            {
              "asset": {
                "type": "svg",
                "src": "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 12 1080\" width=\"12\" height=\"1080\"><rect width=\"12\" height=\"1080\" fill=\"#F2B544\"/></svg>"
              },
              "start": 0,
              "length": 7,
              "width": 12,
              "height": 1080,
              "position": "left",
              "offset": {"x": 0.45, "y": 0}
            }
          ]
        },
        {
          "clips": [
            {
              "asset": {"type": "image", "src": "{{PHOTO}}"},
              "start": 0,
              "length": 7,
              "width": 486,
              "height": 1080,
              "fit": "crop",
              "position": "center",
              "offset": {"x": -0.275, "y": 0},
              "transition": {"in": "fade"}
            }
          ]
        }
      ]
    },
    "output": {"format": "mp4", "size": {"width": 1080, "height": 1080}, "fps": 25}
  }
}

You can design the same thing in Shotstack Studio instead and copy its template ID. To save this JSON as a template, put it in a file called speaker-template.json and send it to the templates endpoint:

Bash
curl -X POST https://api.shotstack.io/edit/v1/templates \
  -H "x-api-key: $SHOTSTACK_API_KEY" \
  -H "Content-Type: application/json" \
  --data-binary @speaker-template.json

The response holds the template ID. Copy it; every method below needs it.

JSON
{"success":true,"message":"Created","response":{"message":"Template Successfully Created","id":"7d2f9c41-5e8a-4b3d-9f16-0c4e8a2b7d95"}}

This is the video one row makes:

Way 1: an Apps Script inside the sheet

Apps Script is the code editor built into Google Sheets. A script you add there belongs to that one sheet. It can add its own menu, read the rows and call any web API, and it runs on Google’s servers, so there is nothing to host.

Add the script

  1. Open the sheet that holds your rows, then click Extensions > Apps Script. The script only sees the sheet you open it from. A new tab opens with an empty myFunction.
  2. Delete everything in the editor, paste the script below, and click Save project (the disk icon).
  3. At the left, click Project Settings (the gear icon). Under Script Properties, click Add script property. Add SHOTSTACK_API_KEY with your production API key, then TEMPLATE_ID with your template ID. Click Save script properties.
  4. Go back to the sheet’s tab and reload the page. After a few seconds, a Videos menu appears at the end of the menu bar.

Here is the whole script:

JavaScript
/**
 * Make one Shotstack video for every row of this sheet.
 *
 * Row 1 holds the column names. Every column except status, render_id and video_url
 * fills the template merge field with the same name in capitals: a "name" column
 * fills {{NAME}}, a "photo url" column fills {{PHOTO_URL}}.
 *
 * Set two script properties first (Project Settings > Script properties):
 *   SHOTSTACK_API_KEY  your production API key
 *   TEMPLATE_ID        the id of the template to render
 */
const API = 'https://api.shotstack.io/edit/v1';
const OUTPUT_COLUMNS = ['status', 'render_id', 'video_url'];
const MAX_PER_RUN = 50;

function onOpen() {
  SpreadsheetApp.getUi()
    .createMenu('Videos')
    .addItem('Make videos for new rows', 'makeVideos')
    .addItem('Check video status', 'checkVideos')
    .addToUi();
}

// For a time-driven trigger: send new rows, then pick up finished videos.
function makeAndCheck() {
  makeVideos();
  checkVideos();
}

function makeVideos() {
  const { key, templateId } = getSettings();
  const { sheet, header, col, rows } = readSheet();
  let sent = 0;
  rows.forEach((row, i) => {
    const empty = row.every((cell) => cell === '');
    if (empty || row[col.status] !== '' || sent >= MAX_PER_RUN) return;
    const merge = header
      .filter((name) => name !== '' && !OUTPUT_COLUMNS.includes(name))
      .map((name) => ({
        find: name.toUpperCase().replace(/\s+/g, '_'),
        replace: row[col[name]],
      }));
    const rowNumber = i + 2;
    try {
      const render = callShotstack('post', '/templates/render', key, { id: templateId, merge });
      sheet.getRange(rowNumber, col.render_id + 1).setValue(render.id);
      sheet.getRange(rowNumber, col.status + 1).setValue('queued');
    } catch (err) {
      sheet.getRange(rowNumber, col.status + 1).setValue('error: ' + err.message);
    }
    sent++;
  });
}

function checkVideos() {
  const { key } = getSettings();
  const { sheet, col, rows } = readSheet();
  rows.forEach((row, i) => {
    const id = row[col.render_id];
    const status = row[col.status];
    if (id === '' || status === 'done' || status.startsWith('failed')) return;
    const rowNumber = i + 2;
    try {
      const render = callShotstack('get', '/render/' + id, key);
      if (render.status === 'done') {
        const link = `https://cdn.shotstack.io/au/v1/${render.owner}/${render.id}.mp4`;
        sheet.getRange(rowNumber, col.video_url + 1).setValue(link);
      }
      const text = render.status === 'failed' ? 'failed: ' + render.error : render.status;
      sheet.getRange(rowNumber, col.status + 1).setValue(text);
    } catch (err) {
      // Leave the row as it is; the next check tries again.
      console.log(`Row ${rowNumber}: ${err.message}`);
    }
  });
}

function getSettings() {
  const props = PropertiesService.getScriptProperties();
  const key = props.getProperty('SHOTSTACK_API_KEY');
  const templateId = props.getProperty('TEMPLATE_ID');
  if (!key || !templateId) {
    throw new Error('Add SHOTSTACK_API_KEY and TEMPLATE_ID in Project Settings > Script properties.');
  }
  return { key, templateId };
}

function readSheet() {
  const sheet = SpreadsheetApp.getActiveSheet();
  // Display values: a date cell comes back as the sheet shows it, not as a number.
  const values = sheet.getDataRange().getDisplayValues();
  const header = values[0].map((name) => name.trim().toLowerCase());
  const col = {};
  header.forEach((name, i) => (col[name] = i));
  OUTPUT_COLUMNS.forEach((name) => {
    if (!(name in col)) throw new Error(`Add a column named "${name}" to row 1.`);
  });
  return { sheet, header, col, rows: values.slice(1) };
}

function callShotstack(method, path, key, body) {
  const options = { method, headers: { 'x-api-key': key }, muteHttpExceptions: true };
  if (body) {
    options.contentType = 'application/json';
    options.payload = JSON.stringify(body);
  }
  const res = UrlFetchApp.fetch(API + path, options);
  const data = JSON.parse(res.getContentText() || '{}');
  if (res.getResponseCode() >= 300) {
    throw new Error(data.message || data.error || 'HTTP ' + res.getResponseCode());
  }
  return data.response;
}

Make the videos

  1. Click Videos > Make videos for new rows.
  2. The first time, Google asks you to authorize the script. If it says Google hasn’t verified the app, click Advanced, then Go to … (unsafe): the app is your own script. Allow access. If the status column does not change, click Videos > Make videos for new rows again.
  3. Each row’s status changes to queued and its render_id fills in.
  4. Wait a minute, then click Videos > Check video status. A finished row shows done, and its video_url holds the link to the video.

One run of the menu made all four speakers’ videos. Here is a frame from each:

A frame from each of the four speaker announcement videos, one per row of the sheet

How the script works

  • onOpen runs when the sheet opens and adds the Videos menu. Google only lets a script that belongs to the sheet add a menu, which is why the script lives in the sheet and not in a separate project.
  • makeVideos reads every row. It skips a row that is empty or already has a status. For the rest, it turns every column except the three output columns into a merge field and sends one request to POST /templates/render. Shotstack answers at once with a render ID; the script stores it and sets the status to queued.
  • checkVideos asks GET /render/{id} about every row that isn’t finished yet and copies the status into the sheet. When a render is done, it builds the CDN link and writes it to video_url.
  • readSheet uses getDisplayValues(), not getValues(). In my sheet, getValues() would have sent the date as a number such as 46520.4375. getDisplayValues() sends “Thu 13 May, 10:30”, exactly as the cell shows it.
  • The API key and template ID live in script properties, not in the code, so you can share the sheet’s script without sharing the key.

The link the script writes is the CDN copy of the video. Shotstack’s hosting docs give its format: https://cdn.shotstack.io/au/v1/{owner}/{render id}.mp4, with both values in the render status response. The file stays there until you delete it. The url in the render status response is a temporary link, so don’t keep that one.

Pick up new rows automatically

The menu works when someone remembers to click it. To make videos for new rows without anyone clicking, run makeAndCheck on a timer:

  1. In the Apps Script tab, click Triggers (the alarm clock icon) at the left.
  2. Click Add Trigger at the bottom right.
  3. Set Choose which function to run to makeAndCheck, Select event source to Time-driven, Select type of time based trigger to Minutes timer and Select minute interval to Every 5 minutes.
  4. Click Save.

Every 5 minutes, the script now sends any new rows and fills in the finished ones. Google’s installable triggers guide says a time-driven trigger can run “as frequently as every minute or as infrequently as once per month”.

To make the video again for a row, clear its status cell. The next run sends it again.

Limits to know

  • Shotstack: the Edit API takes up to 300 requests per 60 seconds per production key (limits). That’s why the script sends at most 50 rows per run (MAX_PER_RUN). Each row needs one request to start and at least one to check, so a run stays well under the limit.
  • Google: Apps Script has daily quotas. A script can run for 6 minutes at a time. A personal Google account gets 20,000 URL Fetch calls a day and 90 minutes of trigger run time; a Google Workspace account gets 100,000 calls and 6 hours.

For thousands of rows, a script on your own machine or a server is a better fit, like the Python script in Way 2. For a CSV file, Bulk create videos from a CSV shows a script in Node.js and Python, with a manifest that lets you stop and resume.

Way 2: a Python script that reads the sheet

If you’d rather keep the code in your own repository, or run it on your own machine or a server, a script outside the sheet does the same job as the Apps Script. This one is Python. It reads and writes the sheet with gws, a command-line tool for the Google Workspace APIs whose commands mirror the Sheets API one to one. Its README says it is “not an officially supported Google product”.

Install gws and sign in

  1. Download the gws program for your system from the gws releases page and put it in a folder on your PATH. The README also lists npm and Homebrew. On Windows, use the downloaded program, not the npm package: the npm gws command is a .cmd wrapper, and Windows splits its arguments at an &. In my test, the talk title Postgres & the "boring" stack broke the command through the wrapper and went through the program unchanged.
  2. Sign in. gws needs an OAuth client from a Google Cloud project. If you have the gcloud tool, gws auth setup creates one for you. Without it, the README gives these steps: set the OAuth consent screen to External (testing mode is fine), add your Google account under Test users, create an OAuth client of type Desktop app, and save its JSON file as ~/.config/gws/client_secret.json. Also enable the Google Sheets API in the project.
  3. Run gws auth login -s sheets and approve access in the browser.
  4. Check that gws can read your sheet. The sheet ID is the long part of its URL, between /d/ and /edit:
Bash
gws sheets spreadsheets values get --params '{"spreadsheetId": "YOUR_SHEET_ID", "range": "Speakers"}'

To run the script on a server with no browser, the README describes pointing GOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE at a service account key instead of signing in. Share the sheet with the service account’s email so it can edit the sheet.

The script

Save this as sheet_videos.py:

Python
"""Make one Shotstack video for every new row of a Google Sheet and write each video's link back into the row.

The sheet is read and written with gws, the Google Workspace CLI (https://github.com/googleworkspace/cli).
Row 1 holds the column names. Every column except status, render_id and video_url fills the template merge
field with the same name in capitals: a "name" column fills {{NAME}}, a "photo url" column fills {{PHOTO_URL}}.

Usage:
  python sheet_videos.py SPREADSHEET_ID SHEET_NAME           send new rows, check sent ones, write back
  python sheet_videos.py SPREADSHEET_ID SHEET_NAME --wait    the same, then keep checking until all are done

Set SHOTSTACK_API_KEY (your production key) and TEMPLATE_ID first.
Set GWS to the full path of the gws program if it is not on your PATH.
"""
import json
import os
import subprocess
import sys
import time

import requests

API = "https://api.shotstack.io/edit/v1"
GWS = os.environ.get("GWS", "gws")
OUTPUT_COLUMNS = ["status", "render_id", "video_url"]


def gws(*args, body=None):
    command = [GWS, *args] + (["--json", json.dumps(body)] if body is not None else [])
    result = subprocess.run(command, capture_output=True, text=True, encoding="utf-8")
    if result.returncode != 0:
        sys.exit(f"gws failed: {result.stdout or result.stderr}")
    return json.loads(result.stdout)


def read_sheet(sheet_id, sheet_name):
    # The default value render option returns each cell as the sheet shows it, so dates stay readable.
    data = gws("sheets", "spreadsheets", "values", "get",
               "--params", json.dumps({"spreadsheetId": sheet_id, "range": sheet_name}))
    values = data.get("values", [])
    header = [name.strip().lower() for name in values[0]]
    for name in OUTPUT_COLUMNS:
        if name not in header:
            sys.exit(f'Add a column named "{name}" to row 1.')
    rows = [row + [""] * (len(header) - len(row)) for row in values[1:]]
    return header, rows


def column_letter(index):
    letters = ""
    index += 1
    while index:
        index, rest = divmod(index - 1, 26)
        letters = chr(65 + rest) + letters
    return letters


def write_back(sheet_id, sheet_name, header, changes):
    """Write every changed cell in one request. changes = {(row_number, column_name): value}."""
    if not changes:
        return
    data = [{"range": f"{sheet_name}!{column_letter(header.index(column))}{row_number}", "values": [[value]]}
            for (row_number, column), value in changes.items()]
    gws("sheets", "spreadsheets", "values", "batchUpdate", "--params", json.dumps({"spreadsheetId": sheet_id}),
        body={"valueInputOption": "RAW", "data": data})


def shotstack(method, path, body=None):
    r = requests.request(method, API + path, json=body, timeout=30,
                         headers={"x-api-key": os.environ["SHOTSTACK_API_KEY"]})
    data = r.json() if r.content else {}
    if not r.ok:
        raise RuntimeError(data.get("message") or data.get("error") or f"HTTP {r.status_code}")
    return data["response"]


def send_new_rows(header, rows, changes):
    for i, row in enumerate(rows):
        status = row[header.index("status")]
        if status or all(cell == "" for cell in row):
            continue
        merge = [{"find": name.upper().replace(" ", "_"), "replace": row[c]}
                 for c, name in enumerate(header) if name and name not in OUTPUT_COLUMNS]
        try:
            render = shotstack("POST", "/templates/render", {"id": os.environ["TEMPLATE_ID"], "merge": merge})
            changes[(i + 2, "render_id")] = render["id"]
            changes[(i + 2, "status")] = row[header.index("status")] = "queued"
            row[header.index("render_id")] = render["id"]
        except RuntimeError as err:
            changes[(i + 2, "status")] = row[header.index("status")] = f"error: {err}"
        time.sleep(0.25)  # stays under the Edit API limit of 300 requests a minute


def check_sent_rows(header, rows, changes):
    """Ask Shotstack about every unfinished row. Returns how many are still rendering."""
    waiting = 0
    for i, row in enumerate(rows):
        render_id, status = row[header.index("render_id")], row[header.index("status")]
        if not render_id or status == "done" or status.startswith(("failed", "error")):
            continue
        try:
            render = shotstack("GET", f"/render/{render_id}")
        except RuntimeError as err:
            print(f"Row {i + 2}: {err}")  # leave the row as it is; the next check tries again
            waiting += 1
            continue
        status = "failed: " + render.get("error", "") if render["status"] == "failed" else render["status"]
        if status == "done":
            changes[(i + 2, "video_url")] = f"https://cdn.shotstack.io/au/v1/{render['owner']}/{render['id']}.mp4"
        if status != row[header.index("status")]:
            changes[(i + 2, "status")] = row[header.index("status")] = status
        if status != "done" and not status.startswith("failed"):
            waiting += 1
    return waiting


def main():
    sheet_id, sheet_name = sys.argv[1], sys.argv[2]
    header, rows = read_sheet(sheet_id, sheet_name)
    changes = {}
    send_new_rows(header, rows, changes)
    waiting = check_sent_rows(header, rows, changes)
    write_back(sheet_id, sheet_name, header, changes)
    print(f"Wrote {len(changes)} cells. {waiting} videos still rendering.")
    deadline = time.time() + 15 * 60
    while "--wait" in sys.argv and waiting and time.time() < deadline:
        time.sleep(10)
        changes = {}
        waiting = check_sent_rows(header, rows, changes)
        write_back(sheet_id, sheet_name, header, changes)
        print(f"Wrote {len(changes)} cells. {waiting} videos still rendering.")


if __name__ == "__main__":
    main()

Run the script

Set your production API key and template ID, then run the script with the sheet ID and the name of the tab:

Bash
pip install requests
export SHOTSTACK_API_KEY="your_production_api_key"
export TEMPLATE_ID="your_template_id"
python sheet_videos.py 1Xq8YzT3fK2mR7vN4bW9cJ6hL0sD5gP1aE3uI8oQ2tZy Speakers --wait

On Windows, in PowerShell, set the two values with $env:SHOTSTACK_API_KEY = "..." and $env:TEMPLATE_ID = "...". If gws isn’t on your PATH, also set GWS to the full path of the program.

In my test, with the four speakers and empty output columns, the script printed:

Text
Wrote 8 cells. 4 videos still rendering.
Wrote 8 cells. 0 videos still rendering.

The first line is the four rows sent: a render_id and the status queued for each. The second is the four finished rows: the status done and the video_url for each. The four links played the same videos as the Apps Script made, and the talk title with &, quotes and an apostrophe came through as typed.

When I ran the script again, it printed Wrote 0 cells. 0 videos still rendering.: a row that already has a status is never sent twice. I also added a row and ran the script with a template ID that doesn’t exist. The row’s status became error: Not Found, and no other row changed.

How the Python script works

  • read_sheet reads the whole tab with one gws call. The Sheets API returns each cell as the sheet shows it, so the date came through as “Thu 13 May, 10:30”, not as a number.
  • send_new_rows uses the same rule as the Apps Script: every column except the three output columns fills the merge field with its name in capitals. It sends one POST /templates/render request per new row.
  • check_sent_rows asks GET /render/{id} about every unfinished row and builds the CDN link when a render is done.
  • write_back writes every changed cell in one request, so even hundreds of rows make one write to the sheet each round.
  • --wait keeps checking every 10 seconds, for up to 15 minutes, until every video is finished. Without it, the script sends the new rows, checks once and stops. Run it again later to fill in the links.

To pick up new rows by themselves, run the script on a schedule, for example with cron on Linux or Task Scheduler on Windows. I ran it with Python 3.13 and gws 0.22.5.

Way 3: no code, with Make, n8n or Zapier

Make, n8n and Zapier all have a Google Sheets trigger and a Shotstack step, so the workflow is the same shape in each:

  1. A new row in the sheet starts the workflow.
  2. Render a template sends the row’s values to your template’s merge fields.
  3. Update the row writes the video link and status back.

Shotstack has a step-by-step guide for each tool. Use the one for the tool you already pay for:

  • Make: Build a Make scenario for video automation watches a sheet of weekly offers, renders a template for each new row and writes the CDN link back. The guide was built on Make’s Free plan.
  • n8n: Real estate videos with n8n turns a listing row into a narrated tour when you set its status to “Make video”, and writes the status back as it goes. To build your own workflow from scratch, start with n8n video automation.
  • Zapier: the Zapier integration page shows how to start a Zap from a new Google Sheets row and map each column to a merge field.

These tools are the right choice when the sheet is one step in a longer process. For example, the next step could email each speaker their video or post it to a social channel.

Way 4: ask an AI assistant

If the sheet is a one-off batch, you don’t need to build anything. An AI assistant that can read your Google Drive and talk to Shotstack can make the videos from one message.

Connect the two tools

I used Claude. Both connections are made once, under Customize > Connectors:

  1. Google Drive: find Google Drive in the list, click Connect and sign in with the Google account that owns the sheet.
  2. Shotstack: click the + button next to Connectors, choose Add custom connector, name it Shotstack and enter https://mcp.shotstack.io/ as the URL. Click Connect and sign in to Shotstack. How to connect Shotstack to your AI tools with MCP has the same steps with screenshots, and the setup for other assistants.

On a Claude Team or Enterprise plan, an owner has to allow connectors for the organization first.

Ask for the videos

Send a message like this one, with your own sheet and template names:

Text
Read my Google Sheet "Speaker videos". For every row, render my Shotstack
template "Speaker announcement" with the row's values: NAME from name,
ROLE from role, TALK from talk, DATE from date and PHOTO from photo.
When every video is done, save a new Google Sheet called
"Speaker videos - links" with each name and its CDN video link.

Claude read the sheet through the Google Drive connector, with the dates as the cells show them. It then called the Shotstack connector’s render_template tool once per row, with the five merge fields filled in from that row.

When the four renders were done, it built the CDN links from the render status and saved them as a new sheet: one row per speaker, with the name and the link. The four videos are the same as the ones the Apps Script made.

What to expect

  • It reads the whole sheet. I tried a test sheet of 150 rows, and the Google Drive connector returned all 150, with dates as the cells show them.
  • Each row is one tool call. The assistant sends one render request per row from the chat. That’s fine for a few dozen rows. For hundreds, use the Apps Script or the Python script.
  • The links come back to you, not into the cells. The Google Drive connector can read a sheet and create new files, but it can’t change cells in an existing sheet. That’s why my message asks for a new sheet of links. Claude’s help center says its separate Google Sheets connector can edit Sheets in a pane beside the chat on the web and in Claude Desktop; I didn’t test that here.

You can set up ChatGPT the same way. Its Google Drive app gives it access to Sheets, and our ChatGPT guide shows how to connect Shotstack. I ran this test in Claude only.

The assistant is also a quick way to design the template: ask it for a video, ask for changes until it looks right, then ask it to save the edit as a template with a merge field for each of your column names.

Make your first sheet of videos

For one batch today, ask your AI assistant. For a sheet your team keeps adding to, paste in the Apps Script and set the trigger, or run the Python script on a schedule. All four methods render the same template, so you can switch later without redoing the design.

Create a free Shotstack account to get your API key and save your first template.

Frequently asked questions (FAQs)

Why does a date in my video show as a number?

The script read the cell’s value instead of what the cell shows. Google stores a date as a number of days; in my sheet, Thursday 13 May 2027 at 10:30 was 46520.4375. In Apps Script, read the rows with getDisplayValues(), as the script above does. The Python script gets the shown value by default. Then set the date format you want in the sheet.

Why does the script say “Add a column named “render_id” to row 1”?

The script could not find one of its three output columns: status, render_id and video_url. Add the missing column names to row 1. If they are already there, check that you opened Apps Script from that sheet. A script added to a different spreadsheet reads that spreadsheet’s rows instead. The Python script prints the same message; check the sheet ID and tab name you gave it.

What happens when a cell is empty?

The merge field is replaced with nothing. I rendered a row with an empty role cell: the video showed the name, the talk and the time, with a blank line where the role would be. Nothing else moved.

Can I use a CSV or Excel file instead of a Google Sheet?

Yes. The template and merge fields are the same; only the part that reads the rows changes. Bulk create videos from a CSV reads a CSV file with Node.js or Python.

Can I make vertical videos for each row?

Yes. Change the template’s output.size to 1080 × 1920 and move the clips to fit the new shape. The sheet and the script stay the same. For a product catalog, AI product video ads with n8n makes a vertical ad for each row, with an animated product photo and a voiceover.

Keep reading

Start free

  • Unlimited developer sandbox
  • No credit card required