> ## Documentation Index
> Fetch the complete documentation index at: https://docs.subverseai.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Google Sheets Service Account Credentials

> How to create and configure Google Sheets Service Account credentials for SubverseAI

# Google Sheets Service Account Credentials

Google Sheets Service Account credentials allow your SubverseAI agents to read from and write to Google Sheets — including **private sheets** — using server-to-server authentication.

## Overview

Google Sheets Service Account credentials provide access to:

* Reading and writing data on private and public spreadsheets
* Appending, updating, and deleting rows
* Managing multiple sheets programmatically
* Secure, non-interactive authentication without user login

## Steps to Create Google Sheets Service Account Credentials

### 1. Set Up a Google Cloud Project

1. Visit the [Google Cloud Console](https://console.cloud.google.com)
2. Sign in with your Google account
3. Create a new project or select an existing one

### 2. Enable the Google Sheets API

1. Navigate to **APIs & Services** > **Library**
2. Search for **Google Sheets API**
3. Click **Enable**

### 3. Create a Service Account

1. Go to **IAM & Admin** > [Service Accounts](https://console.cloud.google.com/iam-admin/serviceaccounts)
2. Click **Create Service Account**
3. Enter a name and description (e.g., "SubverseAI Sheets Integration")
4. Click **Create and Continue**
5. Skip optional role grants for now and click **Done**

### 4. Generate a JSON Key File

1. Click on the service account you just created
2. Go to the **Keys** tab
3. Click **Add Key** > **Create new key**
4. Select **JSON** and click **Create**
5. The key file is downloaded — keep it secure

### 5. Share Your Sheet with the Service Account

1. Open the Google Sheet you want to access
2. Click **Share**
3. Add the service account email (e.g., `service-account@project-id.iam.gserviceaccount.com`) as an **Editor** (or **Viewer** for read-only)
4. Click **Send**

### 6. Add to SubverseAI

1. Go to **Credentials** in your SubverseAI dashboard
2. Click **Create New Credential**
3. Select **Google Sheets Service Account** from the credential types
4. Enter a name for your credential (e.g., "Production Service Account")
5. Fill in the required fields from your JSON key file:
   * **Service Account Email**: The `client_email` field
   * **Private Key**: The `private_key` field (including `-----BEGIN PRIVATE KEY-----` header)
   * **Project ID** (optional): The `project_id` field
6. Click **Save Credential**

## Required Fields

* **Name**: A descriptive name for your credential
* **Service Account Email**: The `client_email` from your JSON key file
* **Private Key**: The `private_key` from your JSON key file

## Optional Fields

* **Project ID**: The `project_id` from your JSON key file

## Usage Tips

* Grant the service account only the minimum necessary permissions on each sheet
* Rotate JSON keys periodically for security
* Use separate service accounts for different environments (dev/staging/prod)
* Store the downloaded JSON key file securely and never commit it to version control

## Troubleshooting

**Permission Denied (403)**: Ensure the sheet has been shared with the service account email

**Invalid JWT / Private Key Error**: Verify the `private_key` value includes the full PEM block — newlines must be preserved (use `\n` if pasting inline)

**API Not Enabled**: Ensure the Google Sheets API is enabled in your Cloud project

**Service Account Not Found**: Confirm the `client_email` value was copied correctly from the JSON key file

## Next Steps

After creating your Google Sheets Service Account credentials:

* Build data entry and update workflows
* Automate report generation and sheet population
* Sync CRM or database records to Google Sheets
* Set up scheduled data exports and imports
