Mirra
IntegrationsGoogle

Google Docs

SDK reference for google docs operations

Overview

Google Docs document creation and editing

  • Category: productivity
  • Auth Required: Yes
  • Supported Modes: standard, delegated

Operations

createDocument

Create a new Google Doc

Arguments:

  • title (string, required): Title of the document

Returns:

AdapterOperationResult - Created document with documentId and title

Response Fields:

FieldTypeDescription
documentIdstringID of the created document
titlestringTitle of the created document

Example:

const result = await mirra.googleDocs.createDocument({
  title: "example"
});

getDocument

Get a Google Doc by ID. Returns normalized flat structure with extracted fields.

Arguments:

  • documentId (string, required): ID of the document

Returns:

AdapterOperationResult - Normalized document with documentId, title, body, url, hasContent fields

Response Fields:

FieldTypeDescription
documentIdstringID of the document
titlestringTitle of the document
revisionIdstringCurrent revision ID
bodystringPlain text content of the document
bodyLengthnumberCharacter count of the body
lastEditedTimestringISO 8601 timestamp of last edit (optional)
urlstringURL to the document
hasContentbooleanWhether document has any text content

Example:

const result = await mirra.googleDocs.getDocument({
  documentId: "abc123"
});

appendText

Append text to the end of a document

Arguments:

  • documentId (string, required): ID of the document
  • text (string, required): Text to append

Returns:

AdapterOperationResult - Append operation result

Response Fields:

FieldTypeDescription
documentIdstringID of the document
successbooleanWhether the operation succeeded
feedbackstringHuman-readable feedback about the operation

Example:

const result = await mirra.googleDocs.appendText({
  documentId: "abc123",
  text: "example"
});

replaceText

Replace text in a document

Arguments:

  • documentId (string, required): ID of the document
  • searchText (string, required): Text to search for
  • replaceText (string, required): Text to replace with

Returns:

AdapterOperationResult - Replace operation result

Response Fields:

FieldTypeDescription
documentIdstringID of the document
successbooleanWhether the operation succeeded
feedbackstringHuman-readable feedback about the operation

Example:

const result = await mirra.googleDocs.replaceText({
  documentId: "abc123",
  searchText: "example",
  replaceText: "example"
});

getDocumentContent

Get the text content of a Google Doc

Arguments:

  • documentId (string, required): ID of the document

Returns:

AdapterOperationResult - Document text content

Response Fields:

FieldTypeDescription
documentIdstringID of the document
contentstringPlain text content of the document

Example:

const result = await mirra.googleDocs.getDocumentContent({
  documentId: "abc123"
});

insertTextAtPosition

Insert text at a specific position in the document

Arguments:

  • documentId (string, required): ID of the document
  • text (string, required): Text to insert
  • position (number, required): Character position to insert at (1-indexed)

Returns:

AdapterOperationResult - Insert operation result

Response Fields:

FieldTypeDescription
documentIdstringID of the document
successbooleanWhether the operation succeeded
feedbackstringHuman-readable feedback about the operation

Example:

const result = await mirra.googleDocs.insertTextAtPosition({
  documentId: "abc123",
  text: "example",
  position: 10
});

insertTextAfter

Insert text after a search string in the document

Arguments:

  • documentId (string, required): ID of the document
  • searchText (string, required): Text to search for
  • textToInsert (string, required): Text to insert after the search text
  • occurrence (number, optional): Which occurrence to insert after (default: 1)

Returns:

AdapterOperationResult - Insert operation result

Response Fields:

FieldTypeDescription
documentIdstringID of the document
successbooleanWhether the operation succeeded
feedbackstringHuman-readable feedback about the operation

Example:

const result = await mirra.googleDocs.insertTextAfter({
  documentId: "abc123",
  searchText: "example",
  textToInsert: "example"
});

insertHeading

Insert a heading into the document

Arguments:

  • documentId (string, required): ID of the document
  • text (string, required): Heading text
  • level (number, required): Heading level (1-6)
  • position (number, optional): Character position to insert at
  • insertAfterText (string, optional): Insert after this text instead of at position

Returns:

AdapterOperationResult - Insert operation result

Response Fields:

FieldTypeDescription
documentIdstringID of the document
successbooleanWhether the operation succeeded
feedbackstringHuman-readable feedback about the operation

Example:

const result = await mirra.googleDocs.insertHeading({
  documentId: "abc123",
  text: "example",
  level: 10
});

insertList

Insert a bulleted or numbered list into the document

Arguments:

  • documentId (string, required): ID of the document
  • items (array, required): Array of list items
  • listType (string, required): Type of list: "bulleted" or "numbered"
  • position (number, optional): Character position to insert at
  • insertAfterText (string, optional): Insert after this text instead of at position

Returns:

AdapterOperationResult - Insert operation result

Response Fields:

FieldTypeDescription
documentIdstringID of the document
successbooleanWhether the operation succeeded
feedbackstringHuman-readable feedback about the operation

Example:

const result = await mirra.googleDocs.insertList({
  documentId: "abc123",
  items: [],
  listType: "example"
});

insertTable

Insert a table into the document

Arguments:

  • documentId (string, required): ID of the document
  • data (array, required): 2D array of table data (rows x columns)
  • hasHeader (boolean, optional): Whether the first row is a header (default: true)
  • position (number, optional): Character position to insert at
  • insertAfterText (string, optional): Insert after this text instead of at position

Returns:

AdapterOperationResult - Insert operation result

Response Fields:

FieldTypeDescription
documentIdstringID of the document
successbooleanWhether the operation succeeded
feedbackstringHuman-readable feedback about the operation

Example:

const result = await mirra.googleDocs.insertTable({
  documentId: "abc123",
  data: []
});

updateDocumentContent

Replace the entire content of a document

Arguments:

  • documentId (string, required): ID of the document
  • newContent (string, required): New content to replace existing content

Returns:

AdapterOperationResult - Update operation result

Response Fields:

FieldTypeDescription
documentIdstringID of the document
successbooleanWhether the operation succeeded
feedbackstringHuman-readable feedback about the operation

Example:

const result = await mirra.googleDocs.updateDocumentContent({
  documentId: "abc123",
  newContent: "example"
});

createSection

Create a new section with a heading and content. Returns normalized result with insertion details.

Arguments:

  • documentId (string, required): ID of the document
  • heading (string, required): Section heading text
  • content (string, required): Section content text

Returns:

AdapterOperationResult - Normalized section result with documentId, title, url, heading, insertionIndex, success

Response Fields:

FieldTypeDescription
documentIdstringID of the document
titlestringTitle of the document
urlstringURL to the document
headingstringThe heading text that was created
insertionIndexnumberCharacter position where section was inserted
successbooleanWhether the operation succeeded

Example:

const result = await mirra.googleDocs.createSection({
  documentId: "abc123",
  heading: "example",
  content: "example"
});

findInsertionPoint

Find the character position for insertion based on position or search text. Returns normalized result with position and context.

Arguments:

  • documentId (string, required): ID of the document
  • position (number, required): Position to find (1 for start, -1 for end)
  • searchText (string, optional): Text to search for (returns position after this text)

Returns:

AdapterOperationResult - Normalized insertion point with documentId, title, url, position, context, documentLength

Response Fields:

FieldTypeDescription
documentIdstringID of the document
titlestringTitle of the document
urlstringURL to the document
positionnumberCharacter position for insertion
contextstringText context around the insertion point
documentLengthnumberTotal character length of the document

Example:

const result = await mirra.googleDocs.findInsertionPoint({
  documentId: "abc123",
  position: 10
});

On this page