webflow.createAssetFolder(name, parentFolderId)

Creates a folder in the Assets panel, which can also be nested within an existing folder for better organization.

Syntax

1createAssetFolder(name: string, parentFolderId?: string): Promise<AssetFolder>

Parameters

  • name: string - The display name of the new folder
  • parentFolderId: string - (optional) - The ID of the desired parent folder. Get existing folder IDs from webflow.getAllAssetFolders()

Returns

Return Value

A Promise resolving to an AssetFolder object.

Example

1// Get All Asset Folders
2 const folders = await webflow.getAllAssetFolders()
3
4 const parentFolderName = "My Parent Folder Name"
5
6 // Find Parent Folder by Name
7 if (parentFolderName && parentFolderName !== '') {
8 const parentFolder = await Promise.all(
9 folders.map(async (folder) => {
10 const folderName = await folder.getName()
11 if (folderName === parentFolderName) {
12 return folder
13 }
14 return null
15 }),
16 ).then((results) => results.find((folder) => folder !== null))
17
18 // Create Asset Folder with parent folder
19 if (parentFolder) {
20 const newFolder = await webflow.createAssetFolder(name, parentFolder.id)
21 console.log(newFolder)
22 }
23 } else {
24 // Crate Asset Folder
25 const newFolder = await webflow.createAssetFolder(name)
26 console.log(newFolder)
27 }

Designer Ability

Designer AbilityLocaleBranchWorkflowSitemode
canManageAssetsAnyAnyAnyAny