> ## Documentation Index
> Fetch the complete documentation index at: https://docs.r28.ai/charter/llms.txt
> Use this file to discover all available pages before exploring further.

# documents_batch_update

> Apply a list of edits to a document. Each request sets exactly one kind of edit — insert_text, replace_all_text, update_text_style, insert_table and so on. Edits apply in order against a document that shifts as they do: when inserting at several indices, order the requests back-to-front so earlier insertions do not move the positions later ones refer to.

<div className="tool-route"><span className="tool-row-method" data-method="POST">POST</span><code>{"https://docs.googleapis.com/v1/documents/{documentId}:batchUpdate"}</code></div>

```python gdocs_documents_batch_update.py theme={null}
from charter.packs import gdocs

result = await gdocs.documents_batch_update.ainvoke({"documentId": ..., "body": ...})
```

<Note>
  Requires `https://www.googleapis.com/auth/documents`. Costs 1 against the provider's own quota.
</Note>

<Warning>
  This tool's JSON schema is 32 KB, because `body.requests` carries 33 kinds of edit behind one method.
  That is more context than most tasks. Narrow it at the call site
  with [`Tool.derived`](/charter/charter/reference/tool#tool-derived):

  ```python theme={null}
  narrowed = gdocs.documents_batch_update.derived(
      name="documents_batch_update_narrowed",
      keep={"replace_all_text", "insert_text", "update_text_style"},
  )
  ```

  Three of the 33 are kept here. Which ones your agent needs is yours to pick. The tool underneath is unchanged.
  See [Projections](/charter/charter/tools/projections).
</Warning>

## Path parameters

<div className="reference-table">
  | Field                                                              | Type     | Description                       |
  | ------------------------------------------------------------------ | -------- | --------------------------------- |
  | `documentId` <span className="required" title="required">\*</span> | `string` | The ID of the document to update. |
</div>

## Body

<div className="reference-table">
  | Field                                                        | Type                                                            | Description         |
  | ------------------------------------------------------------ | --------------------------------------------------------------- | ------------------- |
  | `body` <span className="required" title="required">\*</span> | [BatchUpdateBody](/charter/charter/packs/gdocs/objects#batchupdatebody) | The edits to apply. |
</div>
