Operations (sample payloads)

Main operations

Create empty document

Creates an empty google document with a given title Sample Input

\{
    "access_token": "ya29.a0AWY7CkmhU8j_kJq2xT1jH3yc5jRmTxZ9Oj2L3QX6ZvY1tG_Hs8Jk2I9X...",
    "title": "Project Proposal 2023"
\}

Sample Output

{
    "title": "Project Proposal 2023",
    "body": {
        "content": [
            {
                "endIndex": 1,
                "sectionBreak": {
                    "sectionStyle": \{
                        "columnSeparatorStyle": "NONE",
                        "contentDirection": "LEFT_TO_RIGHT"
                    \}
                },
                "startIndex": 0,
                "paragraph": {
                    "elements": [
                        {
                            "startIndex": 0,
                            "endIndex": 1,
                            "textRun": {
                                "content": "\n",
                                "textStyle": {}
                            }
                        }
                    ],
                    "paragraphStyle": \{
                        "namedStyleType": "NORMAL_TEXT",
                        "direction": "LEFT_TO_RIGHT"
                    \}
                }
            }
        ]
    },
    "documentStyle": {
        "background": {
            "color": {}
        },
        "pageNumberStart": 1,
        "marginTop": \{
            "magnitude": 72,
            "unit": "PT"
        \},
        "marginBottom": \{
            "magnitude": 72,
            "unit": "PT"
        \},
        "marginRight": \{
            "magnitude": 72,
            "unit": "PT"
        \},
        "marginLeft": \{
            "magnitude": 72,
            "unit": "PT"
        \},
        "pageSize": {
            "height": \{
                "magnitude": 792,
                "unit": "PT"
            \},
            "width": \{
                "magnitude": 612,
                "unit": "PT"
            \}
        }
    },
    "namedStyles": {
        "styles": [
            {
                "namedStyleType": "NORMAL_TEXT",
                "textStyle": {
                    "foregroundColor": {
                        "color": {
                            "rgbColor": \{
                                "red": 0,
                                "green": 0,
                                "blue": 0
                            \}
                        }
                    },
                    "bold": false,
                    "smallCaps": false,
                    "weightedFontFamily": \{
                        "fontFamily": "Arial",
                        "weight": 400
                    \},
                    "underline": false,
                    "fontSize": \{
                        "magnitude": 11,
                        "unit": "PT"
                    \},
                    "italic": false,
                    "strikethrough": false,
                    "backgroundColor": {},
                    "baselineOffset": "NONE"
                },
                "paragraphStyle": \{
                    "alignment": "START",
                    "spacingMode": "COLLAPSE",
                    "lineSpacing": 115,
                    "direction": "LEFT_TO_RIGHT"
                \}
            }
        ]
    },
    "revisionId": "ALm37BVKLhYqODXwQWEwjVIzMDc3NDU5Nzg4OTM6MTY4NTY0MDAwMDAwMA",
    "suggestionsViewMode": "SUGGESTIONS_INLINE",
    "documentId": "1AbCdEfGhIjKlMnOpQrStUvWxYz12345678"
}

Find and replace

Replaces all instances of text matching a given criteria. Sample Input

{
    "access_token": "ya29.a0AfH6SMBgQjGkLxH1V...",
    "document_id": "1Ax7vSD3jH2kLm9xY0pZfT...",
    "requests": [
        {
            "replace_all_text": {
                "replace_text": "Tray.io",
                "contains_text": \{
                    "text": "Zapier",
                    "match_case": true
                \}
            }
        }
    ]
}

Sample Output

{
    "replies": [
        {
            "replaceAllText": {
                "occurrencesChanged": 5
            }
        }
    ],
    "writeControl": {
        "requiredRevisionId": "ALm37BUeK..."
    },
    "documentId": "1Ax7vSD3jH2kLm9xY0pZfT..."
}

Get document

Retrieves a document with a given ID Sample Input

\{
    "access_token": "ya29.a0AWY7CkmhU8j_kJq6vHDYQWOHBzxxxxxxxxxxx",
    "document_id": "1A2B3C4D5E6F7G8H9I0J1K2L3M4N5O6P7Q8R9S0T"
\}

Sample Output

{
    "title": "Project Proposal",
    "body": {
        "content": [
            {
                "endIndex": 1,
                "sectionBreak": {
                    "sectionStyle": \{
                        "columnSeparatorStyle": "NONE",
                        "contentDirection": "LEFT_TO_RIGHT"
                    \}
                },
                "startIndex": 0
            },
            {
                "endIndex": 15,
                "paragraph": {
                    "elements": [
                        {
                            "endIndex": 15,
                            "startIndex": 0,
                            "textRun": {
                                "content": "Project Proposal",
                                "textStyle": {
                                    "bold": true,
                                    "fontSize": \{
                                        "magnitude": 18,
                                        "unit": "PT"
                                    \}
                                }
                            }
                        }
                    ],
                    "paragraphStyle": \{
                        "namedStyleType": "HEADING_1",
                        "direction": "LEFT_TO_RIGHT"
                    \}
                },
                "startIndex": 1
            }
        ]
    },
    "documentStyle": {
        "background": {
            "color": {}
        },
        "pageNumberStart": 1,
        "marginTop": \{
            "magnitude": 72,
            "unit": "PT"
        \},
        "marginBottom": \{
            "magnitude": 72,
            "unit": "PT"
        \},
        "marginRight": \{
            "magnitude": 72,
            "unit": "PT"
        \},
        "marginLeft": \{
            "magnitude": 72,
            "unit": "PT"
        \},
        "pageSize": {
            "height": \{
                "magnitude": 792,
                "unit": "PT"
            \},
            "width": \{
                "magnitude": 612,
                "unit": "PT"
            \}
        }
    },
    "namedStyles": {
        "styles": [
            {
                "namedStyleType": "NORMAL_TEXT",
                "textStyle": {
                    "foregroundColor": {
                        "color": {
                            "rgbColor": \{
                                "red": 0,
                                "green": 0,
                                "blue": 0
                            \}
                        }
                    },
                    "fontSize": \{
                        "magnitude": 11,
                        "unit": "PT"
                    \},
                    "weightedFontFamily": \{
                        "fontFamily": "Arial",
                        "weight": 400
                    \}
                },
                "paragraphStyle": \{
                    "namedStyleType": "NORMAL_TEXT",
                    "alignment": "LEFT",
                    "lineSpacing": 1.15,
                    "direction": "LEFT_TO_RIGHT"
                \}
            }
        ]
    },
    "revisionId": "ALm37BVxxxxxxxx",
    "suggestionsViewMode": "SUGGESTIONS_INLINE",
    "documentId": "1A2B3C4D5E6F7G8H9I0J1K2L3M4N5O6P7Q8R9S0T"
}

Update document

Updates a google document with given fields Sample Input

{
    "access_token": "ya29.a0AWY7CklhO1J3M2...",
    "document_id": "1Ax7kj2xhJ3nGf5Y...",
    "requests": [
        {
            "insert_text": {
                "text": "Hello, this is a new paragraph.",
                "location": {
                    "index": 1
                }
            }
        }
    ]
}

Sample Output

{
    "replies": [
        {
            "insertText": {
                "insertedTextLength": 32
            }
        }
    ],
    "writeControl": {
        "requiredRevisionId": "ALm37BVgT..."
    },
    "documentId": "1Ax7kj2xhJ3nGf5Y..."
}

Was this page helpful?