# Collection Presets

Collection 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.


# The Collection Preset Object

# Attributes

# id integer

Unique identifier for this single collection preset.

# title string

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

# user integer

The unique identifier of the user to whom this collection preset applies.

# 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.

# collection string

What collection this collection preset is used for.

# search_query string

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

# filters array

The filters that the user applied.

# view_type string

Name of the view type that is used.

# view_query object

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 object

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.


# List the Collection Presets

List the collection presets.

# Parameters

# project required

The project you're targetting.

# Query

# fields optional

Control what fields are being returned in the object. Learn more

# limit optional

A limit on the number of objects that are returned. Default is 200. Learn more

# offset optional

How many items to skip when fetching data. Default is 0. Learn more

# page optional

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

# sort optional

How to sort the returned items. Learn more

# single optional

Return the result as if it was a single item. Useful for selecting a single item based on filters and search queries. Will force limit to be 1. Learn more

# filter optional

Select items in collection by given conditions. Learn more

# q optional

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

# meta optional

What metadata to return in the response. Learn more

# Returns

Returns an array of collection preset objects.

Endpoint
   GET /:project/collection_presets
Response
{
  "data": [
    {
      "id": 155,
      "title": null,
      "user": 1,
      "role": 1,
      "collection": "articles",
      "search_query": null,
      "filters": [
        {
          "field": "title",
          "operator": "contains",
          "value": "Hello"
        },
        { ... },
        { ... }
      ],
      "view_type": "timeline",
      "view_query": {
        "timeline": {
          "sort": "-published_on"
        }
      },
      "view_options": {
        "timeline": {
          "date": "published_on",
          "title": "{{ title }} ({{ author.first_name }} {{ author.last_name }})",
          "content": "excerpt",
          "color": "action"
        }
      },
      "translation": null
    }
  ]
}

# Retrieve a Collection Preset

Retrieve a single collection preset by unique identifier.

# Parameters

# project required

The project you're targetting.

# id required

Unique identifier of the item.

# Query

# fields optional

Control what fields are being returned in the object. Learn more

# meta optional

What metadata to return in the response. Learn more

# Returns

Returns the collection preset object for the given unique identifier.

Endpoint
   GET /:project/collection_presets/:id
Response
{
  "data": {
    "id": 155,
    "title": null,
    "user": 1,
    "role": 1,
    "collection": "articles",
    "search_query": null,
    "filters": [
      {
        "field": "title",
        "operator": "contains",
        "value": "Hello"
      },
      { ... },
      { ... }
    ],
    "view_type": "timeline",
    "view_query": {
      "timeline": {
        "sort": "-published_on"
      }
    },
    "view_options": {
      "timeline": {
        "date": "published_on",
        "title": "{{ title }} ({{ author.first_name }} {{ author.last_name }})",
        "content": "excerpt",
        "color": "action"
      }
    },
    "translation": null
  }
}

# Create a Collection Preset

Create a new collection preset.

# Parameters

# project required

The project you're targetting.

# Attributes

# collection required

What collection this collection preset is used for.

# title optional

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

# user optional

The unique identifier of the user to whom this collection preset applies.

# role optional

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 optional

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

# filters optional

The filters that the user applied.

# view_type optional

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

# view_query optional

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 optional

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

# translation optional

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

# Query

# fields optional

Control what fields are being returned in the object. Learn more

# meta optional

What metadata to return in the response. Learn more

# Returns

Returns the collection preset object for the collection preset that was just created.

Endpoint
  POST /:project/collection_presets
Request
{
  "collection": "articles",
  "title": "Highly rated articles",
  "filters": [{
  	"field": "rating",
  	"operator": "gte",
  	"value": 4.5
  }]
}
Response
{
  "data": {
    "id": 29,
    "title": "Highly rated articles",
    "user": null,
    "role": null,
    "collection": "articles",
    "search_query": null,
    "filters": [
      {
        "field": "rating",
        "operator": "gte",
        "value": 4.5
      }
    ],
    "view_type": "tabular",
    "view_query": null,
    "view_options": null,
    "translation": null
  }
}

# Update a Collection Preset

Update an existing collection preset.

# Parameters

# project required

The project you're targetting.

# id required

Unique identifier of the item.

# Attributes

# collection required

What collection this collection preset is used for.

# title optional

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

# user optional

The unique identifier of the user to whom this collection preset applies.

# role optional

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 optional

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

# filters optional

The filters that the user applied.

# view_type optional

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

# view_query optional

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 optional

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

# translation optional

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

# Query

# fields optional

Control what fields are being returned in the object. Learn more

# meta optional

What metadata to return in the response. Learn more

# Returns

A collection preset object.

Endpoint
 PATCH /:project/collection_presets/:id
Request
{
  "collection": "movies"
}
Response
{
  "data": {
    "id": 29,
    "title": "Highly rated articles",
    "user": null,
    "role": null,
    "collection": "movies",
    "search_query": null,
    "filters": [
      {
        "field": "rating",
        "operator": "gte",
        "value": 4.5
      }
    ],
    "view_type": "tabular",
    "view_query": null,
    "view_options": null,
    "translation": null
  }
}

# Delete a Collection Preset

Delete an existing collection preset.

# Parameters

# project required

The project you're targetting.

# id required

Unique identifier of the item.

# Returns

Returns an empty body with HTTP status 204

Endpoint
DELETE /:project/collection_presets/:id