Google Docs

App · Documents · 25 actions · 1 trigger

Create and edit documents in Google Docs.

Triggers

Start a workflow when something happens in Google Docs. See how triggers work.

Google Docs Document Modified

Triggers when a Google Docs document is modified

Filters

Narrow which events start a run.

document_idRequired

Event fields

What a run starts with. Later steps read each field with an @ reference.

document_idtext
titletext
revision_idtext

Actions

ActionWhat it does
Add bulleted listAdd a bulleted list to the end of a document.
Add header or footerWrite text in the header or footer shown on every page of a document, such as a company name or 'Confidential'.
Add headingAdd a heading to the end of a document.
Add imageAdd an image from a link to the end of a document.
Add linkAdd text that opens a link, such as 'View the invoice', to the end of a document.
Add numbered listAdd a numbered list (1, 2, 3) to the end of a document.
Add page breakStart a new page at the end of a document, so what's added next begins on it.
Add tableAdd a table to the end of a document, filled in from a list of rows, such as rows read from Google Sheets.
Add table columnAdd an empty column to a table in a document, after the column you choose or at the right.
Add table rowAdd an empty row to a table in a document, after the row you choose or at the bottom.
Add textAdd text to the end of a document.
Add text to the startAdd text to the very start of a document, before what's there, such as the newest entry at the top of a log.
Clear documentRemove everything from a document.
Create documentCreate a new document with a title.
Delete documentMove a document a workflow made to the trash in Google Drive, where it can be restored for 30 days.
Delete table columnDelete one column of a table in a document, and what is in it.
Delete table rowDelete one row of a table in a document, and what is in it.
Fill in placeholdersPut values in place of the placeholders in a document, such as {{name}} and {{date}} in a letter or contract, all in one step.
Name a passageGive a name to the first place some text appears in a document (Google calls it a named range), so scripts and add-ons can find that passage later.
Read documentRead the text of a document.
Remove a passage's nameTake a name off the passages it marks in a document (a named range).
Remove bullets and numberingTurn every bulleted or numbered list in a document into plain lines.
Remove floating imageRemove an image that floats over or beside the text of a document (one set to Wrap text or Behind text).
Remove header or footerRemove the header or footer shown on every page of a document, with its text.
Replace textReplace every occurrence of a word or phrase in a document.

Add bulleted list

Add a bulleted list to the end of a document.

Inputs

Documentdocument_idtextRequired
The document's ID, the part of its link after /d/
ItemsitemslistRequired
The lines of text to add as bullet points

Outputs

Bulleted-list insertion result

rangeobject
Start and end indexes of the inserted list
Example output
{
  "range": {
    "end": 120,
    "start": 70
  }
}

Write text in the header or footer shown on every page of a document, such as a company name or 'Confidential'. Text already there stays, and the new text goes on a line after it.

Inputs

Documentdocument_idtextRequired
The document: its link, or the id in it.
TexttexttextRequired
The text to write.
Wherewheretext
The top of each page (header) or the bottom (footer).One of: header (Header (top of each page)), footer (Footer (bottom of each page)). Default: header.

Outputs

document_idtext
ID of the document
segment_idtext
The header's or footer's ID in the document
wheretext
header or footer
Example output
{
  "document_id": "1AbCdEfGhIjKlMnOpQrStUvWxYz",
  "segment_id": "kix.hdr123",
  "where": "header"
}

Add heading

Add a heading to the end of a document.

Inputs

Documentdocument_idtextRequired
The document's ID, the part of its link after /d/
Heading textheading_texttextRequired
Text for the heading
Levelleveltext
Heading size, from largest to smallest: HEADING_1, HEADING_2, HEADING_3, or HEADING_4

Outputs

Heading insertion result

rangeobject
Start and end indexes of the inserted heading
Example output
{
  "range": {
    "end": 65,
    "start": 50
  }
}

Add image

Add an image from a link to the end of a document. The link must open the image itself for anyone (a PNG, JPEG or GIF under 50 MB); Google keeps a copy.

Inputs

