layouts.createSlide() to stamp out a fully-populated slide by filling each slot by name. This two-phase approach keeps your design consistent across a deck while letting you swap content programmatically.
How layouts work
Layouts live inside a layout container, identified by alayoutId. Every deck has its own layout container (accessible via deck.layoutId after creation), so layouts you define for one deck stay scoped to that deck.
When you create a layout with layouts.create(), you define:
- Static layers — content that appears on every slide stamped from this layout (a header bar, a company logo, a footer).
- Placeholder layers — layers tagged with a
placeholdername. When you calllayouts.createSlide(), you supply afillmap that replaces each placeholder with real content.
The
layoutId you pass to layouts.create() is the container id — it comes from the deck’s layoutId field. It is not the layout’s own id (which is returned from layouts.create()).PlaceholderSpec
Every layer in a layout can carry aplaceholder field. Pass a bare string for a simple name, or a full PlaceholderSpec object to add a visible hint and an explicit type:
type drives render-family selection and master inheritance. If you omit it, the SDK infers it from the layer’s content type (a text layer becomes 'body', a bar layer becomes 'chart', an image layer becomes 'image').
Master layouts
Settingmaster: true on a layout makes it the master for its container. Every other layout in the same container automatically inherits the master’s layers. Master inheritance deduplicates by placeholder type, so a layout’s own title placeholder overrides the master’s title without duplicating it.
Complete walkthrough
Create the deck
You need a deck before you can create a layout, because the layout’s container id comes from the deck.
Retrieve the deck to get its layoutId
The
DeckResource returned by decks.create() includes a layoutId field (which may be null for a brand-new deck before the server provisions the container). A retrieve() call returns the authoritative record after it has been provisioned.Create a layout template with placeholder slots
Define the template layers. Each layer that should be filled at instantiation time gets a The returned
placeholder name.LayoutResource includes a placeholders map keyed by name — you will use this object directly in the next step.Reusing a layout across multiple slides
Once you have aLayoutResource in hand, you can stamp out as many slides as you need. Each call to layouts.createSlide() is independent — a failure on one slide does not affect the others.