Use the create
method to create a new directory or folder.
try {
const name = 'new_directory'; // The name of the directory to create.
const parentDirectoryId = 'parent_directory_id_here'; // The ID of the parent directory or drive.
const [data, error] = await sdk.directory.create({
name,
parentDirectoryId
});
// Check for success
if (error) {
console.error('Failed to create directory: ', error);
} else {
console.log(data);
}
} catch (error) {
console.error(error.message);
}
Params
name
(string): The name of the new directory to create.parentDirectoryId
(string): The ID of the parent directory or a drive where the new directory will be created.
Required API Key Permission
Create Directory