Files
directus/docs/reference/api/rest/presets.md
Rijk van Zanten 817ccf3620 Overhaul docs (#3951)
* Add Quickstart Guide

* Update installation

* Remove unused files

* Update support/backing

* Tweaks in concepts

* Setup file structure for API reference 2.0

* Setup page layout for reference

* Add clean-urls plugin

* getting started updates

* Finish authentication rest

* getting started updates

* Render stylus in 2 spaces

* Various

* Various

* Finish activity docs

* Add collections reference

* Add extension reference

* concepts updates

* Fields/tweaks

* Add files doc

* Add revisions

* concepts docs

* More api reference

* Finish rest api reference (finally)

* initial concepts

* More things

* Add assets api ref

* Move sections from file to assets

* Add environment variables

* contributing docs

* Add field transforms page

* Left align table headers

* concept links

* Add API config

* Fix mobile nav

* Add migrating a project

* doc link fixes

Co-authored-by: Ben Haynes <ben@rngr.org>
2021-02-05 18:51:54 -05:00

5.8 KiB

pageClass
pageClass
page-reference

Preset

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

toc


The Preset Object

id uuid
Primary key of the preset.

bookmark string
The title of the bookmark. If this value is null, it's considered a preset instead of a bookmark.

user many-to-one
User this preset applies to. Many-to-one to users.

role many-to-one
Role this preset applies to. Many-to-one to users.

collection string
Collection this preset applies to.

search string
The search query used in the preset.

filters array
The filters used in the preset.

layout string
The layout used in this preset.

layout_query object
The item query used by the layout. This structure is based on the used layout.

layout_options object
The options used by the layout. This structure is based on the used layout.

{
	"id": 39,
	"bookmark": null,
	"user": "410b5772-e63f-4ae6-9ea2-39c3a31bd6ca",
	"role": null,
	"collection": "directus_activity",
	"search": null,
	"filters": [],
	"layout": "tabular",
	"layout_query": {
		"tabular": {
			"sort": "-timestamp",
			"fields": ["action", "collection", "timestamp", "user"],
			"page": 1
		}
	},
	"layout_options": {
		"tabular": {
			"widths": {
				"action": 100,
				"collection": 210,
				"timestamp": 240,
				"user": 240
			}
		}
	}
}

List Presets

List all presets that exist in Directus.

::: tip Permissions

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

Supports all global query parameters.

Returns

An array of up to limit preset objects. If no items are available, data will be an empty array.

GET /presets

// Response

{
	"data": [
		{
			"id": 39,
			"bookmark": null,
			"user": "410b5772-e63f-4ae6-9ea2-39c3a31bd6ca",
			"role": null,
			"collection": "directus_activity",
			"search": null,
			"filters": [],
			"layout": "tabular",
			"layout_query": {
				"tabular": {
					"sort": "-timestamp",
					"fields": ["action", "collection", "timestamp", "user"],
					"page": 1
				}
			},
			"layout_options": {
				"tabular": {
					"widths": {
						"action": 100,
						"collection": 210,
						"timestamp": 240,
						"user": 240
					}
				}
			}
		},
		{...},
		{...}
	]
}

Retrieve a preset

List an existing preset by primary key.

Query Parameters

Supports all global query parameters.

Returns

Returns the requested preset object.

GET /presets/:id

// Response

{
	"data": {
		"id": 39,
		"bookmark": null,
		"user": "410b5772-e63f-4ae6-9ea2-39c3a31bd6ca",
		"role": null,
		"collection": "directus_activity",
		"search": null,
		"filters": [],
		"layout": "tabular",
		"layout_query": {
			"tabular": {
				"sort": "-timestamp",
				"fields": ["action", "collection", "timestamp", "user"],
				"page": 1
			}
		},
		"layout_options": {
			"tabular": {
				"widths": {
					"action": 100,
					"collection": 210,
					"timestamp": 240,
					"user": 240
				}
			}
		}
	}
}

Create Preset

Create one or more new preset(s).

Query Parameters

Supports all global query parameters.

Request Body

A partial preset object or an array of partial preset objects.

Returns

Returns the preset object for the created preset.

POST /presets

// Request

{
	"user": "410b5772-e63f-4ae6-9ea2-39c3a31bd6ca",
	"layout": "cards",
	"search": "Directus"
}
// Response

{
	"data": {
		"id": 42,
		"bookmark": null,
		"user": "410b5772-e63f-4ae6-9ea2-39c3a31bd6ca",
		"role": null,
		"collection": null,
		"search": "Directus",
		"filters": null,
		"layout": "cards",
		"layout_query": null,
		"layout_options": null
	}
}

Update Preset

Update an existing preset.

Query Parameters

Supports all global query parameters.

Request Body

A partial preset object.

Returns

Returns the preset object for the created preset.

PATCH /presets/:id

// Request

{
	"layout": "tabular"
}
// Response

{
	"data": {
		"id": 42,
		"bookmark": null,
		"user": "410b5772-e63f-4ae6-9ea2-39c3a31bd6ca",
		"role": null,
		"collection": null,
		"search": "Directus",
		"filters": null,
		"layout": "tabular",
		"layout_query": null,
		"layout_options": null
	}
}

Delete Preset

Delete an existing preset.

Returns

Empty body.

DELETE /presets/:id

// Empty Response

Delete Multiple Presets

Delete multiple existing presets.

Request Body

An array of preset primary keys

Returns

Empty body.

DELETE /presets

// Request
[15, 251, 810]
// Empty Response