---
title: Create a folder
summary: Create a folder node under a parent, or get the existing one, in every SDK and over HTTP.
order: 40
languages: [javascript, java, csharp, php]
terms: [node]
see-also: [how-to/models/list-the-tree, how-to/models/upload-a-model, how-to/models/delete-and-restore-a-node, explanation/nodes-versions-and-the-tree]
---

# Create a folder

For an integration that organises its uploads: one folder per project, per user or per import run. A folder is a [[term:node|node]] like any other; the API tokens and delegated tokens you create later are rooted at folders, so the folder layout is also your permission layout.

## Before you start

- A login with the `fs:write` scope and write rights on the parent ([[page:how-to/auth/log-in-with-an-api-token]]).
- The parent's UUID ([[page:how-to/models/list-the-tree]]).

## 1. Create the folder

```code-group {#create} classic
```javascript
const folderUuid = await client.fs.createNode(parentUuid, "Project A", true);
```
```java
UUID folderUuid = client.fs.createNode(parentUuid, "Project A", true);
```
```csharp
Guid folderUuid = client.Fs.CreateNode(parentUuid, "Project A", true, InputFileType.FOLDER);
```
```

```sdk-example
operation: CreateNode
body: |
  {
    "name": "Project A",
    "folder": true,
    "parent_node_uuid": "<parent uuid>"
  }
```

The SDK methods return the new node's UUID: `createNode` on [[js:@bimworks/jssdk/Fs|Fs]] and [[java:nl.bimbase.bimworks.client.apis.FileSystemApi|FileSystemApi]], `CreateNode` on [[dotnet:BIM.works_SDK.Fs|Fs]]; the PHP `FsApi::createNode` ([[page:reference/sdk/php]]) and the HTTP operation [[openapi:CreateNode]] return the whole node:

```try-it
operation: CreateNode
method: POST
path: /openapi/fs/CreateNode
body: |
  {
    "name": "Project A",
    "folder": true,
    "parent_node_uuid": "<parent uuid>"
  }
```

Without `parent_node_uuid` the folder is created in the root node of the credential. A name that already exists in the parent fails with [[error:NODE_ALREADY_EXISTS]]; a name that is not a valid path segment with [[error:INVALID_PATH]].

## 2. Or create it only when it is missing

Import runs that create the same folders every time use the idempotent variant: it returns the UUID of the existing node when the name is taken.

```code-group {#if-missing} classic
```javascript
const folderUuid = await client.fs.createNodeIfNotExists(parentUuid, "Project A", true);
```
```java
UUID folderUuid = client.fs.createNodeIfNotExists(parentUuid, "Project A", true, null);
```
```csharp
Guid folderUuid = client.Fs.CreateNodeIfNotExists(parentUuid, "Project A", true, InputFileType.FOLDER);
```
```

```sdk-example
operation: CreateNode
body: |
  {
    "name": "Project A",
    "folder": true,
    "parent_node_uuid": "<parent folder uuid>",
    "allow_existing": true
  }
```

Over HTTP, `allow_existing: true` on [[openapi:CreateNode]] does the same.

## Check

`getNodeByPath` on the parent's path plus the new name returns a node whose `folder` is true and whose `uuid` is the one you got back ([[page:how-to/models/list-the-tree]]). Creating the same name again fails with [[error:NODE_ALREADY_EXISTS]], unless you used the if-missing variant, which returns the same UUID.
