The Canva Apps SDK, Connect APIs, and MCP are now unified in the Canva Developers SDK. Learn more(opens in a new tab or window).
Canva Developers SDK
The Canva Apps SDK, Connect APIs, and MCP are now unified in the Canva Developers SDK. Learn more(opens in a new tab or window).
API reference
Intents
Intents: Asset
Intents: Content
Intents: Design
Intents: Test
Platform: Test

duplicatePage

API reference for the duplicatePage 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.

Duplicates a page.

Usage

Duplicate a page by ID

import { duplicatePage, getCurrentPageMetadata } from "@canva/design";
const currentPage = await getCurrentPageMetadata();
if (currentPage.type !== 'absolute' || currentPage.id == null) {
throw new Error('Current page does not have an ID');
}
const pageMetadata = await duplicatePage({
sourcePageId: currentPage.id,
mode: 'after_source',
});
TYPESCRIPT

Insert the duplicated page after another page

import { addPage, duplicatePage, getCurrentPageMetadata } from "@canva/design";
const currentPage = await getCurrentPageMetadata();
if (currentPage.type !== 'absolute' || currentPage.id == null) {
throw new Error('Current page does not have an ID');
}
const insertAfterPage = await addPage();
if (insertAfterPage.type !== 'absolute' || insertAfterPage.id == null) {
throw new Error('Inserted page does not have an ID');
}
const pageMetadata = await duplicatePage({
sourcePageId: currentPage.id,
targetPageId: insertAfterPage.id,
mode: 'after_target',
});
TYPESCRIPT

Insert the duplicated page at the start of the design

import { duplicatePage, getCurrentPageMetadata } from "@canva/design";
const currentPage = await getCurrentPageMetadata();
if (currentPage.type !== 'absolute' || currentPage.id == null) {
throw new Error('Current page does not have an ID');
}
const pageMetadata = await duplicatePage({
sourcePageId: currentPage.id,
mode: 'before_first_page',
});
TYPESCRIPT

Insert the duplicated page before the source page

import { duplicatePage, getCurrentPageMetadata } from "@canva/design";
const currentPage = await getCurrentPageMetadata();
if (currentPage.type !== 'absolute' || currentPage.id == null) {
throw new Error('Current page does not have an ID');
}
const pageMetadata = await duplicatePage({
sourcePageId: currentPage.id,
mode: 'before_source',
});
TYPESCRIPT

Insert the duplicated page at the end of the design

import { duplicatePage, getCurrentPageMetadata } from "@canva/design";
const currentPage = await getCurrentPageMetadata();
if (currentPage.type !== 'absolute' || currentPage.id == null) {
throw new Error('Current page does not have an ID');
}
const pageMetadata = await duplicatePage({
sourcePageId: currentPage.id,
mode: 'after_last_page',
});
TYPESCRIPT

Parameters

optsDuplicatePageOptions
Required

Options for duplicating the page.

Options for inserting a page adjacent to the source page.

modestring
Required

The type of insertion.

Available values:

  • "before_source"
  • "after_source"
sourcePageIdPageId
Required

The ID of the page to duplicate.

Options for inserting a page at the start or end of the design.

modestring
Required

The type of insertion.

Available values:

  • "before_first_page"
  • "after_last_page"
sourcePageIdPageId
Required

The ID of the page to duplicate.

Options for inserting a page adjacent to a target page.

modestring
Required

The type of insertion.

Available values:

  • "before_target"
  • "after_target"
targetPageIdPageId
Required

The ID of the page to insert the new page adjacent to.

sourcePageIdPageId
Required

The ID of the page to duplicate.

Returns

The metadata of the duplicated page. This is a Promise that resolves with the following object:

Information about a page within a design with fixed or unbounded dimensions.

typestring

The type of page.

The only valid value is "absolute".

idPageId
Optional

Stable identifier for this page within the design.

dimensionsPageDimensions
Optional

The dimensions of the page, in pixels.

This may be undefined because some types of pages don't have dimensions, such as whiteboards.

widthnumber

The width of the page, in pixels.

heightnumber

The height of the page, in pixels.

titlestring
Optional

The name of the page.

This is optional and will be empty if the user hasn't set a title.

Pages that do not have fixed or unbounded dimensions currently do not return metadata.

typestring

The type of page.

The only valid value is "unsupported".