applyTemplate

API reference for the applyTemplate method.

This API is a preview. Preview APIs are unstable and may change without warning. You can't release public apps using this API until it's stable.

Apply a template to the current design given a template id.

Usage: Apply a template to the current design

import {
applyTemplate,
requestBrandTemplates,
type BrandTemplateId,
} from "@canva/design";
const selection = await requestBrandTemplates();
if (selection.status === "aborted") return;
const templateId = selection.brandTemplates[0]?.token as BrandTemplateId | undefined;
if (!templateId) return;
const result = await applyTemplate({
template: { id: templateId },
mode: "overwrite",
});
if (result.status === "completed") {
// Template was successfully applied
}
TYPESCRIPT

Parameters

optionsApplyTemplateOptions
Required

Options for applying a template to a design.

templateobject
Required
idBrandTemplateId
Required

A unique identifier that references a brand template.

modestring
Required

The only valid value is "overwrite".

Returns

Response object from the ApplyTemplate operation. This is a Promise that resolves with the following object:

statusstring

Available values:

  • "completed"
  • "aborted"