Document
导航和管理 Figma 文档中的页面(画布)。
Type reference
// A Figma document contains pages — each page is an independent canvas with its own node tree.// The "current page" is where all node operations happen. Use document.set to switch pages before working with nodes.// Page IDs look like "0:1", "1:1", etc. The first page is always "0:1".// get returns the current page with its top-level children as stubs. list returns all pages in the document.5 methods available.
Get current page with top-level children
No parameters.
Response
| Field | Type | Description |
|---|---|---|
id | string | |
name | string | |
backgroundColor | string | Canvas background hex color (e.g. "#F5F5F5") |
children | array |
Get document name and list all pages
No parameters.
Response
| Field | Type | Description |
|---|---|---|
name | string | Document name |
currentPageId | string | |
pages | object[] | |
↳ id | string | |
↳ name | string |
Switch to a page by ID or name. At least one of pageId or pageName must be provided.
| Parameter | Type | Required | Description |
|---|---|---|---|
pageId | string | ✗ | Page ID |
pageName | string | ✗ | Page name (case-insensitive, substring match) |
Response
| Field | Type | Description |
|---|---|---|
id | string | |
name | string |
create
Section titled “create”Create a new page
| Parameter | Type | Required | Description |
|---|---|---|---|
name | string | ✗ | Page name (default: 'New Page') |
Response
| Field | Type | Description |
|---|---|---|
id | string | New page ID |
update
Section titled “update”Rename a page
| Parameter | Type | Required | Description |
|---|---|---|---|
newName | string | ✓ | New page name |
pageId | string | ✗ | Page ID (default: current page) |
Response
| Field | Type | Description |
|---|---|---|
result | string | String result |