title: How to get a Google sheet ID which doesn’t exist yet?
body: <p>I have a Google Worksheet with which I'm doing pivot tables.
  I would like to add pivot tables(14) in new sheets that don’t exist yet (One pivot table by sheet), on the same spreadsheet.
  Currently I'm creating new sheets and recovering their IDs by hand. I wish it was automatic.
  Here my pivot table :</p>
  <pre><code>    request_body = {
          &quot;requests&quot; : [
              {
                  &quot;addSheet&quot;: {
                      'properties': {
                          'title': 'test',
                          'tabColor' : {
                              'red' : 0.44,
                              'green' : 0.99,
                              'blue' : 0.50
                          },
                      }
                  },
              }
          ],
          &quot;sheets&quot;:[{
              'data': [{
                  &quot;rowData&quot; : {
                      &quot;values&quot; : [
                          {
                              &quot;pivotTable&quot; : {
                                  #Data Source
                                  &quot;source&quot; : {
                                      &quot;sheetId&quot;: &quot;0&quot;,
                                      &quot;startRowIndex&quot; : 0,
                                      &quot;startColumnIndex&quot; : 0,
                                  },
                                  #Row Field(s)
                                  &quot;rows&quot; : [ 
                                      #field 2
                                      {
                                          &quot;sourceColumnOffset&quot; : 5, #Type Preneur
                                          &quot;showTotals&quot; : False,
                                          &quot;sortOrder&quot; : &quot;ASCENDING&quot;
                                      },
                                      #field 3
                                      {
                                          &quot;sourceColumnOffset&quot; : 3, #Enseigne
                                          &quot;showTotals&quot; : False,
                                          &quot;sortOrder&quot; : &quot;ASCENDING&quot;
                                      }
                                  ],
                                  #Columns Field(s)
                                  &quot;columns&quot; : [
                                      #Field 1
                                      {
                                          &quot;sourceColumnOffset&quot; : 6, #Nature impayés
                                          &quot;sortOrder&quot; : &quot;ASCENDING&quot;, 
                                          &quot;showTotals&quot; : False
                                      },
                                      #Field 2
                                      {
                                          &quot;sourceColumnOffset&quot; : 18, #Année
                                          &quot;sortOrder&quot; : &quot;ASCENDING&quot;,
                                          &quot;showTotals&quot; : True
                                      },
                                      #Field 3
                                      {
                                          &quot;sourceColumnOffset&quot; : 19, #Item - Entry Type
                                          &quot;sortOrder&quot; : &quot;ASCENDING&quot;,
                                          &quot;showTotals&quot; : False  
                                      }
                                  ],
                                  &quot;criteria&quot; : {
                                      6:{
                                          'visibleValues' : ['Solde Créditeur']
                                      },
                                      19:{
                                          'visibleValues' : [
                                              'DEPRD', 'DEPRE', 'ECHEA', 'FACTU'
                                          ]
                                      },
                                      5: {
                                          'visibleValues' : [
                                              &quot;Inconnu&quot;, &quot;Indépendant&quot;,&quot;Antenne / Wifi&quot;, &quot;SL&quot;, &quot;Franchisé&quot;, &quot;Ephémère&quot;, &quot;Copro&quot;, &quot;Carrefour&quot;, &quot;-&quot;
                                          ]
                                      },
                                  },                                        
                                  #Values Field(s)
                                  &quot;values&quot; : [
                                      {
                                          &quot;sourceColumnOffset&quot; : 21, #PNS BRUT PPSO
                                          &quot;summarizeFunction&quot; : &quot;SUM&quot;,
                                          &quot;name&quot; : &quot;&quot;
                                      }
                                  ],
                                  &quot;valueLayout&quot; : &quot;HORIZONTAL&quot;
                              }
                          }
                      ],
                      'dataSourceId' : id_fichier
                  },
                  'fields' : 'pivotTable'
              }]
          }]
      }
  
      #Ecriture du 1er TCD
      response = service_sheet.spreadsheets().batchUpdate(
          spreadsheetId = Id_fichier_source,
          body = request_body
      ).execute()
  </code></pre>
  <p>Do you have any ideas ?</p>