# Sync inventory from Google Sheets (OAuth)

Updates Shopify inventory from a Google Sheet selected through a Google OAuth connection, with optional product-level auto publish and auto unpublish rules.

Canonical URL: https://templates.jsworkflows.com/templates/sync-inventory-from-google-sheets-oauth/

## When to use this template

This template is built for Shopify stores using the JsWorkflows app.

Use this template when you want a ready-made workflow for this use case: Updates Shopify inventory from a Google Sheet selected through a Google OAuth connection, with optional product-level auto publish and auto unpublish rules.

It is designed for Shopify inventory and merchandising operations and gives you a production-ready starting point instead of building the automation from scratch. It can work with Google as part of the workflow.

This workflow uses the scheduled trigger model and starts from the "Daily schedule" trigger. It includes setup fields for merchant-facing values, so you can configure the workflow before installing it.

## Metadata

- Category: Inventory and merch
- Trigger: Daily schedule
- Workflow type: Scheduled
- Complexity: advanced
- Usage class: heavy-operation

## Connected services

- google

## Additional Shopify scopes

- read_products
- read_locations
- read_inventory
- read_markets_home
- write_inventory
- read_publications
- write_publications

## Setup fields

- Google OAuth handle (`OAUTH_HANDLE`)
  - Type: text
  - Storage: config
  - Required: yes
  - Description: OAuth handle for the Google connection that can access the selected spreadsheet.
- Spreadsheet ID (`SPREADSHEET_ID`)
  - Type: google_drive_file_picker
  - Storage: config
  - Required: yes
  - Description: Select the Google Sheet with the picker or paste an already-accessible spreadsheet ID.
- Source sheet name (`SHEET_NAME`)
  - Type: text
  - Storage: config
  - Required: yes
  - Description: The tab name to read inventory rows from.
- Report sheet name (`REPORT_SHEET_NAME`)
  - Type: text
  - Storage: config
  - Required: no
  - Description: Optional tab used for row-level error reporting. Leave blank to disable report logging.
- Identifier mode (`IDENTIFIER_MODE`)
  - Type: select
  - Storage: config
  - Required: yes
  - Description: Use SKU for most catalogs. Use Handle only for single-variant products.
- Identifier source header override (`IDENTIFIER_COLUMN`)
  - Type: text
  - Storage: config
  - Required: no
  - Description: Optional source header name to use instead of the default 'Variant SKU' or 'Handle' column.
- Inventory header mappings (`INVENTORY_COLUMN_MAPPINGS`)
  - Type: textarea
  - Storage: config
  - Required: no
  - Description: Optional line-by-line mapping when supplier stock columns do not use the 'Inventory: Location Name' format. Use one line per mapping: Source Header => Shopify Location Name
- Channels for auto publish/unpublish (`PUBLICATION_IDS`)
  - Type: shopify_publication_multiselect
  - Storage: config
  - Required: no
  - Description: Optional Shopify sales channels used by the auto publish and auto unpublish rules.
- Auto publish when in stock (`AUTO_PUBLISH_WHEN_IN_STOCK`)
  - Type: checkbox
  - Storage: config
  - Required: no
  - Description: Publish affected products to the selected channels when Shopify's live tracked inventory is above zero after sync.
- Auto unpublish when out of stock (`AUTO_UNPUBLISH_WHEN_OUT_OF_STOCK`)
  - Type: checkbox
  - Storage: config
  - Required: no
  - Description: Unpublish affected products from the selected channels when all tracked variants are at zero or below after sync.

## Setup guide

## Before you start

This template reads a Google Sheet and updates Shopify inventory for **existing** products using a Google OAuth connection.

## Matching modes

- `Variant SKU` mode: best for catalogs with unique SKUs
- `Handle` mode: only for **single-variant** products

## Sheet model

- Row 1 must contain headers
- Header names matter; column order does not
- Each row represents one identifier update row
- Blank inventory cells are skipped
- A quantity of `0` is treated as a real update and sets that location to zero

## Required headers

When Identifier mode is `sku`:
- `Variant SKU`
- one or more `Inventory: Location Name` columns

When Identifier mode is `handle`:
- `Handle`
- one or more `Inventory: Location Name` columns

Examples:
- `Inventory: Sydney Warehouse`
- `Inventory: Melbourne Warehouse`

## Multi-location inventory

Use one inventory column per Shopify location. Any non-empty integer value in those columns is synced to that location.

If an inventory item is not yet stocked at a target location, the workflow automatically activates it before retrying the quantity update.

## Google OAuth setup

This version uses a Google OAuth handle instead of a service account.

Provide:
- `OAUTH_HANDLE`
- `SPREADSHEET_ID` using the Google picker or an already-accessible spreadsheet ID
- `SHEET_NAME`
- optional `REPORT_SHEET_NAME`

If you use the picker, the saved spreadsheet reference includes metadata such as the file name and resource key when available.

## Error reporting

If `Report sheet name` is set, the template appends row-level failures to that tab in the same selected spreadsheet.

Create the report tab before running the template. Leave the field blank to disable report logging.

## Publishing behavior

Optional auto publish and auto unpublish rules work at the **product** level. After a successful inventory update, the workflow checks Shopify's live tracked inventory for the affected product and then:

- publishes the product when any tracked variant has inventory above zero
- unpublishes the product when all tracked variants are at zero or below

Selected Shopify publications are loaded live in the setup UI and stored by publication ID.

Products with untracked variants are skipped for auto publish and auto unpublish, because tracked inventory alone would not be a reliable visibility signal for them.

## Internal pacing

This template automatically chooses internal row batch sizing and chunk staggering based on sheet size, inventory-column complexity, and whether auto publish or auto unpublish is enabled. Shopify throttling is handled internally with deferred retries so the workflow can slow down instead of surfacing throttle failures as row errors.

## Important limits

- `Handle` mode only supports single-variant products
- `Variant SKU` mode is the recommended mode for multi-variant catalogs
- This template updates inventory only. It does not change price, cost, metafields, or product content

## Header mapping overrides

If your supplier or source file uses different column names, you can keep the original file and configure mappings in setup:

- `Identifier source header override` lets you point the template at a custom SKU or handle column
- `Inventory header mappings` lets you map supplier stock columns to Shopify locations using one line per mapping

Example:
- `Supplier SKU =>` set in the identifier override field
- `Sydney Qty => Sydney Warehouse`
- `Melbourne Stock => Melbourne Warehouse`