Documentdocument_idtextRequired
The document: its link, or the id in it.
Image linkimage_urltextRequired
A public link to the image, starting with https://.
Width (pt)width_ptnumber
How wide to make it, in points (a page's text is about 468 pt wide). Leave empty to use the image's own size.From 1 to 1000.

Outputs

The image added

document_idtext
ID of the document the image was added to
image_idtext
The image's ID in the document
Example output
{
  "document_id": "1AbCdEfGhIjKlMnOpQrStUvWxYz",
  "image_id": "kix.abc123"
}

Add text that opens a link, such as 'View the invoice', to the end of a document.

Inputs

Documentdocument_idtextRequired
The document: its link, or the id in it.
Link texttexttextRequired
The words people click.
LinkurltextRequired
Where the words lead, starting with https://.

Outputs

document_idtext
ID of the document
rangeobject
Where in the document it was added
Example output
{
  "document_id": "1AbCdEfGhIjKlMnOpQrStUvWxYz",
  "range": {
    "end": 136,
    "start": 120
  }
}

Add numbered list

Add a numbered list (1, 2, 3) to the end of a document.

Inputs

Documentdocument_idtextRequired
The document: its link, or the id in it.
ItemsitemslistRequired
The lines of text to number, in order

Outputs

document_idtext
ID of the document
rangeobject
Where in the document it was added
Example output
{
  "document_id": "1AbCdEfGhIjKlMnOpQrStUvWxYz",
  "range": {
    "end": 120,
    "start": 70
  }
}

Add page break

Start a new page at the end of a document, so what's added next begins on it.

Inputs

Documentdocument_idtextRequired
The document: its link, or the id in it.

Outputs

addedtrue/false
Whether the page break was added
document_idtext
ID of the document
Example output
{
  "added": true,
  "document_id": "1AbCdEfGhIjKlMnOpQrStUvWxYz"
}

Add table

Add a table to the end of a document, filled in from a list of rows, such as rows read from Google Sheets. Records with named fields get a heading row of the names.

Inputs

Documentdocument_idtextRequired
The document: its link, or the id in it.
RowsrowslistRequired
The table's rows, each a list of the cells in it, from left to right. Up to 200 rows and 20 columns.

Outputs

The table added

columnsnumber
Columns in the table
document_idtext
ID of the document the table was added to
rowsnumber
Rows in the table
start_indexnumber
Where in the document the table starts
Example output
{
  "columns": 2,
  "document_id": "1AbCdEfGhIjKlMnOpQrStUvWxYz",
  "rows": 3,
  "start_index": 120
}

Add table column

Add an empty column to a table in a document, after the column you choose or at the right.

Inputs

Documentdocument_idtextRequired
The document: its link, or the id in it.
Tabletable_numbernumber
Which table, counting from the top of the document: 1 for the first.At least 1. Default: 1.
After columnafter_columnnumber
Add it after this column (1 is the leftmost). Leave blank to add it at the right.At least 1.

Outputs

columnsnumber
Columns the table has now
document_idtext
ID of the document
new_columnnumber
The new column's number
Example output
{
  "columns": 3,
  "document_id": "1AbCdEfGhIjKlMnOpQrStUvWxYz",
  "new_column": 3
}

Add table row

Add an empty row to a table in a document, after the row you choose or at the bottom.

Inputs

Documentdocument_idtextRequired
The document: its link, or the id in it.
Tabletable_numbernumber
Which table, counting from the top of the document: 1 for the first.At least 1. Default: 1.
After rowafter_rownumber
Add it after this row (1 is the top row). Leave blank to add it at the bottom.At least 1.

Outputs

document_idtext
ID of the document
new_rownumber
The new row's number
rowsnumber
Rows the table has now
Example output
{
  "document_id": "1AbCdEfGhIjKlMnOpQrStUvWxYz",
  "new_row": 4,
  "rows": 4
}

Add text

Add text to the end of a document.

Inputs

Documentdocument_idtextRequired
The document's ID, the part of its link after /d/
TexttexttextRequired
Text to append to the document

Outputs

Append result

inserted_atnumber
Index where the text was inserted
Example output
{
  "inserted_at": 42
}

Add text to the start

Add text to the very start of a document, before what's there, such as the newest entry at the top of a log.

Inputs

Documentdocument_idtextRequired
The document: its link, or the id in it.
TexttexttextRequired
Text to add. End it with a new line to keep it apart from the text after it.

Outputs

document_idtext
ID of the document
inserted_atnumber
Where in the document the text went (1, its start)
Example output
{
  "document_id": "1AbCdEfGhIjKlMnOpQrStUvWxYz",
  "inserted_at": 1
}

Clear document

Remove everything from a document.

Inputs

Documentdocument_idtextRequired
The ID of the document to clear

Outputs

No return value

Example output
{}

Create document

Create a new document with a title.

Inputs

TitletitletextRequired
Title of the new document
Texttexttext
Beta. Text to start the document with, such as a summary or meeting notes. Leave blank for an empty document.

Outputs

Created Google Docs document

document_idtext
Document ID of the created document
document_urltext
Link that opens the document, for a message or for moving it into a Drive folder
Example output
{
  "document_id": "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms",
  "document_url": "https://docs.google.com/document/d/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms/edit"
}

Delete document

Move a document a workflow made to the trash in Google Drive, where it can be restored for 30 days. Only documents made by workflows can be deleted.

Inputs

Documentdocument_idtextRequired
The document: its link, or the id in it. It must have been made by a workflow.

Outputs

deletedtrue/false
Whether the document was moved to the trash
document_idtext
ID of the document moved to the trash
Example output
{
  "deleted": true,
  "document_id": "1AbCdEfGhIjKlMnOpQrStUvWxYz"
}

Delete table column

Delete one column of a table in a document, and what is in it.

Inputs

Documentdocument_idtextRequired
The document: its link, or the id in it.
ColumncolumnnumberRequired
The column to delete: 1 for the leftmost.At least 1.
Tabletable_numbernumber
Which table, counting from the top of the document: 1 for the first.At least 1. Default: 1.

Outputs

columnsnumber
Columns the table has now
deleted_columnnumber
The column deleted
document_idtext
ID of the document
Example output
{
  "columns": 2,
  "deleted_column": 3,
  "document_id": "1AbCdEfGhIjKlMnOpQrStUvWxYz"
}

Delete table row

Delete one row of a table in a document, and what is in it.

Inputs

Documentdocument_idtextRequired
The document: its link, or the id in it.
RowrownumberRequired
The row to delete: 1 for the top row.At least 1.
Tabletable_numbernumber
Which table, counting from the top of the document: 1 for the first.At least 1. Default: 1.

Outputs

deleted_rownumber
The row deleted
document_idtext
ID of the document
rowsnumber
Rows the table has now
Example output
{
  "deleted_row": 3,
  "document_id": "1AbCdEfGhIjKlMnOpQrStUvWxYz",
  "rows": 2
}

Fill in placeholders

Put values in place of the placeholders in a document, such as {{name}} and {{date}} in a letter or contract, all in one step. Pair it with Google Drive's Duplicate file to fill in a copy of a template.

Inputs

Documentdocument_idtextRequired
The document: its link, or the id in it.
ValuesvaluesobjectRequired
Each placeholder's name and the value to put in its place. A name like client_name fills {{client_name}}. Up to 200.

Outputs

document_idtext
ID of the document
not_foundlist
Placeholders given that the document doesn't have
occurrences_changednumber
How many placeholders were filled in, counting each place one appears
Example output
{
  "document_id": "1AbCdEfGhIjKlMnOpQrStUvWxYz",
  "not_found": [],
  "occurrences_changed": 3
}

Name a passage

Give a name to the first place some text appears in a document (Google calls it a named range), so scripts and add-ons can find that passage later.

Inputs

Documentdocument_idtextRequired
The document: its link, or the id in it.
NamenametextRequired
The name to give it, up to 256 characters.
TexttexttextRequired
The text to name, exactly as it appears in one paragraph. The first place it appears is named.

Outputs

document_idtext
ID of the document
nametext
The name given
named_range_idtext
Google's ID for the named passage
rangeobject
Where in the document it was added
Example output
{
  "document_id": "1AbCdEfGhIjKlMnOpQrStUvWxYz",
  "name": "signature_block",
  "named_range_id": "kix.nr123",
  "range": {
    "end": 142,
    "start": 120
  }
}

Read document

Read the text of a document.

Inputs

Documentdocument_idtextRequired
The document's ID, the part of its link after /d/

Outputs

Plain text content of the document

texttext
Plain text content of the document
Example output
{
  "text": "This is the document content.\n\nIt has multiple paragraphs."
}

Remove a passage's name

Take a name off the passages it marks in a document (a named range). The text stays.

Inputs

Documentdocument_idtextRequired
The document: its link, or the id in it.
NamenametextRequired
The name to remove. Every passage with it loses it.

Outputs

deletedtrue/false
Whether it was removed
document_idtext
ID of the document
nametext
The name removed
Example output
{
  "deleted": true,
  "document_id": "1AbCdEfGhIjKlMnOpQrStUvWxYz",
  "name": "signature_block"
}

Remove bullets and numbering

Turn every bulleted or numbered list in a document into plain lines. The text stays.

Inputs

Documentdocument_idtextRequired
The document: its link, or the id in it.

Outputs

document_idtext
ID of the document
paragraphsnumber
How many list lines became plain lines
Example output
{
  "document_id": "1AbCdEfGhIjKlMnOpQrStUvWxYz",
  "paragraphs": 3
}

Remove floating image

Remove an image that floats over or beside the text of a document (one set to Wrap text or Behind text). Images in a line of text aren't counted.

Inputs

Documentdocument_idtextRequired
The document: its link, or the id in it.
Imageimage_numbernumber
Which floating image, counting from the top of the document: 1 for the first.At least 1. Default: 1.

Outputs

document_idtext
ID of the document
object_idtext
The removed image's ID
Example output
{
  "document_id": "1AbCdEfGhIjKlMnOpQrStUvWxYz",
  "object_id": "kix.abc123"
}

Remove the header or footer shown on every page of a document, with its text. A document without one is left as it is.

Inputs

Documentdocument_idtextRequired
The document: its link, or the id in it.
Whichwheretext
The header (top of each page) or the footer (bottom).One of: header (Header (top of each page)), footer (Footer (bottom of each page)). Default: header.

Outputs

document_idtext
ID of the document
removedtrue/false
Whether there was one to remove
wheretext
header or footer
Example output
{
  "document_id": "1AbCdEfGhIjKlMnOpQrStUvWxYz",
  "removed": true,
  "where": "header"
}

Replace text

Replace every occurrence of a word or phrase in a document.

Inputs

Documentdocument_idtextRequired
The document's ID, the part of its link after /d/
Find textfind_texttextRequired
Text to find in the document
Replace textreplace_texttext
Text to replace with. Leave empty to remove the text.

Outputs

Replacement result

occurrences_changednumber
Number of occurrences replaced
Example output
{
  "occurrences_changed": 3
}

On this page