# Google Docs (/integrations/google_docs)





{/* MANUAL-CONTENT-START:intro */}

Use [Google Docs](https://docs.google.com) in Sim to read, create, and update documents. Workflows can insert text, tables, images, and page breaks; find and replace text; and apply text styling.

{/* MANUAL-CONTENT-END */}

## OAuth scopes [#oauth-scopes]

Sim requests these scopes when someone connects a Google Docs account. For a self-hosted deployment, register your own app with the provider using the settings below. See [Integrations and OAuth](/platform/self-hosting/integrations-oauth) for setup.

| Setting | Value |
| - | - |
| Redirect URI | `<NEXT_PUBLIC_APP_URL>/api/auth/oauth2/callback/google-docs` |
| Environment variables | `GOOGLE_CLIENT_ID`, `GOOGLE_CLIENT_SECRET` |

| Scope | Description |
| - | - |
| `https://www.googleapis.com/auth/userinfo.email` | View email address |
| `https://www.googleapis.com/auth/userinfo.profile` | View basic profile info |
| `https://www.googleapis.com/auth/drive.file` | View and manage Google Drive files you open or create with Sim |
| `https://www.googleapis.com/auth/drive` | View, edit, create, and delete all Google Drive files |

## Use the block [#usage-instructions]

Read, write, and create documents, insert text, tables, images, and page breaks, find and replace text, and apply text styling.

## Actions [#actions]

### Read Google Docs Document [#read-google-docs-document]

Read content from a Google Docs document

<ReferenceDetails>
  #### Input [#input]

  | Parameter | Type | Required | Description |
  | - | - | - | - |
  | `documentId` | string | Yes | Google Docs document ID |

  #### Output [#output]

  | Parameter | Type | Description |
  | - | - | - |
  | `content` | string | Extracted document text content |
  | `metadata` | json | Document metadata including ID, title, and URL |
  | ↳ `documentId` | string | Google Docs document ID |
  | ↳ `title` | string | Document title |
  | ↳ `mimeType` | string | Document MIME type |
  | ↳ `url` | string | Document URL |
</ReferenceDetails>

### Write to Google Docs Document [#write-to-google-docs-document]

Append content to a Google Docs document. Content is inserted literally; Markdown is not interpreted. For formatted output from Markdown, use the Create operation with the markdown toggle enabled.

<ReferenceDetails>
  #### Input [#input-1]

  | Parameter | Type | Required | Description |
  | - | - | - | - |
  | `documentId` | string | Yes | The ID of the document to write to |
  | `content` | string | Yes | The content to write to the document |

  #### Output [#output-1]

  | Parameter | Type | Description |
  | - | - | - |
  | `updatedContent` | boolean | Indicates if document content was updated successfully |
  | `metadata` | json | Updated document metadata including ID, title, and URL |
  | ↳ `documentId` | string | Google Docs document ID |
  | ↳ `title` | string | Document title |
  | ↳ `mimeType` | string | Document MIME type |
  | ↳ `url` | string | Document URL |
</ReferenceDetails>

### Create Google Docs Document [#create-google-docs-document]

Create a new Google Docs document

<ReferenceDetails>
  #### Input [#input-2]

  | Parameter | Type | Required | Description |
  | - | - | - | - |
  | `title` | string | Yes | The title of the document to create |
  | `content` | string | No | The content of the document to create |
  | `folderSelector` | string | No | Google Drive folder ID to create the document in (e.g., 1ABCxyz...) |
  | `folderId` | string | No | The ID of the folder to create the document in (internal use) |
  | `markdown` | boolean | No | When true, content is interpreted as Markdown and converted to formatted Google Docs content (headings, bold/italic, lists, tables, links, code blocks, blockquotes). Default: false (content inserted as plain text). |

  #### Output [#output-2]

  | Parameter | Type | Description |
  | - | - | - |
  | `metadata` | json | Created document metadata including ID, title, and URL |
  | ↳ `documentId` | string | Google Docs document ID |
  | ↳ `title` | string | Document title |
  | ↳ `mimeType` | string | Document MIME type |
  | ↳ `url` | string | Document URL |
</ReferenceDetails>

### Insert Text into Google Docs Document [#insert-text-into-google-docs-document]

Insert text at a specific index in a Google Docs document. When no index is provided, text is appended to the end of the document. Text is inserted literally; Markdown is not interpreted.

<ReferenceDetails>
  #### Input [#input-3]

  | Parameter | Type | Required | Description |
  | - | - | - | - |
  | `documentId` | string | Yes | The ID of the document to insert text into |
  | `text` | string | Yes | The text to insert |
  | `index` | number | No | The character index (the document body starts at index 1) at which to insert the text. When omitted, text is appended to the end of the document. |

  #### Output [#output-3]

  | Parameter | Type | Description |
  | - | - | - |
  | `updatedContent` | boolean | Indicates if text was inserted successfully |
  | `metadata` | json | Updated document metadata including ID, title, and URL |
  | ↳ `documentId` | string | Google Docs document ID |
  | ↳ `title` | string | Document title |
  | ↳ `mimeType` | string | Document MIME type |
  | ↳ `url` | string | Document URL |
</ReferenceDetails>

### Find and Replace Text in Google Docs Document [#find-and-replace-text-in-google-docs-document]

Replace all occurrences of a search string with new text across a Google Docs document.

<ReferenceDetails>
  #### Input [#input-4]

  | Parameter | Type | Required | Description |
  | - | - | - | - |
  | `documentId` | string | Yes | The ID of the document to update |
  | `searchText` | string | Yes | The text to find |
  | `replaceText` | string | No | The text to replace matches with. Use an empty string to delete matches. |
  | `matchCase` | boolean | No | Whether the search should be case sensitive. Defaults to false. |

  #### Output [#output-4]

  | Parameter | Type | Description |
  | - | - | - |
  | `occurrencesChanged` | number | The number of occurrences that were replaced |
  | `metadata` | json | Updated document metadata including ID, title, and URL |
  | ↳ `documentId` | string | Google Docs document ID |
  | ↳ `title` | string | Document title |
  | ↳ `mimeType` | string | Document MIME type |
  | ↳ `url` | string | Document URL |
</ReferenceDetails>

### Insert Table into Google Docs Document [#insert-table-into-google-docs-document]

Insert an empty table with the given number of rows and columns into a Google Docs document. When no index is provided, the table is appended to the end of the document.

<ReferenceDetails>
  #### Input [#input-5]

  | Parameter | Type | Required | Description |
  | - | - | - | - |
  | `documentId` | string | Yes | The ID of the document to insert the table into |
  | `rows` | number | Yes | The number of rows in the table |
  | `columns` | number | Yes | The number of columns in the table |
  | `index` | number | No | The character index (the document body starts at index 1) at which to insert the table. When omitted, the table is appended to the end of the document. |

  #### Output [#output-5]

  | Parameter | Type | Description |
  | - | - | - |
  | `updatedContent` | boolean | Indicates if the table was inserted successfully |
  | `metadata` | json | Updated document metadata including ID, title, and URL |
  | ↳ `documentId` | string | Google Docs document ID |
  | ↳ `title` | string | Document title |
  | ↳ `mimeType` | string | Document MIME type |
  | ↳ `url` | string | Document URL |
</ReferenceDetails>

### Insert Image into Google Docs Document [#insert-image-into-google-docs-document]

Insert an inline image from a public URL into a Google Docs document. The image must be publicly accessible and under 50 MB. When no index is provided, the image is appended to the end of the document.

<ReferenceDetails>
  #### Input [#input-6]

  | Parameter | Type | Required | Description |
  | - | - | - | - |
  | `documentId` | string | Yes | The ID of the document to insert the image into |
  | `imageUrl` | string | Yes | The publicly accessible URL of the image to insert |
  | `index` | number | No | The character index (the document body starts at index 1) at which to insert the image. When omitted, the image is appended to the end of the document. |
  | `width` | number | No | Optional image width in points (PT) |
  | `height` | number | No | Optional image height in points (PT) |

  #### Output [#output-6]

  | Parameter | Type | Description |
  | - | - | - |
  | `objectId` | string | The ID of the inserted inline image object |
  | `metadata` | json | Updated document metadata including ID, title, and URL |
  | ↳ `documentId` | string | Google Docs document ID |
  | ↳ `title` | string | Document title |
  | ↳ `mimeType` | string | Document MIME type |
  | ↳ `url` | string | Document URL |
</ReferenceDetails>

### Insert Page Break into Google Docs Document [#insert-page-break-into-google-docs-document]

Insert a page break into a Google Docs document. When no index is provided, the page break is appended to the end of the document.

<ReferenceDetails>
  #### Input [#input-7]

  | Parameter | Type | Required | Description |
  | - | - | - | - |
  | `documentId` | string | Yes | The ID of the document to insert the page break into |
  | `index` | number | No | The character index (the document body starts at index 1) at which to insert the page break. When omitted, the page break is appended to the end of the document. |

  #### Output [#output-7]

  | Parameter | Type | Description |
  | - | - | - |
  | `updatedContent` | boolean | Indicates if the page break was inserted successfully |
  | `metadata` | json | Updated document metadata including ID, title, and URL |
  | ↳ `documentId` | string | Google Docs document ID |
  | ↳ `title` | string | Document title |
  | ↳ `mimeType` | string | Document MIME type |
  | ↳ `url` | string | Document URL |
</ReferenceDetails>

### Apply Text Style in Google Docs Document [#apply-text-style-in-google-docs-document]

Apply bold, italic, underline, and/or font size to a range of text in a Google Docs document, identified by its start and end character index.

<ReferenceDetails>
  #### Input [#input-8]

  | Parameter | Type | Required | Description |
  | - | - | - | - |
  | `documentId` | string | Yes | The ID of the document to update |
  | `startIndex` | number | Yes | The start character index (the document body starts at index 1) of the range to style (inclusive) |
  | `endIndex` | number | Yes | The end character index of the range to style (exclusive) |
  | `bold` | boolean | No | Whether to make the text bold |
  | `italic` | boolean | No | Whether to make the text italic |
  | `underline` | boolean | No | Whether to underline the text |
  | `fontSize` | number | No | The font size to apply, in points (PT) |

  #### Output [#output-8]

  | Parameter | Type | Description |
  | - | - | - |
  | `updatedContent` | boolean | Indicates if the text style was applied successfully |
  | `metadata` | json | Updated document metadata including ID, title, and URL |
  | ↳ `documentId` | string | Google Docs document ID |
  | ↳ `title` | string | Document title |
  | ↳ `mimeType` | string | Document MIME type |
  | ↳ `url` | string | Document URL |
</ReferenceDetails>

### Update Paragraph Style in Google Docs Document [#update-paragraph-style-in-google-docs-document]

Apply a named paragraph style (such as a heading or title) and/or alignment to the paragraphs overlapping a range of text in a Google Docs document, identified by its start and end character index.

<ReferenceDetails>
  #### Input [#input-9]

  | Parameter | Type | Required | Description |
  | - | - | - | - |
  | `documentId` | string | Yes | The ID of the document to update |
  | `startIndex` | number | Yes | The start character index (the document body starts at index 1) of the range to style (inclusive) |
  | `endIndex` | number | Yes | The end character index of the range to style (exclusive) |
  | `namedStyleType` | string | No | The named paragraph style to apply. One of: NORMAL\_TEXT, TITLE, SUBTITLE, HEADING\_1, HEADING\_2, HEADING\_3, HEADING\_4, HEADING\_5, HEADING\_6. |
  | `alignment` | string | No | The paragraph alignment to apply. One of: LEFT, CENTER, RIGHT, JUSTIFY. |

  #### Output [#output-9]

  | Parameter | Type | Description |
  | - | - | - |
  | `updatedContent` | boolean | Indicates if the paragraph style was applied successfully |
  | `metadata` | json | Updated document metadata including ID, title, and URL |
  | ↳ `documentId` | string | Google Docs document ID |
  | ↳ `title` | string | Document title |
  | ↳ `mimeType` | string | Document MIME type |
  | ↳ `url` | string | Document URL |
</ReferenceDetails>

### Create Paragraph Bullets in Google Docs Document [#create-paragraph-bullets-in-google-docs-document]

Add bulleted or numbered list formatting to the paragraphs overlapping a range of text in a Google Docs document, using a chosen bullet glyph preset.

<ReferenceDetails>
  #### Input [#input-10]

  | Parameter | Type | Required | Description |
  | - | - | - | - |
  | `documentId` | string | Yes | The ID of the document to update |
  | `startIndex` | number | Yes | The start character index (the document body starts at index 1) of the range to bullet (inclusive) |
  | `endIndex` | number | Yes | The end character index of the range to bullet (exclusive) |
  | `bulletPreset` | string | No | The bullet glyph preset to apply. Defaults to BULLET\_DISC\_CIRCLE\_SQUARE. Examples: BULLET\_DISC\_CIRCLE\_SQUARE, BULLET\_CHECKBOX, NUMBERED\_DECIMAL\_ALPHA\_ROMAN, NUMBERED\_DECIMAL\_NESTED. |

  #### Output [#output-10]

  | Parameter | Type | Description |
  | - | - | - |
  | `updatedContent` | boolean | Indicates if the bullets were applied successfully |
  | `metadata` | json | Updated document metadata including ID, title, and URL |
  | ↳ `documentId` | string | Google Docs document ID |
  | ↳ `title` | string | Document title |
  | ↳ `mimeType` | string | Document MIME type |
  | ↳ `url` | string | Document URL |
</ReferenceDetails>

### Delete Paragraph Bullets in Google Docs Document [#delete-paragraph-bullets-in-google-docs-document]

Remove bullet or numbered list formatting from the paragraphs overlapping a range of text in a Google Docs document, identified by its start and end character index.

<ReferenceDetails>
  #### Input [#input-11]

  | Parameter | Type | Required | Description |
  | - | - | - | - |
  | `documentId` | string | Yes | The ID of the document to update |
  | `startIndex` | number | Yes | The start character index (the document body starts at index 1) of the range to clear bullets from (inclusive) |
  | `endIndex` | number | Yes | The end character index of the range to clear bullets from (exclusive) |

  #### Output [#output-11]

  | Parameter | Type | Description |
  | - | - | - |
  | `updatedContent` | boolean | Indicates if the bullets were removed successfully |
  | `metadata` | json | Updated document metadata including ID, title, and URL |
  | ↳ `documentId` | string | Google Docs document ID |
  | ↳ `title` | string | Document title |
  | ↳ `mimeType` | string | Document MIME type |
  | ↳ `url` | string | Document URL |
</ReferenceDetails>

### Delete Content Range in Google Docs Document [#delete-content-range-in-google-docs-document]

Delete all content between a start and end character index in a Google Docs document. The endIndex is exclusive and must be greater than the startIndex.

<ReferenceDetails>
  #### Input [#input-12]

  | Parameter | Type | Required | Description |
  | - | - | - | - |
  | `documentId` | string | Yes | The ID of the document to delete content from |
  | `startIndex` | number | Yes | The start character index (the document body starts at index 1) of the range to delete (inclusive) |
  | `endIndex` | number | Yes | The end character index of the range to delete (exclusive) |

  #### Output [#output-12]

  | Parameter | Type | Description |
  | - | - | - |
  | `updatedContent` | boolean | Indicates if the content range was deleted successfully |
  | `metadata` | json | Updated document metadata including ID, title, and URL |
  | ↳ `documentId` | string | Google Docs document ID |
  | ↳ `title` | string | Document title |
  | ↳ `mimeType` | string | Document MIME type |
  | ↳ `url` | string | Document URL |
</ReferenceDetails>

### Create Named Range in Google Docs Document [#create-named-range-in-google-docs-document]

Create a named range over a span of content in a Google Docs document so it can be referenced or deleted later. The name may be 1-256 characters and need not be unique.

<ReferenceDetails>
  #### Input [#input-13]

  | Parameter | Type | Required | Description |
  | - | - | - | - |
  | `documentId` | string | Yes | The ID of the document to update |
  | `name` | string | Yes | The name of the range to create (1-256 characters) |
  | `startIndex` | number | Yes | The start character index (the document body starts at index 1) of the range (inclusive) |
  | `endIndex` | number | Yes | The end character index of the range (exclusive) |

  #### Output [#output-13]

  | Parameter | Type | Description |
  | - | - | - |
  | `namedRangeId` | string | The ID of the created named range |
  | `metadata` | json | Updated document metadata including ID, title, and URL |
  | ↳ `documentId` | string | Google Docs document ID |
  | ↳ `title` | string | Document title |
  | ↳ `mimeType` | string | Document MIME type |
  | ↳ `url` | string | Document URL |
</ReferenceDetails>

### Delete Named Range in Google Docs Document [#delete-named-range-in-google-docs-document]

Delete one or more named ranges from a Google Docs document by their ID or by name. Provide exactly one of namedRangeId or name; deleting by name removes all ranges sharing that name. The content itself is not removed.

<ReferenceDetails>
  #### Input [#input-14]

  | Parameter | Type | Required | Description |
  | - | - | - | - |
  | `documentId` | string | Yes | The ID of the document to update |
  | `namedRangeId` | string | No | The ID of the named range to delete. Provide exactly one of namedRangeId or namedRangeName. |
  | `namedRangeName` | string | No | The name of the named range(s) to delete. All ranges sharing this name are removed. Provide exactly one of namedRangeId or namedRangeName. |

  #### Output [#output-14]

  | Parameter | Type | Description |
  | - | - | - |
  | `updatedContent` | boolean | Indicates if the named range(s) were deleted successfully |
  | `metadata` | json | Updated document metadata including ID, title, and URL |
  | ↳ `documentId` | string | Google Docs document ID |
  | ↳ `title` | string | Document title |
  | ↳ `mimeType` | string | Document MIME type |
  | ↳ `url` | string | Document URL |
</ReferenceDetails>
