title: google docs api delete all content
body: <p>I noticed from the <a href="https://developers.google.com/docs/api/reference/rest/v1/documents/batchUpdate?apix_params=%7B%22documentId%22%3A%221ys6KIY1XOhPHrgQBJ4XxR1WDl0etZdmR9R48h2sP2cc%22%2C%22resource%22%3A%7B%22requests%22%3A%5B%7B%22deleteContentRange%22%3A%7B%22range%22%3A%7B%22startIndex%22%3A1%2C%22endIndex%22%3A80%7D%7D%7D%5D%7D%7D" rel="nofollow noreferrer">google docs API</a></p>
  
  <p>I can do</p>
  
  <pre><code>{
    "requests": [
      {
        "deleteContentRange": {
          "range": {
            "startIndex": 1,
            "endIndex": 80
          }
        }
      }
    ]
  }
  </code></pre>
  
  <p>but if the endindex is greater than the total length of characters in the document, I get the following error:</p>
  
  <pre><code>{
    "error": {
      "code": 400,
      "message": "Invalid requests[0].deleteContentRange: Index 79 must be less than the end index of the referenced segment, 7.",
      "status": "INVALID_ARGUMENT"
    }
  }
  </code></pre>
  
  <p>but I just want to delete all of the content, even though I don't know the end range value.</p>
  
  <p>So: is it possible to get the endIndex somehow, or delete all content another way?</p>