Box Developer Documentation

Join BoxWorks 2024 to discover what's possible with content and AI!

Register now!

Create Folder

Create Folder

To create a folder in Box you will need to provide our API with a name for the new folder, as well as the id of the parent folder that you would like to create the new folder within.

cURL
curl -i -X POST "https://api.box.com/2.0/folders" \
     -H "authorization: Bearer <ACCESS_TOKEN>" \
     -H "content-type: application/json" \
     -d '{
       "name": "New Folder",
       "parent": {
         "id": "0"
       }
     }'
TypeScript Gen
await parentClient.folders.createFolder({
  name: getUuid(),
  parent: { id: '0' } satisfies CreateFolderRequestBodyParentField,
} satisfies CreateFolderRequestBody);
Python Gen
parent_client.folders.create_folder(get_uuid(), CreateFolderParent(id="0"))
.NET Gen
await parentClient.Folders.CreateFolderAsync(requestBody: new CreateFolderRequestBody(name: Utils.GetUUID(), parent: new CreateFolderRequestBodyParentField(id: "0")));
Swift Gen (Beta)
try await parentClient.folders.createFolder(requestBody: CreateFolderRequestBody(name: Utils.getUUID(), parent: CreateFolderRequestBodyParentField(id: "0")))
Java
BoxFolder parentFolder = new BoxFolder(api, "id");
BoxFolder.Info childFolderInfo = parentFolder.createFolder("Child Folder Name");
Python
subfolder = client.folder('0').create_subfolder('My Stuff')
print(f'Created subfolder with ID {subfolder.id}')
.NET
// Create a new folder in the user's root folder
var folderParams = new BoxFolderRequest()
{
    Name = "New folder",
    Parent = new BoxRequestEntity()
    {
        Id = "0"
    }
};
BoxFolder folder = await client.FoldersManager.CreateAsync(folderParams);
Node
client.folders.create('0', 'New Folder')
    .then(folder => {
        /* folder -> {
            type: 'folder',
            id: '123456',
            sequence_id: '0',
            etag: '0',
            name: 'New Folder',
            created_at: '2012-12-12T10:53:43-08:00',
            modified_at: '2012-12-12T11:15:04-08:00',
            description: '',
            size: 0,
            path_collection: 
            { total_count: 1,
                entries: 
                [ { type: 'folder',
                    id: '0',
                    sequence_id: null,
                    etag: null,
                    name: 'All Files' } ] },
            created_by: 
            { type: 'user',
                id: '22222',
                name: 'Example User'
                login: 'user@example.com' },
            modified_by: 
            { type: 'user',
                id: '22222',
                name: 'Example User',
                login: 'user@example.com' },
            owned_by: 
            { type: 'user',
                id: '22222',
                name: 'Example User',
                login: 'user@example.com' },
            shared_link: null,
            parent: 
            { type: 'folder',
                id: '0',
                sequence_id: null,
                etag: null,
                name: 'All Files' },
            item_status: 'active',
            item_collection: 
            { total_count: 0,
                entries: [],
                offset: 0,
                limit: 100 } }
        */
    });
iOS
client.folders.create(name: "New Folder", parentId: "22222") { (result: Result<Folder, BoxSDKError>) in
    guard case let .success(folder) = result else {
        print("Error creating folder")
        return
    }

    print("Created folder \"\(folder.name)\" inside of folder \"\(folder.parent?.name)\"")
}

Name restrictions

There are some restrictions to the folder name. Names containing non-printable ASCII characters, forward and backward slashes (/, \), as well as names with trailing spaces are prohibited.

Additionally, the names . and .. are reserved names and therefore also prohibited.