Policies

Policies define a specific set of access permissions, and are a composable unit that can be assigned to both roles and users.

List Policies

List all policies 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.

meta
string

What metadata to return in the response.

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.

page
integer

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

Response

Successful request

data
array
meta
object
GET /policies
Response Example
{
  "data": [
    {
      "id": "22640672-eef0-4ee9-ab04-591f3afb288",
      "name": "Admin",
      "icon": "supervised_user_circle",
      "description": null,
      "ip_access": null,
      "enforce_tfa": false,
      "admin_access": true,
      "app_access": true,
      "users": [
        "0bc7b36a-9ba9-4ce0-83f0-0a526f354e07"
      ],
      "roles": [
        "8b4474c0-288d-4bb8-b62e-8330646bb6aa"
      ],
      "permissions": [
        "5c74c86f-cab0-4b14-a3c4-cd4f2363e826"
      ]
    }
  ],
  "meta": {}
}

Create Multiple Policies

Create multiple new policies.

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 /policies
Response Example
{
  "data": [
    {
      "id": "22640672-eef0-4ee9-ab04-591f3afb288",
      "name": "Admin",
      "icon": "supervised_user_circle",
      "description": null,
      "ip_access": null,
      "enforce_tfa": false,
      "admin_access": true,
      "app_access": true,
      "users": [
        "0bc7b36a-9ba9-4ce0-83f0-0a526f354e07"
      ],
      "roles": [
        "8b4474c0-288d-4bb8-b62e-8330646bb6aa"
      ],
      "permissions": [
        "5c74c86f-cab0-4b14-a3c4-cd4f2363e826"
      ]
    }
  ],
  "meta": {}
}

Delete Multiple Policies

Delete multiple existing policies.

Request Body

An array of policy primary keys.

[array]
array
DELETE /policies

Update Multiple Policies

Update multiple existing policies.

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 /policies
Response Example
{
  "data": [
    {
      "id": "22640672-eef0-4ee9-ab04-591f3afb288",
      "name": "Admin",
      "icon": "supervised_user_circle",
      "description": null,
      "ip_access": null,
      "enforce_tfa": false,
      "admin_access": true,
      "app_access": true,
      "users": [
        "0bc7b36a-9ba9-4ce0-83f0-0a526f354e07"
      ],
      "roles": [
        "8b4474c0-288d-4bb8-b62e-8330646bb6aa"
      ],
      "permissions": [
        "5c74c86f-cab0-4b14-a3c4-cd4f2363e826"
      ]
    }
  ],
  "meta": {}
}

Create a Policy

Create a new policy.

Query Parameters

fields
array

Control what fields are being returned in the object.

meta
string

What metadata to return in the response.

Request Body

[object]
object

Response

Successful request

data
object
POST /policies‎
Response Example
{
  "data": {
    "id": "22640672-eef0-4ee9-ab04-591f3afb288",
    "name": "Admin",
    "icon": "supervised_user_circle",
    "description": null,
    "ip_access": null,
    "enforce_tfa": false,
    "admin_access": true,
    "app_access": true,
    "users": [
      "0bc7b36a-9ba9-4ce0-83f0-0a526f354e07"
    ],
    "roles": [
      "8b4474c0-288d-4bb8-b62e-8330646bb6aa"
    ],
    "permissions": [
      "5c74c86f-cab0-4b14-a3c4-cd4f2363e826"
    ]
  }
}

Retrieve a Policy

List an existing policy by primary key.

Query Parameters

id
string

Unique identifier of the Policy.

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 /policies/{id}
Response Example
{
  "data": {
    "id": "22640672-eef0-4ee9-ab04-591f3afb288",
    "name": "Admin",
    "icon": "supervised_user_circle",
    "description": null,
    "ip_access": null,
    "enforce_tfa": false,
    "admin_access": true,
    "app_access": true,
    "users": [
      "0bc7b36a-9ba9-4ce0-83f0-0a526f354e07"
    ],
    "roles": [
      "8b4474c0-288d-4bb8-b62e-8330646bb6aa"
    ],
    "permissions": [
      "5c74c86f-cab0-4b14-a3c4-cd4f2363e826"
    ]
  }
}

Delete a Policy

Delete an existing policy.

Query Parameters

id
string

Unique identifier of the policy.

DELETE /policies/{id}

Update a Policy

Update an existing policy.

Query Parameters

id
string

Unique identifier of the policy.

fields
array

Control what fields are being returned in the object.

meta
string

What metadata to return in the response.

Request Body

[object]
object

Response

Successful request

data
object
PATCH /policies/{id}
Response Example
{
  "data": {
    "id": "22640672-eef0-4ee9-ab04-591f3afb288",
    "name": "Admin",
    "icon": "supervised_user_circle",
    "description": null,
    "ip_access": null,
    "enforce_tfa": false,
    "admin_access": true,
    "app_access": true,
    "users": [
      "0bc7b36a-9ba9-4ce0-83f0-0a526f354e07"
    ],
    "roles": [
      "8b4474c0-288d-4bb8-b62e-8330646bb6aa"
    ],
    "permissions": [
      "5c74c86f-cab0-4b14-a3c4-cd4f2363e826"
    ]
  }
}