Presets

Presets hold the preferences of individual users of the platform. This allows Directus to show and maintain custom item listings for users of the app.

List Presets

List all presets that exist in Directus. The data returned in this endpoint will be filtered based on the user's permissions. For example, presets for a role other than the current user's role won't be returned.

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.

page
integer

Cursor for use in pagination. Often used in combination with limit.

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 /presets
Response Example
{
  "data": [
    {
      "id": 155,
      "user": "63716273-0f29-4648-8a2a-2af2948f6f78",
      "role": "50419801-0f30-8644-2b3c-9bc2d980d0a0",
      "collection": "articles",
      "layout": null,
      "layout_query": {
        "cards": {
          "sort": "-published_on"
        }
      },
      "layout_options": {
        "cards": {
          "icon": "account_circle",
          "title": "{{ first_name }} {{ last_name }}",
          "subtitle": "{{ title }}",
          "size": 3
        }
      },
      "filters": []
    }
  ],
  "meta": {}
}

Create Multiple Presets

Create multiple new Presets.

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 /presets
Response Example
{
  "data": [
    {
      "id": 155,
      "user": "63716273-0f29-4648-8a2a-2af2948f6f78",
      "role": "50419801-0f30-8644-2b3c-9bc2d980d0a0",
      "collection": "articles",
      "layout": null,
      "layout_query": {
        "cards": {
          "sort": "-published_on"
        }
      },
      "layout_options": {
        "cards": {
          "icon": "account_circle",
          "title": "{{ first_name }} {{ last_name }}",
          "subtitle": "{{ title }}",
          "size": 3
        }
      },
      "filters": []
    }
  ],
  "meta": {}
}

Delete Multiple Presets

Delete multiple existing presets.

Request Body

An array of preset primary keys.

[array]
array
DELETE /presets

Update Multiple Presets

Update multiple presets at the same time.

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

keys
array
data
object

Response

Successful request

data
array
meta
object
PATCH /presets
Response Example
{
  "data": [
    {
      "id": 155,
      "user": "63716273-0f29-4648-8a2a-2af2948f6f78",
      "role": "50419801-0f30-8644-2b3c-9bc2d980d0a0",
      "collection": "articles",
      "layout": null,
      "layout_query": {
        "cards": {
          "sort": "-published_on"
        }
      },
      "layout_options": {
        "cards": {
          "icon": "account_circle",
          "title": "{{ first_name }} {{ last_name }}",
          "subtitle": "{{ title }}",
          "size": 3
        }
      },
      "filters": []
    }
  ],
  "meta": {}
}

Create a Preset

Create a new preset.

Query Parameters

fields
array

Control what fields are being returned in the object.

meta
string

What metadata to return in the response.

Request Body

collection
string

What collection this collection preset is used for.

title
string

Name for the bookmark. If this is set, the collection preset will be considered to be a bookmark.

role
string

The unique identifier of a role in the platform. If user is null, this will be used to apply the collection preset or bookmark for all users in the role.

search
string

What the user searched for in search/filter in the header bar.

filters
array
layout
string

Name of the view type that is used.

layout_query
string

Layout query that's saved per layout type. Controls what data is fetched on load. These follow the same format as the JS SDK parameters.

layout_options
string

Options of the views. The properties in here are controlled by the layout.

Response

Successful request

data
object
POST /presets‎
Response Example
{
  "data": {
    "id": 155,
    "user": "63716273-0f29-4648-8a2a-2af2948f6f78",
    "role": "50419801-0f30-8644-2b3c-9bc2d980d0a0",
    "collection": "articles",
    "layout": null,
    "layout_query": {
      "cards": {
        "sort": "-published_on"
      }
    },
    "layout_options": {
      "cards": {
        "icon": "account_circle",
        "title": "{{ first_name }} {{ last_name }}",
        "subtitle": "{{ title }}",
        "size": 3
      }
    },
    "filters": []
  }
}

Retrieve a Preset

Retrieve a single preset by unique identifier.

Query Parameters

id
integer

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 /presets/{id}
Response Example
{
  "data": {
    "id": 155,
    "user": "63716273-0f29-4648-8a2a-2af2948f6f78",
    "role": "50419801-0f30-8644-2b3c-9bc2d980d0a0",
    "collection": "articles",
    "layout": null,
    "layout_query": {
      "cards": {
        "sort": "-published_on"
      }
    },
    "layout_options": {
      "cards": {
        "icon": "account_circle",
        "title": "{{ first_name }} {{ last_name }}",
        "subtitle": "{{ title }}",
        "size": 3
      }
    },
    "filters": []
  }
}

Delete a Preset

Delete an existing preset.

Query Parameters

id
integer

Identifier for the object.

DELETE /presets/{id}

Update a Preset

Update an existing preset.

Query Parameters

id
integer

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

collection
string

What collection this collection preset is used for.

title
string

Name for the bookmark. If this is set, the collection preset will be considered to be a bookmark.

role
integer

The unique identifier of a role in the platform. If user is null, this will be used to apply the collection preset or bookmark for all users in the role.

search_query
string

What the user searched for in search/filter in the header bar.

filters
array
view_type
string

Name of the view type that is used. Defaults to tabular.

view_query
string

View query that's saved per view type. Controls what data is fetched on load. These follow the same format as the JS SDK parameters.

view_options
string

Options of the views. The properties in here are controlled by the layout.

translation
object

Key value pair of language-translation. Can be used to translate the bookmark title in multiple languages.

Response

Successful request

data
object
PATCH /presets/{id}
Response Example
{
  "data": {
    "id": 155,
    "user": "63716273-0f29-4648-8a2a-2af2948f6f78",
    "role": "50419801-0f30-8644-2b3c-9bc2d980d0a0",
    "collection": "articles",
    "layout": null,
    "layout_query": {
      "cards": {
        "sort": "-published_on"
      }
    },
    "layout_options": {
      "cards": {
        "icon": "account_circle",
        "title": "{{ first_name }} {{ last_name }}",
        "subtitle": "{{ title }}",
        "size": 3
      }
    },
    "filters": []
  }
}