Folders

Folders can be used to organize files within the platform. Folders are virtual, and aren't mirrored within the storage adapter.

List Folders

List all folders that exist in Directus.

Query Parameters

fields
array

Control what fields are being returned in the object.

limit
integer

A limit on the number of objects that are returned.

offset
integer

How many items to skip when fetching data.

sort
array

How to sort the returned items. sort is a CSV of fields used to sort the fetched items. Sorting defaults to ascending (ASC) order but a minus sign (-) can be used to reverse this to descending (DESC) order. Fields are prioritized by their order in the CSV. You can also use a ? to sort randomly.

filter

Select items in collection by given conditions.

search
string

Filter by items that contain the given search query in one of their fields.

meta
string

What metadata to return in the response.

Response

Successful request

data
array
meta
object
GET /folders
Response Example
{
  "data": [
    {
      "id": "0cf0e03d-4364-45df-b77b-ca61f61869d2",
      "name": "New York",
      "parent": "{\n  \"data\": {\n    \"id\": \"fc02d733-95b8-4e27-bd4b-08a32cbe4e66\",\n    \"name\": \"Test\",\n    \"parent\": null\n  }\n}\n"
    }
  ],
  "meta": {}
}

Create Multiple Folders

Create multiple new (virtual) folders.

Query Parameters

fields
array

Control what fields are being returned in the object.

limit
integer

A limit on the number of objects that are returned.

meta
string

What metadata to return in the response.

offset
integer

How many items to skip when fetching data.

sort
array

How to sort the returned items. sort is a CSV of fields used to sort the fetched items. Sorting defaults to ascending (ASC) order but a minus sign (-) can be used to reverse this to descending (DESC) order. Fields are prioritized by their order in the CSV. You can also use a ? to sort randomly.

filter

Select items in collection by given conditions.

search
string

Filter by items that contain the given search query in one of their fields.

Request Body

data
array

Response

Successful request

data
array
meta
object
POST /folders
Response Example
{
  "data": [
    {
      "id": "0cf0e03d-4364-45df-b77b-ca61f61869d2",
      "name": "New York",
      "parent": "{\n  \"data\": {\n    \"id\": \"fc02d733-95b8-4e27-bd4b-08a32cbe4e66\",\n    \"name\": \"Test\",\n    \"parent\": null\n  }\n}\n"
    }
  ],
  "meta": {}
}

Delete Multiple Folders

Delete multiple existing folders. Any files in these folders will be moved to the root folder.

Request Body

An array of folder primary keys.

[array]
array
DELETE /folders

Update Multiple Folders

Update multiple folders at the same time. Any files in these folders will be moved to the root folder.

Query Parameters

fields
array

Control what fields are being returned in the object.

limit
integer

A limit on the number of objects that are returned.

meta
string

What metadata to return in the response.

offset
integer

How many items to skip when fetching data.

sort
array

How to sort the returned items. sort is a CSV of fields used to sort the fetched items. Sorting defaults to ascending (ASC) order but a minus sign (-) can be used to reverse this to descending (DESC) order. Fields are prioritized by their order in the CSV. You can also use a ? to sort randomly.

filter

Select items in collection by given conditions.

search
string

Filter by items that contain the given search query in one of their fields.

Request Body

data
object
keys
array

Response

Successful request

data
array
meta
object
PATCH /folders
Response Example
{
  "data": [
    {
      "id": "0cf0e03d-4364-45df-b77b-ca61f61869d2",
      "name": "New York",
      "parent": "{\n  \"data\": {\n    \"id\": \"fc02d733-95b8-4e27-bd4b-08a32cbe4e66\",\n    \"name\": \"Test\",\n    \"parent\": null\n  }\n}\n"
    }
  ],
  "meta": {}
}

Create a Folder

Create a new (virtual) folder.

Query Parameters

fields
array

Control what fields are being returned in the object.

meta
string

What metadata to return in the response.

Request Body

name
string

Name of the folder.

parent
integer

Unique identifier of the parent folder. This allows for nested folders.

Response

Successful request

data
object
POST /folders‎
Response Example
{
  "data": {
    "id": "0cf0e03d-4364-45df-b77b-ca61f61869d2",
    "name": "New York",
    "parent": "{\n  \"data\": {\n    \"id\": \"fc02d733-95b8-4e27-bd4b-08a32cbe4e66\",\n    \"name\": \"Test\",\n    \"parent\": null\n  }\n}\n"
  }
}

Retrieve a Folder

List an existing folder by primary key.

Query Parameters

id
string

Unique identifier for the object.

fields
array

Control what fields are being returned in the object.

meta
string

What metadata to return in the response.

Response

Successful request

data
object
GET /folders/{id}
Response Example
{
  "data": {
    "id": "0cf0e03d-4364-45df-b77b-ca61f61869d2",
    "name": "New York",
    "parent": "{\n  \"data\": {\n    \"id\": \"fc02d733-95b8-4e27-bd4b-08a32cbe4e66\",\n    \"name\": \"Test\",\n    \"parent\": null\n  }\n}\n"
  }
}

Delete a Folder

Delete an existing folder. Any files in this folder will be moved to the root folder.

Query Parameters

id
string

Unique identifier for the object.

DELETE /folders/{id}

Update a Folder

Update an existing folder.

Query Parameters

id
string

Unique identifier for the object.

fields
array

Control what fields are being returned in the object.

meta
string

What metadata to return in the response.

Request Body

name
string

Name of the folder. Can't be null or empty.

parent
integer

Unique identifier of the parent folder. This allows for nested folders.

Response

Successful request

data
object
PATCH /folders/{id}
Response Example
{
  "data": {
    "id": "0cf0e03d-4364-45df-b77b-ca61f61869d2",
    "name": "New York",
    "parent": "{\n  \"data\": {\n    \"id\": \"fc02d733-95b8-4e27-bd4b-08a32cbe4e66\",\n    \"name\": \"Test\",\n    \"parent\": null\n  }\n}\n"
  }
}