Skip to content

Instantly share code, notes, and snippets.

@kmahorker
Created February 24, 2025 08:00
Show Gist options
  • Select an option

  • Save kmahorker/34e7f7c606d0aa503a6222505770d337 to your computer and use it in GitHub Desktop.

Select an option

Save kmahorker/34e7f7c606d0aa503a6222505770d337 to your computer and use it in GitHub Desktop.
{
"agentsJson": "0.1.0",
"info": {
"title": "Google Docs API Flows",
"version": "0.1.0",
"description": "This specification enables interaction with the Google Docs API by exposing individual operations (create, get, batch update) as well as compound flows (e.g. create and retrieve) that orchestrate multiple API calls. Each flow is described in detail so that AI agents and language models can call these methods with high accuracy."
},
"sources": [
{
"id": "googledocs",
"path": "https://raw.githubusercontent.com/wild-card-ai/agents-json/refs/heads/integrations/googledocs/agents_json/googledocs/openapi.yaml"
},
{
"id": "googledocs_alternate",
"path": "https://docs.googleapis.com/$discovery/rest?version=v1"
}
],
"overrides": [],
"flows": [
{
"id": "document_create",
"title": "Create Document",
"description": "Creates a blank Google Document with a specified title. Use this flow to initialize a new document. In addition to the title (supplied via the request body), an optional 'fields' query parameter allows clients to restrict the returned fields.",
"actions": [
{
"id": "create_document_action",
"sourceId": "googledocs",
"operationId": "googledocs_create_document"
}
],
"links": [
{
"origin": {
"actionId": "document_create",
"fieldPath": "requestBody.title"
},
"target": {
"actionId": "create_document_action",
"fieldPath": "requestBody.title"
}
},
{
"origin": {
"actionId": "document_create",
"fieldPath": "parameters.fields"
},
"target": {
"actionId": "create_document_action",
"fieldPath": "parameters.fields"
}
}
],
"fields": {
"parameters": [
{
"name": "fields",
"description": "Optional. Selector specifying which fields to include in a partial response.",
"required": false,
"type": "string"
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"description": "Google Docs document definition. Provide the title of the document.",
"properties": {
"title": {
"type": "string",
"description": "Title of the document."
}
},
"required": [
"title"
]
},
"example": {
"title": "My New Document"
}
}
},
"required": true
},
"responses": {
"success": {
"type": "object",
"description": "The created Google Document resource, including documentId and details.",
"example": {
"documentId": "doc123",
"title": "My New Document"
}
}
}
}
},
{
"id": "document_get",
"title": "Get Document",
"description": "Retrieves the latest version of a specified Google Document based on its documentId. Optional parameters include suggestionsViewMode and fields selectors for a partial response.",
"actions": [
{
"id": "get_document_action",
"sourceId": "googledocs",
"operationId": "googledocs_get_document"
}
],
"links": [
{
"origin": {
"actionId": "document_get",
"fieldPath": "parameters.documentId"
},
"target": {
"actionId": "get_document_action",
"fieldPath": "parameters.documentId"
}
},
{
"origin": {
"actionId": "document_get",
"fieldPath": "parameters.suggestionsViewMode"
},
"target": {
"actionId": "get_document_action",
"fieldPath": "parameters.suggestionsViewMode"
}
},
{
"origin": {
"actionId": "document_get",
"fieldPath": "parameters.fields"
},
"target": {
"actionId": "get_document_action",
"fieldPath": "parameters.fields"
}
}
],
"fields": {
"parameters": [
{
"name": "documentId",
"description": "The ID of the Google Document to retrieve.",
"required": true,
"type": "string"
},
{
"name": "suggestionsViewMode",
"description": "Optional. The view mode for document suggestions (e.g., DEFAULT_FOR_CURRENT_ACCESS, SUGGESTIONS_INLINE, PREVIEW_SUGGESTIONS_ACCEPTED, PREVIEW_WITHOUT_SUGGESTIONS).",
"required": false,
"type": "string",
"enum": [
"DEFAULT_FOR_CURRENT_ACCESS",
"SUGGESTIONS_INLINE",
"PREVIEW_SUGGESTIONS_ACCEPTED",
"PREVIEW_WITHOUT_SUGGESTIONS"
]
},
{
"name": "fields",
"description": "Optional. Selector specifying which fields to include in a partial response.",
"required": false,
"type": "string"
}
],
"responses": {
"success": {
"type": "object",
"description": "The retrieved Google Document details.",
"example": {
"documentId": "doc123",
"title": "My New Document",
"body": {
"content": [
{
"paragraph": {
"elements": [
{
"textRun": {
"content": "Example content"
}
}
]
}
}
]
}
}
}
}
}
},
{
"id": "document_batch_update",
"title": "Batch Update Document",
"description": "Applies one or more update requests to a Google Document. This flow covers all supported update operations including inserting text, updating paragraph style, creating bullets, deleting a range of content, replacing text, and updating text style. An optional 'fields' parameter allows a partial response.",
"actions": [
{
"id": "batch_update_document_action",
"sourceId": "googledocs",
"operationId": "googledocs_batch_update_documents"
}
],
"links": [
{
"origin": {
"actionId": "document_batch_update",
"fieldPath": "parameters.documentId"
},
"target": {
"actionId": "batch_update_document_action",
"fieldPath": "parameters.documentId"
}
},
{
"origin": {
"actionId": "document_batch_update",
"fieldPath": "parameters.fields"
},
"target": {
"actionId": "batch_update_document_action",
"fieldPath": "parameters.fields"
}
},
{
"origin": {
"actionId": "document_batch_update",
"fieldPath": "requestBody.requests"
},
"target": {
"actionId": "batch_update_document_action",
"fieldPath": "requestBody.requests"
}
}
],
"fields": {
"parameters": [
{
"name": "documentId",
"description": "The ID of the Google Document to update.",
"required": true,
"type": "string"
},
{
"name": "fields",
"description": "Optional. Selector specifying which fields to include in a partial response.",
"required": false,
"type": "string"
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"description": "List of update requests to apply to the document. Supported update types include insertText, updateParagraphStyle, createParagraphBullets, deleteContentRange, replaceAllText, and updateTextStyle.",
"properties": {
"requests": {
"type": "array",
"description": "An array of update requests. Each request supports one of the following operations:",
"items": {
"type": "object",
"description": "A single update request that modifies the document.",
"properties": {
"insertText": {
"type": "object",
"description": "Inserts text at a specified location.",
"properties": {
"text": {
"type": "string",
"description": "The text to insert."
},
"location": {
"type": "object",
"description": "The location at which to insert the text.",
"properties": {
"index": {
"type": "integer",
"description": "The zero-based index where to insert the text."
}
},
"required": [
"index"
]
}
},
"required": [
"text",
"location"
]
},
"updateParagraphStyle": {
"type": "object",
"description": "Updates the paragraph style within a specified range.",
"properties": {
"range": {
"type": "object",
"description": "The range of the document to update.",
"properties": {
"startIndex": {
"type": "integer",
"description": "The starting index (inclusive)."
},
"endIndex": {
"type": "integer",
"description": "The ending index (exclusive)."
}
},
"required": [
"startIndex",
"endIndex"
]
},
"paragraphStyle": {
"type": "object",
"description": "The paragraph style to apply.",
"properties": {
"namedStyleType": {
"type": "string",
"description": "The named style type (e.g., HEADING_1, NORMAL_TEXT)."
},
"alignment": {
"type": "string",
"description": "The alignment of the paragraph."
}
},
"required": [
"namedStyleType"
]
},
"fields": {
"type": "string",
"description": "Comma-separated list of fields to update in the paragraph style."
}
},
"required": [
"range",
"paragraphStyle",
"fields"
]
},
"createParagraphBullets": {
"type": "object",
"description": "Creates bullets for paragraphs in the specified range.",
"properties": {
"range": {
"type": "object",
"description": "The range that will contain bullets.",
"properties": {
"startIndex": {
"type": "integer",
"description": "The zero-based start index."
},
"endIndex": {
"type": "integer",
"description": "The zero-based end index."
}
},
"required": [
"startIndex",
"endIndex"
]
},
"bulletPreset": {
"type": "string",
"description": "The bullet preset type (e.g., NUMERIC, BULLET)."
}
},
"required": [
"range",
"bulletPreset"
]
},
"deleteContentRange": {
"type": "object",
"description": "Deletes the content within the specified range.",
"properties": {
"range": {
"type": "object",
"description": "The range from which to delete content.",
"properties": {
"startIndex": {
"type": "integer",
"description": "The starting index (inclusive)."
},
"endIndex": {
"type": "integer",
"description": "The ending index (exclusive)."
}
},
"required": [
"startIndex",
"endIndex"
]
}
},
"required": [
"range"
]
},
"replaceAllText": {
"type": "object",
"description": "Replaces all instances of text matching a given criteria.",
"properties": {
"containsText": {
"type": "object",
"description": "The criteria used to match text.",
"properties": {
"text": {
"type": "string",
"description": "The text pattern to match."
},
"matchCase": {
"type": "boolean",
"description": "Whether the matching should be case sensitive."
}
},
"required": [
"text"
]
},
"replaceText": {
"type": "string",
"description": "The replacement text."
}
},
"required": [
"containsText",
"replaceText"
]
},
"updateTextStyle": {
"type": "object",
"description": "Updates text style for a given range within the document.",
"properties": {
"range": {
"type": "object",
"description": "The range in which to update the text style.",
"properties": {
"startIndex": {
"type": "integer",
"description": "The zero-based start index."
},
"endIndex": {
"type": "integer",
"description": "The zero-based end index."
}
},
"required": [
"startIndex",
"endIndex"
]
},
"textStyle": {
"type": "object",
"description": "The text style to apply.",
"properties": {
"bold": {
"type": "boolean",
"description": "Whether the text should be bold."
},
"italic": {
"type": "boolean",
"description": "Whether the text should be italicized."
}
}
},
"fields": {
"type": "string",
"description": "Comma-separated list of fields to update in the text style."
}
},
"required": [
"range",
"textStyle",
"fields"
]
}
},
"additionalProperties": true
}
},
"writeControl": {
"type": "object",
"description": "Control over the execution of the write requests."
}
},
"required": [
"requests"
]
},
"example": {
"requests": [
{
"insertText": {
"text": "Hello, world!",
"location": {
"index": 1
}
}
}
]
}
}
},
"required": true
},
"responses": {
"success": {
"type": "object",
"description": "Response from the batch update operation, including documentId and update replies.",
"example": {
"documentId": "doc123",
"replies": [
{
"insertText": {
"updatedProperties": {
"text": "Hello, world!"
}
}
}
],
"writeControl": {
"requiredRevisionId": "67890"
}
}
}
}
}
},
{
"id": "document_create_and_get",
"title": "Create and Retrieve Document",
"description": "Creates a new Google Document and immediately retrieves its details. This compound flow is useful for verifying the creation of a document and for chaining subsequent operations. In addition to the new document title, optional parameters for the GET operation (such as suggestionsViewMode and fields) can be provided.",
"actions": [
{
"id": "create_document_action",
"sourceId": "googledocs",
"operationId": "googledocs_create_document"
},
{
"id": "get_document_action",
"sourceId": "googledocs",
"operationId": "googledocs_get_document"
}
],
"links": [
{
"origin": {
"actionId": "document_create_and_get",
"fieldPath": "requestBody.title"
},
"target": {
"actionId": "create_document_action",
"fieldPath": "requestBody.title"
}
},
{
"origin": {
"actionId": "document_create_and_get",
"fieldPath": "responses.success.documentId"
},
"target": {
"actionId": "get_document_action",
"fieldPath": "parameters.documentId"
}
},
{
"origin": {
"actionId": "document_create_and_get",
"fieldPath": "parameters.suggestionsViewMode"
},
"target": {
"actionId": "get_document_action",
"fieldPath": "parameters.suggestionsViewMode"
}
},
{
"origin": {
"actionId": "document_create_and_get",
"fieldPath": "parameters.fields"
},
"target": {
"actionId": "get_document_action",
"fieldPath": "parameters.fields"
}
}
],
"fields": {
"parameters": [
{
"name": "suggestionsViewMode",
"description": "Optional. The view mode for document suggestions.",
"required": false,
"type": "string",
"enum": [
"DEFAULT_FOR_CURRENT_ACCESS",
"SUGGESTIONS_INLINE",
"PREVIEW_SUGGESTIONS_ACCEPTED",
"PREVIEW_WITHOUT_SUGGESTIONS"
]
},
{
"name": "fields",
"description": "Optional. Selector specifying which fields to include in a partial response.",
"required": false,
"type": "string"
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"description": "Provide the title for the new document.",
"properties": {
"title": {
"type": "string",
"description": "Title of the document."
}
},
"required": [
"title"
]
},
"example": {
"title": "Compound Flow Document"
}
}
},
"required": true
},
"responses": {
"success": {
"type": "object",
"description": "Retrieved document details after creation, including documentId, title, and content.",
"example": {
"documentId": "doc456",
"title": "Compound Flow Document",
"body": {
"content": [
{
"paragraph": {
"elements": [
{
"textRun": {
"content": "Compound flow content."
}
}
]
}
}
]
}
}
}
}
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment