> ## Documentation Index
> Fetch the complete documentation index at: https://www.canva.dev/docs/apps/llms.txt
> Use this file to discover all available pages before exploring further.
# duplicatePage
API reference for the duplicatePage method.
NOTE: **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
```typescript
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',
});
```
### Insert the duplicated page after another page
```typescript
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',
});
```
### Insert the duplicated page at the start of the design
```typescript
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',
});
```
### Insert the duplicated page before the source page
```typescript
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',
});
```
### Insert the duplicated page at the end of the design
```typescript
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',
});
```
## Parameters
Options for duplicating the page.
}>
Options for inserting a page adjacent to the source page.
The type of insertion.
**Available values**:
* `"before_source"`
* `"after_source"`
The ID of the page to duplicate.
}>
Options for inserting a page at the start or end of the design.
The type of insertion.
**Available values**:
* `"before_first_page"`
* `"after_last_page"`
The ID of the page to duplicate.
}>
Options for inserting a page adjacent to a target page.
The type of insertion.
**Available values**:
* `"before_target"`
* `"after_target"`
The ID of the page to insert the new page adjacent to.
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.
The type of page.
The only valid value is `"absolute"`.
Stable identifier for this page within the design.
The dimensions of the page, in pixels.
This may be `undefined` because some types of pages don't have dimensions, such as whiteboards.
Properties of dimensions>}>
The width of the page, in pixels.
The height of the page, in pixels.
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.
The type of page.
The only valid value is `"unsupported"`.
## Permissions
To use this method, the `canva:design:content:write` permission must be enabled for the app. To learn more, see [Permissions](https://www.canva.dev/docs/apps/configuring-intents-permissions/).
## Rate limit
This method has a rate limit of 10 requests every 10 seconds.