Skip to content
One API for Agents
Available

Google Docs

Read Google Docs as markdown, create them, and append, insert or replace text.

Google Docs holds briefs, reports and drafts. One API for Agents calls the Google Docs API with read and write access: agents read a document as clean markdown, create new ones, and append, insert or replace text. Documents are opened by ID or URL.

Provider id
gdocs
Auth
Sign in with Google or Microsoft (OAuth), Service account
Scopes
documents read-only
Endpoints
3 raw · 5 smart tools
Schemas
GET /v1/providers/gdocs
Markdown
/providers/gdocs.md

Smart tools

Curated calls with compact output for agents. Over MCP each one is a tool with the same name; over REST, pass it as tool.

docs_read

Read a Google Doc as markdown-style text (headings, lists, tables, links), with its title, revisionId, tabs, heading outline with indexes, and endIndex.

Name Type Notes
document required string Document ID, or its docs.google.com/document/d/<id>/… URL
tab_id string Read one tab only; by default every tab is included
max_chars integer default 50000 · 1000–500000
suggestions string How to show suggested edits; Google's default applies when omitted DEFAULT_FOR_CURRENT_ACCESSSUGGESTIONS_INLINEPREVIEW_SUGGESTIONS_ACCEPTEDPREVIEW_WITHOUT_SUGGESTIONS
REST
curl https://api.oneapiforagents.com/v1/call \
  -H "Authorization: Bearer $ONEAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "provider": "gdocs",
    "tool": "docs_read",
    "input": {
      "document": "https://docs.google.com/document/d/1AbCdEfGhIjKlMnOpQrStUvWxYz0123456789_-abc/edit"
    }
  }'
MCP tool call
{
  "tool": "docs_read",
  "arguments": {
    "document": "https://docs.google.com/document/d/1AbCdEfGhIjKlMnOpQrStUvWxYz0123456789_-abc/edit"
  }
}

docs_create

Create a Google Doc with a title and optional initial text (markdown headings, lists and paragraphs become Docs styles). Returns its ID and URL.

Name Type Notes
title required string
text string
format string markdown: # headings, - and 1. lists (indent to nest), [links](url), **bold**, *italic*. plain: text as is markdownplain default "markdown"
REST
curl https://api.oneapiforagents.com/v1/call \
  -H "Authorization: Bearer $ONEAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "provider": "gdocs",
    "tool": "docs_create",
    "input": {
      "title": "Weekly SEO report",
      "text": "# Summary\n- Clicks up 12%"
    }
  }'
MCP tool call
{
  "tool": "docs_create",
  "arguments": {
    "title": "Weekly SEO report",
    "text": "# Summary\n- Clicks up 12%"
  }
}

docs_append

Append text or simple markdown to the end of a Google Doc (or of one tab).

Name Type Notes
document required string Document ID, or its docs.google.com/document/d/<id>/… URL
text required string
format string markdown: # headings, - and 1. lists (indent to nest), [links](url), **bold**, *italic*. plain: text as is markdownplain default "markdown"
tab_id string Tab to use; defaults to the tab in the URL, else the first tab
REST
curl https://api.oneapiforagents.com/v1/call \
  -H "Authorization: Bearer $ONEAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "provider": "gdocs",
    "tool": "docs_append",
    "input": {
      "document": "1AbCdEfGhIjKlMnOpQrStUvWxYz0123456789_-abc",
      "text": "## Next steps\n- Refresh the pricing page"
    }
  }'
MCP tool call
{
  "tool": "docs_append",
  "arguments": {
    "document": "1AbCdEfGhIjKlMnOpQrStUvWxYz0123456789_-abc",
    "text": "## Next steps\n- Refresh the pricing page"
  }
}

docs_replace_text

Replace every occurrence of some text in a Google Doc. Case-sensitive unless match_case is false.

Name Type Notes
document required string Document ID, or its docs.google.com/document/d/<id>/… URL
find required string
replace required string Plain text; an empty string deletes the matches
match_case boolean default true
tab_id string Only this tab; by default every tab
REST
curl https://api.oneapiforagents.com/v1/call \
  -H "Authorization: Bearer $ONEAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "provider": "gdocs",
    "tool": "docs_replace_text",
    "input": {
      "document": "1AbCdEfGhIjKlMnOpQrStUvWxYz0123456789_-abc",
      "find": "Q3",
      "replace": "Q4"
    }
  }'
MCP tool call
{
  "tool": "docs_replace_text",
  "arguments": {
    "document": "1AbCdEfGhIjKlMnOpQrStUvWxYz0123456789_-abc",
    "find": "Q3",
    "replace": "Q4"
  }
}

docs_insert

Insert text or simple markdown into a Google Doc, either below a heading (matched by its text) or at an index from docs_read. Pass exactly one of heading or index.

