2

My company's slides suite has a master template that we use for all of our decks. I am building a script to automatically create Slides and populate them with some csv info. I have managed to create and populate the slides, and I can access ObjectId of some layouts in the master template if I append slides into an existent presentation, however, I want to create a presentation from scratch and use the layouts from our master template.

The problem is that I have no idea how to obtain the master template's ID to specify the master to be used when creating the presentation. I checked the docs for the slides API and I couldn't find anything telling you how to get it, only telling you that it exists, and I tried by getting the last portion of the URL when clicking on the "master layout" slide in the master template editor in the website, but the API call doesn't recognize it as a valid ID, or it just doesn't return anything so no master is set up.

The docs on the create method

1 Answers1

2

The easiest way to obtain a Google Slide (or any Google document) Id is to open the respective document and inspect the Url in the address bar

It should look like this:

enter image description here

The part marked with XXX in the image, so the part between https://docs.google.com/presentation/d/ and /edit#slide=id.p is the presentationId.


A possibility to retrieve the presentationId propgrammatically would be e.g. to use the Drive API method list and specify as the quer paramater q e.g. the file name, mimeTypr and / or other paramters that would allow you to identify the presentaiton.

ziganotschka
  • 25,866
  • 2
  • 16
  • 33
  • Hello. This doesn't seem to be an answer to my question, unless the master template is a presentation object in itself and thus its presentationId IS the master ID. To clarify: I need to get the master's ID. Master template is the template that allows you to choose from your own personal set of custom layouts for each slide. –  Jul 05 '20 at 06:38
  • A master template is a presentation. Do you want to make a new presentation entirely based on the template? In this case you should use the Drive API method [Files: copy](https://developers.google.com/drive/api/v3/reference/files/copy) using the presentaitonId of the template presentation as `fileId`. – ziganotschka Jul 06 '20 at 08:26
  • perhaps I am misunderstanding what a master is. My goal here is to create a new presentation via an api call, and for this new presentation to have the custom layouts that we use in all of our presentations, which include our background images, color palettes and logos and such. –  Jul 07 '20 at 18:13
  • I am not sure if this will solve your issue and allow you to import a custom theme as done [here](https://support.google.com/a/users/answer/9308838?hl=en), but if the only thing you need to know is how to obtain the masterObjectId - you can do it with the request [presentations.get](https://developers.google.com/slides/reference/rest/v1/presentations/get) setting `fields` to `masters/objectId`. – ziganotschka Jul 08 '20 at 08:08