# IRPCViews.CreateSubFolder

Location: [gRPC API](https://developer.m-files.com/APIs/gRPC-API/index.md) > [Vault API](https://developer.m-files.com/APIs/gRPC-API/vault/index.md) > [Views](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCViews/index.md)

HTML version: https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCViews/CreateSubFolder/

Badges: `Vault API / standard` `write` `session or assertion` `returns metadata structure version`

Creates a traditional folder at a location inside a view, or returns an existing folder with
the same name there.

- **Service:** [Views](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCViews/index.md) `MFiles.IRPCViews`
- **gRPC method:** `/MFiles.IRPCViews/CreateSubFolder`
- **HTTP (mf-http-grpc):** `POST /grpc/v1/create-sub-folder`
- **Request:** [`CreateSubFolderRequest`](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCViews/CreateSubFolder/index.md#request)
- **Response:** [`CreateSubFolderResponse`](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCViews/CreateSubFolder/index.md#response)
- **Book and level:** Vault API, standard
- **Kind:** write
- **Session:** Required: a session (mfiles-session-id-bin metadata) or a session assertion (x-mf-session-assertion metadata).
- **Idempotent:** no
- **Returns metadata structure version:** yes (in the mfiles-metadata-version-bin trailer)
- **Streaming:** none (unary)

<a id="remarks"></a>

## Remarks

- `view_location.parent_folder` must not be empty, and `subfolder` must not have a parent
  folder; otherwise the call fails with "The parameter is incorrect.".
- Only works at locations that allow traditional folders; elsewhere it fails with "Sorry, but
  it's not possible to create traditional folders here.".
- If a folder with the same name exists at the location, it is returned instead of a new one.
- Related: [CreateOrFindTraditionalFolder](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCValueLists/CreateOrFindTraditionalFolder/index.md)
  creates folders outside view locations.

<a id="request"></a>

## Request: CreateSubFolderRequest

Requests to create a sub-folder.

> Nested message fields are expanded to depth 3; follow a type link for deeper levels and for the type's own page.

| Field | Type | Description |
|---|---|---|
| `view_location` | [`ViewLocation`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.ViewLocation/index.md) | The location in the view: `parent_folder` starts with the view folder. |
| `view_location.parent_folder[]` | repeated [`Folder`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.Folder/index.md) | Array of folders describing the parent folder of the view. The first element of the array must be a view folder. Other elements, if any, are property folders. |
| `view_location.parent_folder[].type` | [`FolderType`](https://developer.m-files.com/APIs/gRPC-API/Reference/Enums/MFiles.FolderType/index.md) | The type of the folder, for example `FOLDER_TYPE_VIEW_FOLDER` or `FOLDER_TYPE_PROPERTY_FOLDER`. Values: `FOLDER_TYPE_UNKNOWN` (0), `FOLDER_TYPE_ANY_FOLDER` (1), `FOLDER_TYPE_VIEW_FOLDER` (2), `FOLDER_TYPE_PROPERTY_FOLDER` (3), `FOLDER_TYPE_TRADITIONAL_FOLDER` (4), `FOLDER_TYPE_SEARCH_FOLDER` (5), `FOLDER_TYPE_EXTERNAL_VIEW_FOLDER` (6). |
| `view_location.parent_folder[].data` | [`FolderInfoUnion`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.FolderInfoUnion/index.md) | Additional folder type -specific information as a union. |
| `view_location.customizes_property_folder` | `bool` | True if the view is overlapping with a property folder. |
| `view_location.customized_property_folder` | [`TypedValue`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.TypedValue/index.md) | The overlapped property folder. Ignored if bOverlapping is false. |
| `view_location.customized_property_folder.is_null_value` | `bool` | True if the value is empty. `data` is then unset. |
| `view_location.customized_property_folder.type` | [`Datatype`](https://developer.m-files.com/APIs/gRPC-API/Reference/Enums/MFiles.Datatype/index.md) | The data type of the value. |
| `view_location.customized_property_folder.data` | [`TypedValueUnion`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.TypedValueUnion/index.md) | The value, in the member that matches `type`. Unset for an empty value. |
| `subfolder` | [`ValueListItem`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.ValueListItem/index.md) | The folder to create: `item_info.obj_id.type` 4 (Traditional folders) and `item_info.name`. The item ID is ignored. |
| `subfolder.item_info` | [`ItemInfo`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.ItemInfo/index.md) | The item's identity and name: `obj_id.type` is the value list ID, `obj_id.item_id.internal_id` the item ID (unique within the list only), plus `name`, `guid`, `external_id` and flags. `options.is_deleted` marks a deleted item. |
| `subfolder.item_info.obj_id` | [`ObjID`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.ObjID/index.md) | The object id or value list item id. Includes the object type or value list id. |
| `subfolder.item_info.name` | `string` | The name of the item. |
| `subfolder.item_info.external_id_status` | [`ExtIDStatus`](https://developer.m-files.com/APIs/gRPC-API/Reference/Enums/MFiles.ExtIDStatus/index.md) | The status of this item's external ID. Values: `EXT_IDSTATUS_UNKNOWN` (0), `EXT_IDSTATUS_EXTERNAL` (1), `EXT_IDSTATUS_INTERNAL` (2), `EXT_IDSTATUS_DISCARDED` (3), `EXT_IDSTATUS_NOT_AVAILABLE` (4), `EXT_IDSTATUS_EXTERNAL_REDUCED` (5). |
| `subfolder.item_info.external_id` | `string` | The external ID (display ID) of this item. unset means that the external ID is the same as the internal ID. |
| `subfolder.item_info.guid` | `string` | GUID for the item. |
| `subfolder.item_info.options` | [`ITEMFLAGS`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.ITEMFLAGS/index.md) | Bit flags that provide additional information on the item (e.g. is the object deleted). |
| `subfolder.item_info.external_repository_icon_id` | `string` | The ID of the item's icon. |
| `subfolder.has_parent` | `bool` | True if the item has a parent item in the same (hierarchical) list. |
| `subfolder.has_owner` | `bool` | True if the item belongs to an item of the owner list (`ValueList.owner_object_type`). |
| `subfolder.parent_id` | `int32` | With `has_parent`, the item ID of the parent item; otherwise ignored. |
| `subfolder.owner_id` | `int32` | With `has_owner`, the item ID of the owner item in the owner list. |
| `subfolder.owner_name` | `string` | The name of the owner item. |
| `subfolder.automatic_permissions` | [`AutomaticPermissions`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.AutomaticPermissions/index.md) | If set, specifies the automatic permissions for an object for which the user selects this item. |
| `subfolder.automatic_permissions.permissions` | [`NamedACL`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.NamedACL/index.md) | The automatic permissions for an object for which the user selects this item. |
| `subfolder.automatic_permissions.is_default` | `bool` | True if these automatic permissions are not private i.e. they are not directly specified for (owned by) this item but they come from somewhere else, e.g. from the default/common automatic permissions of the object type. |
| `subfolder.automatic_permissions.use_object_permissions` | `bool` | If true the object/item's own permissions are used as its automatic permissions. |
| `subfolder.icon` | [`Bytes`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.Bytes/index.md) | If set, contains the icon of this item in .ICO format. |
| `subfolder.icon.value` | `bytes` | Array of bytes. |

<a id="response"></a>

## Response: CreateSubFolderResponse

Response to create sub-folder request.

> Nested message fields are expanded to depth 3; follow a type link for deeper levels and for the type's own page.

| Field | Type | Description |
|---|---|---|
| `folder` | [`ValueListItem`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.ValueListItem/index.md) | The created or found folder. |
| `folder.item_info` | [`ItemInfo`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.ItemInfo/index.md) | The item's identity and name: `obj_id.type` is the value list ID, `obj_id.item_id.internal_id` the item ID (unique within the list only), plus `name`, `guid`, `external_id` and flags. `options.is_deleted` marks a deleted item. |
| `folder.item_info.obj_id` | [`ObjID`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.ObjID/index.md) | The object id or value list item id. Includes the object type or value list id. |
| `folder.item_info.name` | `string` | The name of the item. |
| `folder.item_info.external_id_status` | [`ExtIDStatus`](https://developer.m-files.com/APIs/gRPC-API/Reference/Enums/MFiles.ExtIDStatus/index.md) | The status of this item's external ID. Values: `EXT_IDSTATUS_UNKNOWN` (0), `EXT_IDSTATUS_EXTERNAL` (1), `EXT_IDSTATUS_INTERNAL` (2), `EXT_IDSTATUS_DISCARDED` (3), `EXT_IDSTATUS_NOT_AVAILABLE` (4), `EXT_IDSTATUS_EXTERNAL_REDUCED` (5). |
| `folder.item_info.external_id` | `string` | The external ID (display ID) of this item. unset means that the external ID is the same as the internal ID. |
| `folder.item_info.guid` | `string` | GUID for the item. |
| `folder.item_info.options` | [`ITEMFLAGS`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.ITEMFLAGS/index.md) | Bit flags that provide additional information on the item (e.g. is the object deleted). |
| `folder.item_info.external_repository_icon_id` | `string` | The ID of the item's icon. |
| `folder.has_parent` | `bool` | True if the item has a parent item in the same (hierarchical) list. |
| `folder.has_owner` | `bool` | True if the item belongs to an item of the owner list (`ValueList.owner_object_type`). |
| `folder.parent_id` | `int32` | With `has_parent`, the item ID of the parent item; otherwise ignored. |
| `folder.owner_id` | `int32` | With `has_owner`, the item ID of the owner item in the owner list. |
| `folder.owner_name` | `string` | The name of the owner item. |
| `folder.automatic_permissions` | [`AutomaticPermissions`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.AutomaticPermissions/index.md) | If set, specifies the automatic permissions for an object for which the user selects this item. |
| `folder.automatic_permissions.permissions` | [`NamedACL`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.NamedACL/index.md) | The automatic permissions for an object for which the user selects this item. |
| `folder.automatic_permissions.is_default` | `bool` | True if these automatic permissions are not private i.e. they are not directly specified for (owned by) this item but they come from somewhere else, e.g. from the default/common automatic permissions of the object type. |
| `folder.automatic_permissions.use_object_permissions` | `bool` | If true the object/item's own permissions are used as its automatic permissions. |
| `folder.icon` | [`Bytes`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.Bytes/index.md) | If set, contains the icon of this item in .ICO format. |
| `folder.icon.value` | `bytes` | Array of bytes. |
| `value_list_version` | `int64` | The current version of the Traditional folders list's items. |

<a id="related"></a>

## Related methods

- [IRPCValueLists.CreateOrFindTraditionalFolder](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCValueLists/CreateOrFindTraditionalFolder/index.md): Creates a traditional folder, or returns an existing folder with the same name.