Name Type Notes
document required string Document ID, or its docs.google.com/document/d/<id>/… URL
text required string
format string markdown: # headings, - and 1. lists (indent to nest), [links](url), **bold**, *italic*. plain: text as is markdownplain default "markdown"
heading string Heading text to find (case-insensitive; exact match preferred)
placement string With heading: right under it, or at the end of its section (before the next heading of the same or higher level) below_headingend_of_section default "below_heading"
index integer UTF-16 index. At a paragraph's start or end the text becomes new paragraphs; mid-paragraph it is inserted inline as plain text ≥ 1
revision_id string revisionId from docs_read; the insert fails if the doc changed since
tab_id string Tab to use; defaults to the tab in the URL, else the first tab
REST
curl https://api.oneapiforagents.com/v1/call \
  -H "Authorization: Bearer $ONEAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "provider": "gdocs",
    "tool": "docs_insert",
    "input": {
      "document": "1AbCdEfGhIjKlMnOpQrStUvWxYz0123456789_-abc",
      "heading": "Next steps",
      "text": "- Add FAQ schema"
    }
  }'
MCP tool call
{
  "tool": "docs_insert",
  "arguments": {
    "document": "1AbCdEfGhIjKlMnOpQrStUvWxYz0123456789_-abc",
    "heading": "Next steps",
    "text": "- Add FAQ schema"
  }
}

Raw endpoints

Passthrough to the Google Docs API. path fills URL placeholders, query the query string and body the JSON body. Input is validated before anything is sent; the response is the provider's own body.

documents.get

Read

The full Document resource. Pass includeTabsContent=true to get every tab in `tabs` (otherwise `body` holds the first tab only).

GET https://docs.googleapis.com/v1/documents/{documentId}

Name Type Notes
path.documentId required string Document ID or docs.google.com URL
query.suggestionsViewMode string DEFAULT_FOR_CURRENT_ACCESSSUGGESTIONS_INLINEPREVIEW_SUGGESTIONS_ACCEPTEDPREVIEW_WITHOUT_SUGGESTIONS
query.includeTabsContent boolean
REST
curl https://api.oneapiforagents.com/v1/call \
  -H "Authorization: Bearer $ONEAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "provider": "gdocs",
    "endpoint": "documents.get",
    "input": {
      "path": {
        "documentId": "1AbCdEfGhIjKlMnOpQrStUvWxYz0123456789_-abc"
      },
      "query": {
        "includeTabsContent": true
      }
    }
  }'
Input JSON Schema
JSON
{
  "type": "object",
  "properties": {
    "path": {
      "type": "object",
      "properties": {
        "documentId": {
          "description": "Document ID or docs.google.com URL",
          "type": "string"
        }
      },
      "required": [
        "documentId"
      ]
    },
    "query": {
      "type": "object",
      "properties": {
        "suggestionsViewMode": {
          "type": "string",
          "enum": [
            "DEFAULT_FOR_CURRENT_ACCESS",
            "SUGGESTIONS_INLINE",
            "PREVIEW_SUGGESTIONS_ACCEPTED",
            "PREVIEW_WITHOUT_SUGGESTIONS"
          ]
        },
        "includeTabsContent": {
          "type": "boolean"
        }
      }
    }
  },
  "required": [
    "path"
  ]
}

documents.create

Writes

Create a blank document. Only `title` is used; add content with documents.batchUpdate.

POST https://docs.googleapis.com/v1/documents

Name Type Notes
body.title string
REST
curl https://api.oneapiforagents.com/v1/call \
  -H "Authorization: Bearer $ONEAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "provider": "gdocs",
    "endpoint": "documents.create",
    "input": {
      "body": {
        "title": "Weekly SEO report"
      }
    }
  }'
Input JSON Schema
JSON
{
  "type": "object",
  "properties": {
    "body": {
      "type": "object",
      "properties": {
        "title": {
          "type": "string",
          "maxLength": 1000
        }
      }
    }
  },
  "required": [
    "body"
  ]
}

documents.batchUpdate

Writes

Apply Docs requests atomically (insertText, deleteContentRange, replaceAllText, createParagraphBullets, …). Indexes are UTF-16 code units; order edits from the highest index down.

POST https://docs.googleapis.com/v1/documents/{documentId}:batchUpdate

Name Type Notes
path.documentId required string Document ID or docs.google.com URL
body.requests required array<object (free-form)>
body.writeControl object
REST
curl https://api.oneapiforagents.com/v1/call \
  -H "Authorization: Bearer $ONEAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "provider": "gdocs",
    "endpoint": "documents.batchUpdate",
    "input": {
      "path": {
        "documentId": "1AbCdEfGhIjKlMnOpQrStUvWxYz0123456789_-abc"
      },
      "body": {
        "requests": [
          {
            "insertText": {
              "text": "Hello\n",
              "location": {
                "index": 1
              }
            }
          }
        ]
      }
    }
  }'
Input JSON Schema
JSON
{
  "type": "object",
  "properties": {
    "path": {
      "type": "object",
      "properties": {
        "documentId": {
          "description": "Document ID or docs.google.com URL",
          "type": "string"
        }
      },
      "required": [
        "documentId"
      ]
    },
    "body": {
      "type": "object",
      "properties": {
        "requests": {
          "minItems": 1,
          "maxItems": 500,
          "type": "array",
          "items": {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {}
          }
        },
        "writeControl": {
          "type": "object",
          "properties": {
            "requiredRevisionId": {
              "type": "string"
            },
            "targetRevisionId": {
              "type": "string"
            }
          }
        }
      },
      "required": [
        "requests"
      ]
    }
  },
  "required": [
    "path",
    "body"
  ]
}