Control panels

Control panels allow you to configure the global site setup. The @controlpanels endpoint allows you to list all existing control panels.

Listing Control Panels

A list of all existing control panels in the portal can be retrieved by sending a GET request to the @controlpanels endpoint:

GET /@controlpanels HTTP/1.1
Accept: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhZG1pbiIsImZ1bGxuYW1lIjoiQWRtaW4iLCJpYXQiOjE2NDkzMTI0NDl9.RS1Ny_r0v7vIylFfK6q0JVJrkiDuTOh9iG9IL8xbzAk

Or use the client directly:

import { Client } from '@robgietema/nick';

const cli = Client.initialize({ apiPath: 'http://localhost:8080' });
const login = await cli.login({
  data: { login: 'admin', password: 'admin' },
});

const { data } = await cli.getControlpanels();

Response:

HTTP/1.1 200 OK
Content-Type: application/json

[
  {
    "@id": "http://localhost:8080/@controlpanels/dexterity-types",
    "group": "Content",
    "title": "Content Types"
  },
  {
    "@id": "http://localhost:8080/@controlpanels/language",
    "group": "General",
    "title": "Language"
  },
  {
    "@id": "http://localhost:8080/@controlpanels/mail",
    "group": "General",
    "title": "Mail"
  },
  {
    "@id": "http://localhost:8080/@controlpanels/navigation",
    "group": "General",
    "title": "Navigation"
  },
  {
    "@id": "http://localhost:8080/@controlpanels/security",
    "group": "Security",
    "title": "Security"
  },
  {
    "@id": "http://localhost:8080/@controlpanels/site",
    "group": "General",
    "title": "Site"
  },
  {
    "@id": "http://localhost:8080/@controlpanels/usergroup",
    "group": "Users",
    "title": "User and Group Settings"
  }
]

The following fields are returned:

  • @id: hypermedia link to the control panel
  • title: the title of the control panel
  • group: the group in which the control panel should appear, for example, General, Content, Users, Security, Advanced, or Add-on Configuration.

Retrieve a single Control Panel

To retrieve a single control panel, send a GET request to the URL of the control panel:

GET /@controlpanels/mail HTTP/1.1
Accept: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhZG1pbiIsImZ1bGxuYW1lIjoiQWRtaW4iLCJpYXQiOjE2NDkzMTI0NDl9.RS1Ny_r0v7vIylFfK6q0JVJrkiDuTOh9iG9IL8xbzAk

Or use the client directly:

import { Client } from '@robgietema/nick';

const cli = Client.initialize({ apiPath: 'http://localhost:8080' });
const login = await cli.login({
  data: { login: 'admin', password: 'admin' },
});

const { data } = await cli.getControlpanel({ path: '/mail' });

Response:

HTTP/1.1 200 OK
Content-Type: application/json

{
  "@id": "http://localhost:8080/@controlpanels/mail",
  "group": "General",
  "title": "Mail",
  "data": {
    "host": "localhost",
    "pass": "",
    "port": 25,
    "user": "",
    "debug": true,
    "secure": true,
    "email_from_name": "Webmaster",
    "email_from_address": "webmaster@nickcms.org"
  },
  "schema": {
    "required": ["host", "port", "email_from_name", "email_from_address"],
    "fieldsets": [
      {
        "id": "default",
        "title": "Default",
        "fields": [
          "host",
          "port",
          "secure",
          "user",
          "pass",
          "email_from_name",
          "email_from_address",
          "debug"
        ]
      }
    ],
    "properties": {
      "host": {
        "type": "string",
        "title": "SMTP server",
        "default": "localhost",
        "description": "The address of your local SMTP (outgoing email) server. Usually 'localhost', unless you use an external server to send email."
      },
      "pass": {
        "type": "string",
        "title": "ESMTP password",
        "widget": "password",
        "description": "The password for the ESMTP user account."
      },
      "port": {
        "type": "integer",
        "title": "SMTP port",
        "default": 25,
        "description": "The port of your local SMTP (outgoing email) server. Usually '25'."
      },
      "user": {
        "type": "string",
        "title": "ESMTP username",
        "description": "Username for authentication to your email server. Not required unless you are using ESMTP."
      },
      "debug": {
        "type": "boolean",
        "title": "Debug",
        "description": "If enabled, the mail is sent to a test server."
      },
      "secure": {
        "type": "boolean",
        "title": "Secure",
        "description": "If enabled, the mail is sent using a secure connection."
      },
      "email_from_name": {
        "type": "string",
        "title": "Site 'From' name",
        "description": "Nick generates email using this name as the email sender."
      },
      "email_from_address": {
        "type": "string",
        "title": "Site 'From' address",
        "description": "Nick generates email using this address as the email return address. It is also used as the destination address for the site-wide contact form and the “Send test email” feature."
      }
    }
  }
}

The following fields are returned:

  • @id: hypermedia link to the control panel
  • title: title of the control panel
  • group: group name of the control panel
  • schema: JSON Schema of the control panel
  • data: current values of the control panel

Updating a Control Panel

To update the settings on a control panel, send a PATCH request to control panel resource:

PATCH /@controlpanels/mail HTTP/1.1
Accept: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhZG1pbiIsImZ1bGxuYW1lIjoiQWRtaW4iLCJpYXQiOjE2NDkzMTI0NDl9.RS1Ny_r0v7vIylFfK6q0JVJrkiDuTOh9iG9IL8xbzAk
Content-Type: application/json

{
  "host": "mail.someserver.com",
  "port": 25
}

Or use the client directly:

import { Client } from '@robgietema/nick';

const cli = Client.initialize({ apiPath: 'http://localhost:8080' });
const login = await cli.login({
  data: { login: 'admin', password: 'admin' },
});

const { data } = await cli.updateControlpanel({
  token: login.data.token,
  path: '/@controlpanels/mail',
  data: {
    host: 'mail.someserver.com',
    port: 25,
  },
});

A successful response to a PATCH request will be indicated by a 204 No Content response:

HTTP/1.1 204 No Content

Control Panels not based on schemas

Control panels which are not based on schemas have a custom @controlpanels/:panel endpoint implementation.

Content Types

@controlpanels/dexterity-types is a custom control panel endpoint that will allow you to add, remove, and configure available types.

Reading or writing content types require the Manage Site permission.

Verb URL Action
GET /@controlpanels/dexterity-types List configurable content types
POST /@controlpanels/dexterity-types Creates a new content type
GET /@controlpanels/dexterity-types/{type-id} Get the current state of the content type
PATCH /@controlpanels/dexterity-types/{type-id} Update the content type details
DELETE /@controlpanels/dexterity-types/{type-id} Remove the content type

Listing Content Types

To list the available content types, send a GET request to @controlpanels/dexterity-types

GET /@controlpanels/dexterity-types HTTP/1.1
Accept: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhZG1pbiIsImZ1bGxuYW1lIjoiQWRtaW4iLCJpYXQiOjE2NDkzMTI0NDl9.RS1Ny_r0v7vIylFfK6q0JVJrkiDuTOh9iG9IL8xbzAk

Or use the client directly:

import { Client } from '@robgietema/nick';

const cli = Client.initialize({ apiPath: 'http://localhost:8080' });
const login = await cli.login({
  data: { login: 'admin', password: 'admin' },
});

const { data } = await cli.getControlpanel({ path: '/dexterity-types' });

Response:

HTTP/1.1 200 OK
Content-Type: application/json

{
  "@id": "http://localhost:8080/@controlpanels/dexterity-types",
  "items": [
    {
      "@id": "http://localhost:8080/@controlpanels/dexterity-types/Event",
      "@type": "Event",
      "title": "Event",
      "description": "",
      "id": "Event",
      "count": 2,
      "meta_type": "Event"
    },
    {
      "@id": "http://localhost:8080/@controlpanels/dexterity-types/Feed",
      "@type": "Feed",
      "count": 0,
      "description": "",
      "id": "Feed",
      "meta_type": "Feed",
      "title": "Feed"
    },
    {
      "@id": "http://localhost:8080/@controlpanels/dexterity-types/File",
      "@type": "File",
      "title": "File",
      "description": "Lets you upload a file to the site.",
      "id": "File",
      "count": 0,
      "meta_type": "File"
    },
    {
      "@id": "http://localhost:8080/@controlpanels/dexterity-types/Folder",
      "@type": "Folder",
      "title": "Folder",
      "description": "",
      "id": "Folder",
      "count": 3,
      "meta_type": "Folder"
    },
    {
      "@id": "http://localhost:8080/@controlpanels/dexterity-types/Image",
      "@type": "Image",
      "title": "Image",
      "description": "Images can be referenced in pages or displayed in an album.",
      "id": "Image",
      "count": 0,
      "meta_type": "Image"
    },
    {
      "@id": "http://localhost:8080/@controlpanels/dexterity-types/Page",
      "@type": "Page",
      "title": "Page",
      "description": "",
      "id": "Page",
      "count": 0,
      "meta_type": "Page"
    },
    {
      "@id": "http://localhost:8080/@controlpanels/dexterity-types/Site",
      "@type": "Site",
      "title": "Site",
      "description": "",
      "id": "Site",
      "count": 1,
      "meta_type": "Site"
    },
    {
      "@id": "http://localhost:8080/@controlpanels/dexterity-types/Video",
      "@type": "Video",
      "title": "Video",
      "description": "Videos can be referenced in pages.",
      "id": "Video",
      "count": 0,
      "meta_type": "Video"
    }
  ],
  "title": "Content Types",
  "group": "Content"
}

The following fields are returned:

  • @id: hypermedia link to the control panel
  • title: title of the control panel
  • group: group name of the control panel
  • items: list of configurable content types

Creating a new type with POST

To create a new content type, send a POST request to the /@controlpanels/dexterity-types endpoint:

POST /@controlpanels/dexterity-types HTTP/1.1
Accept: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhZG1pbiIsImZ1bGxuYW1lIjoiQWRtaW4iLCJpYXQiOjE2NDkzMTI0NDl9.RS1Ny_r0v7vIylFfK6q0JVJrkiDuTOh9iG9IL8xbzAk
Content-Type: application/json

{
  "title": "My Type",
  "description": "Type Description"
}

Or use the client directly:

import { Client } from '@robgietema/nick';

const cli = Client.initialize({ apiPath: 'http://localhost:8080' });
const login = await cli.login({
  data: { login: 'admin', password: 'admin' },
});

const { data } = await cli.createControlpanelType({
  token: login.data.token,
  data: {
    title: 'My Type',
    description: 'Type Description',
  },
});

Response:

HTTP/1.1 201 Created
Content-Type: application/json

{
  "@id": "http://localhost:8080/@controlpanels/dexterity-types/My Type",
  "title": "My Type",
  "description": "Type Description",
  "schema": {
    "fieldsets": [
      {
        "fields": [
          "title",
          "description",
          "allowed_content_types",
          "filter_content_types"
        ],
        "id": "default",
        "title": "Default"
      },
      {
        "fields": [
          "basic",
          "blocks",
          "categorization",
          "dates",
          "dublin_core",
          "exclude_from_nav",
          "ownership",
          "preview_image_link",
          "short_name",
          "versioning"
        ],
        "id": "behaviors",
        "title": "Behaviors"
      }
    ],
    "properties": {
      "allowed_content_types": {
        "additionalItems": true,
        "description": "",
        "factory": "Multiple Choice",
        "items": {
          "description": "",
          "factory": "Choice",
          "title": "",
          "type": "string",
          "vocabulary": {
            "@id": "http://localhost:8080/@vocabularies/types"
          }
        },
        "title": "Allowed Content Types",
        "type": "array",
        "uniqueItems": true
      },
      "description": {
        "description": "",
        "factory": "Text",
        "title": "Description",
        "type": "string",
        "widget": "textarea"
      },
      "filter_content_types": {
        "factory": "Yes/No",
        "title": "Filter Contained Types",
        "description": "Items of this type can act as a folder containing other items. What content types should be allowed inside?",
        "type": "boolean"
      },
      "title": {
        "description": "",
        "factory": "Text line (String)",
        "title": "Type Name",
        "type": "string"
      },
      "basic": {
        "description": "Adds title and description fields.",
        "factory": "Yes/No",
        "title": "Basic metadata",
        "type": "boolean"
      },
      "blocks": {
        "description": "Enables Volto Blocks support",
        "factory": "Yes/No",
        "title": "Blocks",
        "type": "boolean"
      },
      "categorization": {
        "description": "Adds keywords and language fields.",
        "factory": "Yes/No",
        "title": "Categorization",
        "type": "boolean"
      },
      "dates": {
        "description": "Adds effective and expiration dates.",
        "factory": "Yes/No",
        "title": "Dates",
        "type": "boolean"
      },
      "dublin_core": {
        "description": "Adds standard metadatafields",
        "factory": "Yes/No",
        "title": "Dublin Core metadata",
        "type": "boolean"
      },
      "exclude_from_nav": {
        "description": "If selected, this item will not appear in the navigation tree.",
        "factory": "Yes/No",
        "title": "Exclude from navigation",
        "type": "boolean"
      },
      "ownership": {
        "description": "Adds ownership and rights fields.",
        "factory": "Yes/No",
        "title": "Ownership",
        "type": "boolean"
      },
      "preview_image_link": {
        "description": "Gives the ability to rename an item from its edit form.",
        "factory": "Yes/No",
        "title": "Preview Image Link",
        "type": "boolean"
      },
      "short_name": {
        "description": "Gives the ability to rename an item from its edit form.",
        "factory": "Yes/No",
        "title": "Short name",
        "type": "boolean"
      },
      "versioning": {
        "description": "Versioning support",
        "factory": "Yes/No",
        "title": "Versioning",
        "type": "boolean"
      }
    },
    "required": [
      "title",
      "filter_content_types"
    ]
  },
  "data": {
      "title": "My Type",
      "description": "Type Description",
      "allowed_content_types": [],
      "filter_content_types": false,
      "basic": false,
      "blocks": false,
      "categorization": false,
      "dates": false,
      "dublin_core": false,
      "exclude_from_nav": false,
      "ownership": false,
      "preview_image_link": false,
      "short_name": false,
      "versioning": false
  }
}

Reading a type with GET

After a successful POST, access the content type by sending a GET request to the endpoint /@controlpanels/dexterity-types/{type-id}:

GET /@controlpanels/dexterity-types/Page HTTP/1.1
Accept: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhZG1pbiIsImZ1bGxuYW1lIjoiQWRtaW4iLCJpYXQiOjE2NDkzMTI0NDl9.RS1Ny_r0v7vIylFfK6q0JVJrkiDuTOh9iG9IL8xbzAk

Or use the client directly:

import { Client } from '@robgietema/nick';

const cli = Client.initialize({ apiPath: 'http://localhost:8080' });
const login = await cli.login({
  data: { login: 'admin', password: 'admin' },
});

const { data } = await cli.getControlpanelType({
  token: login.data.token,
  path: '/@controlpanels/dexterity-types/Page',
});

Response:

HTTP/1.1 200 OK
Content-Type: application/json

{
  "@id": "http://localhost:8080/@controlpanels/dexterity-types/Page",
  "title": "Page",
  "description": "",
  "schema": {
    "fieldsets": [
      {
        "fields": [
          "title",
          "description",
          "allowed_content_types",
          "filter_content_types"
        ],
        "id": "default",
        "title": "Default"
      },
      {
        "fields": [
          "basic",
          "blocks",
          "categorization",
          "dates",
          "dublin_core",
          "exclude_from_nav",
          "ownership",
          "preview_image_link",
          "short_name",
          "versioning"
        ],
        "id": "behaviors",
        "title": "Behaviors"
      }
    ],
    "properties": {
      "allowed_content_types": {
        "additionalItems": true,
        "description": "",
        "factory": "Multiple Choice",
        "items": {
          "description": "",
          "factory": "Choice",
          "title": "",
          "type": "string",
          "vocabulary": {
            "@id": "http://localhost:8080/@vocabularies/types"
          }
        },
        "title": "Allowed Content Types",
        "type": "array",
        "uniqueItems": true
      },
      "description": {
        "description": "",
        "factory": "Text",
        "title": "Description",
        "type": "string",
        "widget": "textarea"
      },
      "filter_content_types": {
        "factory": "Yes/No",
        "title": "Filter Contained Types",
        "description": "Items of this type can act as a folder containing other items. What content types should be allowed inside?",
        "type": "boolean"
      },
      "title": {
        "description": "",
        "factory": "Text line (String)",
        "title": "Type Name",
        "type": "string"
      },
      "basic": {
        "description": "Adds title and description fields.",
        "factory": "Yes/No",
        "title": "Basic metadata",
        "type": "boolean"
      },
      "blocks": {
        "description": "Enables Volto Blocks support",
        "factory": "Yes/No",
        "title": "Blocks",
        "type": "boolean"
      },
      "categorization": {
        "description": "Adds keywords and language fields.",
        "factory": "Yes/No",
        "title": "Categorization",
        "type": "boolean"
      },
      "dates": {
        "description": "Adds effective and expiration dates.",
        "factory": "Yes/No",
        "title": "Dates",
        "type": "boolean"
      },
      "dublin_core": {
        "description": "Adds standard metadatafields",
        "factory": "Yes/No",
        "title": "Dublin Core metadata",
        "type": "boolean"
      },
      "exclude_from_nav": {
        "description": "If selected, this item will not appear in the navigation tree.",
        "factory": "Yes/No",
        "title": "Exclude from navigation",
        "type": "boolean"
      },
      "ownership": {
        "description": "Adds ownership and rights fields.",
        "factory": "Yes/No",
        "title": "Ownership",
        "type": "boolean"
      },
      "preview_image_link": {
        "description": "Gives the ability to rename an item from its edit form.",
        "factory": "Yes/No",
        "title": "Preview Image Link",
        "type": "boolean"
      },
      "short_name": {
        "description": "Gives the ability to rename an item from its edit form.",
        "factory": "Yes/No",
        "title": "Short name",
        "type": "boolean"
      },
      "versioning": {
        "description": "Versioning support",
        "factory": "Yes/No",
        "title": "Versioning",
        "type": "boolean"
      }
    },
    "required": [
      "title",
      "filter_content_types"
    ]
  },
  "data": {
    "title": "Page",
    "description": "",
    "allowed_content_types": [],
    "filter_content_types": false,
    "basic": false,
    "blocks": true,
    "categorization": false,
    "dates": true,
    "dublin_core": true,
    "exclude_from_nav": true,
    "ownership": false,
    "preview_image_link": false,
    "short_name": true,
    "versioning": true
  }
}

Updating a type with PATCH

To update an existing content type, send a PATCH request to the server. PATCH allows to provide just a subset of the resource, that is, the values you actually want to change:

PATCH /@controlpanels/dexterity-types/Page HTTP/1.1
Accept: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhZG1pbiIsImZ1bGxuYW1lIjoiQWRtaW4iLCJpYXQiOjE2NDkzMTI0NDl9.RS1Ny_r0v7vIylFfK6q0JVJrkiDuTOh9iG9IL8xbzAk
Content-Type: application/json

{
  "description": "Some Description",
  "preview_image_link": true
}

Or use the client directly:

import { Client } from '@robgietema/nick';

const cli = Client.initialize({ apiPath: 'http://localhost:8080' });
const login = await cli.login({
  data: { login: 'admin', password: 'admin' },
});

const { data } = await cli.updateControlpanelType({
  token: login.data.token,
  path: '/@controlpanels/dexterity-types/Page',
  data: {
    description: 'Some Description',
    preview_image_link: true,
  },
});

Response:

HTTP/1.1 204 No Content

Removing a type with DELETE

Delete an existing content type by sending a DELETE request to the URL of an existing content type:

DELETE /@controlpanels/dexterity-types/File HTTP/1.1
Accept: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhZG1pbiIsImZ1bGxuYW1lIjoiQWRtaW4iLCJpYXQiOjE2NDkzMTI0NDl9.RS1Ny_r0v7vIylFfK6q0JVJrkiDuTOh9iG9IL8xbzAk

Or use the client directly:

import { Client } from '@robgietema/nick';

const cli = Client.initialize({ apiPath: 'http://localhost:8080' });
const login = await cli.login({
  data: { login: 'admin', password: 'admin' },
});

const { data } = await cli.deleteControlpanelType({
  token: login.data.token,
  path: '/@controlpanels/dexterity-types/File',
});

Response:

HTTP/1.1 204 No Content

Content Rules

@controlpanels/content-rules is a custom control panel endpoint that will allow you to add, remove, and configure available Content Rules.

Reading or writing content rules require the Manage Site permission.

Verb URL Action
GET /@controlpanels/content-rules List configurable content rules
POST /@controlpanels/content-rules Creates a new content rule
GET /@controlpanels/content-rules/{rule-id} Get the current state of the content rule
PATCH /@controlpanels/content-rules/{rule-id} Update the content rule details
DELETE /@controlpanels/content-rules/{rule-id} Remove the content rule

Listing Content Types

To list the available content rules, send a GET request to @controlpanels/content-rules

GET /@controlpanels/content-rules HTTP/1.1
Accept: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhZG1pbiIsImZ1bGxuYW1lIjoiQWRtaW4iLCJpYXQiOjE2NDkzMTI0NDl9.RS1Ny_r0v7vIylFfK6q0JVJrkiDuTOh9iG9IL8xbzAk

Or use the client directly:

import { Client } from '@robgietema/nick';

const cli = Client.initialize({ apiPath: 'http://localhost:8080' });
const login = await cli.login({
  data: { login: 'admin', password: 'admin' },
});

const { data } = await cli.getControlpanelContentRules();

Response:

HTTP/1.1 200 OK
Content-Type: application/json

{
  "@id": "http://localhost:8080/@controlpanels/content-rules",
  "group": "Content",
  "title": "Content Rules",
  "items": [
    [
      {
        "@id": "http://localhost:8080/@controlpanels/content-rules/rule-1",
        "id": "rule-1",
        "title": "Content Rule 1",
        "description": "Description for Content Rule 1",
        "assigned": true,
        "enabled": false,
        "trigger": "onAfterAdd"
      },
      {
        "@id": "http://localhost:8080/@controlpanels/content-rules/rule-2",
        "id": "rule-2",
        "title": "Content Rule 2",
        "description": "Description for Content Rule 2",
        "assigned": false,
        "enabled": false,
        "trigger": "onAfterDelete"
      }
    ]
  ]
}

The following fields are returned:

  • @id: hypermedia link to the rule
  • id: actual id of the content rule
  • assigned: rule assigned or not
  • title: title of the rule
  • description: rule description
  • trigger: triggering event
  • conditions: conditions before triggering the rule
  • actions: actions to take place

Creating a new Content rule with POST

To create a new content rule, send a POST request to the /@controlpanels/content-rules endpoint:

POST /@controlpanels/content-rules HTTP/1.1
Accept: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhZG1pbiIsImZ1bGxuYW1lIjoiQWRtaW4iLCJpYXQiOjE2NDkzMTI0NDl9.RS1Ny_r0v7vIylFfK6q0JVJrkiDuTOh9iG9IL8xbzAk
Content-Type: application/json

{
  "title": "Content Rule 3",
  "description": "Description for Content Rule 3",
  "event": "onAfterModify",
  "cascading": false,
  "enabled": false,
  "stop": false
}

Or use the client directly:

import { Client } from '@robgietema/nick';

const cli = Client.initialize({ apiPath: 'http://localhost:8080' });
const login = await cli.login({
  data: { login: 'admin', password: 'admin' },
});

const { data } = await cli.createControlpanelContentRule({
  token: login.data.token,
  data: {
    title: 'Content Rule 3',
    description: 'Description for Content Rule 3',
    event: 'onAfterModify',
    cascading: false,
    enabled: false,
    stop: false,
  },
});

Response:

HTTP/1.1 201 Created
Content-Type: application/json

{
  "@id": "http://localhost:8080/@controlpanels/content-rules/content-rule-3",
  "id": "content-rule-3",
  "title": "Content Rule 3",
  "description": "Description for Content Rule 3",
  "assigned": false,
  "enabled": false,
  "trigger": "onAfterModify",
  "actions": [],
  "conditions": [],
  "cascading": false,
  "stop": false,
  "event": "onAfterModify",
  "addable_actions": [
    {
      "@schema": {
        "fieldsets": [
          {
            "fields": ["target_folder"],
            "id": "default",
            "title": "Default"
          }
        ],
        "properties": {
          "target_folder": {
            "description": "As a path relative to the portal root.",
            "factory": "Relation Choice",
            "title": "Target folder",
            "widget": "object_browser"
          }
        },
        "required": ["target_folder"],
        "type": "object"
      },
      "addview": "copy_item",
      "description": "Copy the triggering item to a specific folder",
      "title": "Copy to folder"
    },
    {
      "@schema": {
        "fieldsets": [
          {
            "fields": [],
            "id": "default",
            "title": "Default"
          }
        ],
        "properties": {},
        "required": [],
        "type": "object"
      },
      "addview": "delete_item",
      "description": "Delete the triggering item",
      "title": "Delete item"
    },
    {
      "@schema": {
        "fieldsets": [
          {
            "fields": ["message"],
            "id": "default",
            "title": "Default"
          }
        ],
        "properties": {
          "message": {
            "default": "",
            "description": "&e = the triggering event, &c = the context, &u = the user",
            "factory": "Text line (String)",
            "title": "Message",
            "type": "string"
          }
        },
        "required": ["message"],
        "type": "object"
      },
      "addview": "logger",
      "description": "Log a particular event",
      "title": "Logger"
    },
    {
      "@schema": {
        "fieldsets": [
          {
            "fields": ["target_folder"],
            "id": "default",
            "title": "Default"
          }
        ],
        "properties": {
          "target_folder": {
            "description": "As a path relative to the portal root.",
            "factory": "Relation Choice",
            "title": "Target folder",
            "widget": "object_browser"
          }
        },
        "required": ["target_folder"],
        "type": "object"
      },
      "addview": "move_item",
      "description": "Move the triggering item to a specific folder",
      "title": "Move to folder"
    },
    {
      "@schema": {
        "fieldsets": [
          {
            "fields": [
              "subject",
              "source",
              "recipients",
              "exclude_actor",
              "message"
            ],
            "id": "default",
            "title": "Default"
          }
        ],
        "properties": {
          "exclude_actor": {
            "description": "Do not send the email to the user that did the action.",
            "factory": "Yes/No",
            "title": "Exclude actor from recipients",
            "type": "boolean"
          },
          "message": {
            "description": "The message that you want to mail.",
            "factory": "Text",
            "title": "Message",
            "type": "string",
            "widget": "textarea"
          },
          "recipients": {
            "description": "The email where you want to send this message. To send it to different email addresses, just separate them with ,",
            "factory": "Text line (String)",
            "title": "Email recipients",
            "type": "string"
          },
          "source": {
            "description": "The email address that sends the email. If no email is provided here, it will use the portal from address.",
            "factory": "Text line (String)",
            "title": "Email source",
            "type": "string"
          },
          "subject": {
            "description": "Subject of the message",
            "factory": "Text line (String)",
            "title": "Subject",
            "type": "string"
          }
        },
        "required": ["subject", "recipients", "message"],
        "type": "object"
      },
      "addview": "send_email",
      "description": "Send an email on the triggering object",
      "title": "Send email"
    },
    {
      "@schema": {
        "fieldsets": [
          {
            "fields": ["transition"],
            "id": "default",
            "title": "Default"
          }
        ],
        "properties": {
          "transition": {
            "description": "Select the workflow transition to attempt",
            "factory": "Choice",
            "title": "Transition",
            "type": "string",
            "vocabulary": {
              "@id": "workflowTransitions"
            }
          }
        },
        "required": ["transition"],
        "type": "object"
      },
      "addview": "transition_workflow",
      "description": "Perform a workflow transition on the triggering object",
      "title": "Transition workflow state"
    },
    {
      "@schema": {
        "fieldsets": [
          {
            "fields": ["comment"],
            "id": "default",
            "title": "Default"
          }
        ],
        "properties": {
          "comment": {
            "description": "The comment added to the history while versioning the content.",
            "factory": "Text line (String)",
            "title": "Comment",
            "type": "string"
          }
        },
        "required": [],
        "type": "object"
      },
      "addview": "version_item",
      "description": "Store a new version of the item",
      "title": "Version item"
    }
  ],
  "addable_conditions": [
    {
      "@schema": {
        "fieldsets": [
          {
            "fields": ["check_types"],
            "id": "default",
            "title": "Default"
          }
        ],
        "properties": {
          "check_types": {
            "additionalItems": true,
            "description": "The content type to check for.",
            "factory": "Multiple Choice",
            "items": {
              "description": "",
              "factory": "Choice",
              "title": "",
              "type": "string",
              "vocabulary": {
                "@id": "types"
              }
            },
            "title": "Content type",
            "type": "array",
            "uniqueItems": true
          }
        },
        "required": ["check_types"],
        "type": "object"
      },
      "addview": "content_type",
      "description": "Apply only when the current content object is of a particular type",
      "title": "Content type"
    },
    {
      "@schema": {
        "fieldsets": [
          {
            "fields": ["file_extension"],
            "id": "default",
            "title": "Default"
          }
        ],
        "properties": {
          "file_extension": {
            "description": "The file extension to check for",
            "factory": "Text line (String)",
            "title": "File extension",
            "type": "string"
          }
        },
        "required": ["file_extension"],
        "type": "object"
      },
      "addview": "file_extension",
      "description": "Apply only to a particular file extension",
      "title": "File Extension"
    },
    {
      "@schema": {
        "fieldsets": [
          {
            "fields": ["group_names"],
            "id": "default",
            "title": "Default"
          }
        ],
        "properties": {
          "group_names": {
            "additionalItems": true,
            "description": "The name of the group.",
            "factory": "Multiple Choice",
            "items": {
              "description": "",
              "factory": "Choice",
              "title": "",
              "type": "string",
              "vocabulary": {
                "@id": "groups"
              }
            },
            "title": "Group name",
            "type": "array",
            "uniqueItems": true
          }
        },
        "required": ["group_names"],
        "type": "object"
      },
      "addview": "user_group",
      "description": "Apply only when the current user is in the given group",
      "title": "User’s group"
    },
    {
      "@schema": {
        "fieldsets": [
          {
            "fields": ["role_names"],
            "id": "default",
            "title": "Default"
          }
        ],
        "properties": {
          "role_names": {
            "additionalItems": true,
            "description": "The roles to check for.",
            "factory": "Multiple Choice",
            "items": {
              "description": "",
              "factory": "Choice",
              "title": "",
              "type": "string",
              "vocabulary": {
                "@id": "roles"
              }
            },
            "title": "Roles",
            "type": "array",
            "uniqueItems": true
          }
        },
        "required": ["role_names"],
        "type": "object"
      },
      "addview": "user_role",
      "description": "Apply only when the current user has the given role",
      "title": "User’s role"
    },
    {
      "@schema": {
        "fieldsets": [
          {
            "fields": ["wf_states"],
            "id": "default",
            "title": "Default"
          }
        ],
        "properties": {
          "wf_states": {
            "additionalItems": true,
            "description": "The workflow states to check for.",
            "factory": "Multiple Choice",
            "items": {
              "description": "",
              "factory": "Choice",
              "title": "",
              "type": "string",
              "vocabulary": {
                "@id": "workflowStates"
              }
            },
            "title": "Workflow state",
            "type": "array",
            "uniqueItems": true
          }
        },
        "required": ["wf_states"],
        "type": "object"
      },
      "addview": "workflow_state",
      "description": "Apply only to a objects in a particular workflow state",
      "title": "Workflow state"
    }
  ],
  "assignments": []
}

Creating a new Condition on a Content rule with POST

To create a new condition on a content rule, send a POST request to the /@controlpanels/content-rules/{rule-id}/condition endpoint:

POST /@controlpanels/content-rules/rule-1/condition HTTP/1.1
Accept: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhZG1pbiIsImZ1bGxuYW1lIjoiQWRtaW4iLCJpYXQiOjE2NDkzMTI0NDl9.RS1Ny_r0v7vIylFfK6q0JVJrkiDuTOh9iG9IL8xbzAk
Content-Type: application/json

{
  "file_extension": "jpg",
  "type": "file_extension"
}

Or use the client directly:

import { Client } from '@robgietema/nick';

const cli = Client.initialize({ apiPath: 'http://localhost:8080' });
const login = await cli.login({
  data: { login: 'admin', password: 'admin' },
});

const { data } = await cli.createControlpanelContentRuleCondition({
  token: login.data.token,
  data: {
    file_extension: 'jpg',
    type: 'file_extension',
  },
});

Response:

HTTP/1.1 201 Created
Content-Type: application/json

{
  "@id": "http://localhost:8080/@controlpanels/content-rules/rule-1",
  "id": "rule-1",
  "title": "Content Rule 1",
  "description": "Description for Content Rule 1",
  "assigned": true,
  "enabled": false,
  "trigger": "onAfterAdd",
  "actions": [
    {
      "idx": 0,
      "title": "Transition workflow state",
      "description": "Perform a workflow transition on the triggering object",
      "summary": "Execute transition publish",
      "first": true,
      "last": false
    },
    {
      "idx": 1,
      "title": "Logger",
      "description": "Log a particular event",
      "summary": "Log message Test message",
      "first": false,
      "last": true
    }
  ],
  "conditions": [
    {
      "idx": 0,
      "title": "File Extension",
      "description": "Apply only to a particular file extension",
      "summary": "File extension is jpg",
      "first": true,
      "last": false
    },
    {
      "idx": 1,
      "title": "Workflow state",
      "description": "Apply only to a objects in a particular workflow state",
      "summary": "Workflow states are: private",
      "first": false,
      "last": false
    },
    {
      "idx": 2,
      "title": "File Extension",
      "description": "Apply only to a particular file extension",
      "summary": "File extension is jpg",
      "first": false,
      "last": true
    }
  ],
  "cascading": false,
  "stop": false,
  "event": "onAfterAdd",
  "addable_actions": [
    {
      "addview": "copy_item",
      "title": "Copy to folder",
      "description": "Copy the triggering item to a specific folder",
      "@schema": {
        "fieldsets": [
          {
            "fields": ["target_folder"],
            "id": "default",
            "title": "Default"
          }
        ],
        "properties": {
          "target_folder": {
            "description": "As a path relative to the portal root.",
            "title": "Target folder",
            "widget": "object_browser",
            "factory": "Relation Choice"
          }
        },
        "required": ["target_folder"],
        "type": "object"
      }
    },
    {
      "addview": "delete_item",
      "title": "Delete item",
      "description": "Delete the triggering item",
      "@schema": {
        "fieldsets": [
          {
            "fields": [],
            "id": "default",
            "title": "Default"
          }
        ],
        "properties": {},
        "required": [],
        "type": "object"
      }
    },
    {
      "addview": "logger",
      "title": "Logger",
      "description": "Log a particular event",
      "@schema": {
        "fieldsets": [
          {
            "fields": ["message"],
            "id": "default",
            "title": "Default"
          }
        ],
        "properties": {
          "message": {
            "default": "",
            "description": "&e = the triggering event, &c = the context, &u = the user",
            "factory": "Text line (String)",
            "title": "Message",
            "type": "string"
          }
        },
        "required": ["message"],
        "type": "object"
      }
    },
    {
      "addview": "move_item",
      "title": "Move to folder",
      "description": "Move the triggering item to a specific folder",
      "@schema": {
        "fieldsets": [
          {
            "fields": ["target_folder"],
            "id": "default",
            "title": "Default"
          }
        ],
        "properties": {
          "target_folder": {
            "description": "As a path relative to the portal root.",
            "title": "Target folder",
            "widget": "object_browser",
            "factory": "Relation Choice"
          }
        },
        "required": ["target_folder"],
        "type": "object"
      }
    },
    {
      "addview": "send_email",
      "title": "Send email",
      "description": "Send an email on the triggering object",
      "@schema": {
        "fieldsets": [
          {
            "fields": [
              "subject",
              "source",
              "recipients",
              "exclude_actor",
              "message"
            ],
            "id": "default",
            "title": "Default"
          }
        ],
        "properties": {
          "exclude_actor": {
            "description": "Do not send the email to the user that did the action.",
            "factory": "Yes/No",
            "title": "Exclude actor from recipients",
            "type": "boolean"
          },
          "message": {
            "description": "The message that you want to mail.",
            "factory": "Text",
            "title": "Message",
            "type": "string",
            "widget": "textarea"
          },
          "recipients": {
            "description": "The email where you want to send this message. To send it to different email addresses, just separate them with ,",
            "factory": "Text line (String)",
            "title": "Email recipients",
            "type": "string"
          },
          "source": {
            "description": "The email address that sends the email. If no email is provided here, it will use the portal from address.",
            "factory": "Text line (String)",
            "title": "Email source",
            "type": "string"
          },
          "subject": {
            "description": "Subject of the message",
            "factory": "Text line (String)",
            "title": "Subject",
            "type": "string"
          }
        },
        "required": ["subject", "recipients", "message"],
        "type": "object"
      }
    },
    {
      "addview": "transition_workflow",
      "title": "Transition workflow state",
      "description": "Perform a workflow transition on the triggering object",
      "@schema": {
        "fieldsets": [
          {
            "fields": ["transition"],
            "id": "default",
            "title": "Default"
          }
        ],
        "properties": {
          "transition": {
            "description": "Select the workflow transition to attempt",
            "factory": "Choice",
            "title": "Transition",
            "type": "string",
            "vocabulary": {
              "@id": "workflowTransitions"
            }
          }
        },
        "required": ["transition"],
        "type": "object"
      }
    },
    {
      "addview": "version_item",
      "title": "Version item",
      "description": "Store a new version of the item",
      "@schema": {
        "fieldsets": [
          {
            "fields": ["comment"],
            "id": "default",
            "title": "Default"
          }
        ],
        "properties": {
          "comment": {
            "description": "The comment added to the history while versioning the content.",
            "factory": "Text line (String)",
            "title": "Comment",
            "type": "string"
          }
        },
        "required": [],
        "type": "object"
      }
    }
  ],
  "addable_conditions": [
    {
      "addview": "content_type",
      "title": "Content type",
      "description": "Apply only when the current content object is of a particular type",
      "@schema": {
        "fieldsets": [
          {
            "fields": ["check_types"],
            "id": "default",
            "title": "Default"
          }
        ],
        "properties": {
          "check_types": {
            "additionalItems": true,
            "description": "The content type to check for.",
            "factory": "Multiple Choice",
            "items": {
              "description": "",
              "factory": "Choice",
              "title": "",
              "type": "string",
              "vocabulary": {
                "@id": "types"
              }
            },
            "title": "Content type",
            "type": "array",
            "uniqueItems": true
          }
        },
        "required": ["check_types"],
        "type": "object"
      }
    },
    {
      "addview": "file_extension",
      "title": "File Extension",
      "description": "Apply only to a particular file extension",
      "@schema": {
        "fieldsets": [
          {
            "fields": ["file_extension"],
            "id": "default",
            "title": "Default"
          }
        ],
        "properties": {
          "file_extension": {
            "description": "The file extension to check for",
            "factory": "Text line (String)",
            "title": "File extension",
            "type": "string"
          }
        },
        "required": ["file_extension"],
        "type": "object"
      }
    },
    {
      "addview": "user_group",
      "title": "User’s group",
      "description": "Apply only when the current user is in the given group",
      "@schema": {
        "fieldsets": [
          {
            "fields": ["group_names"],
            "id": "default",
            "title": "Default"
          }
        ],
        "properties": {
          "group_names": {
            "additionalItems": true,
            "description": "The name of the group.",
            "factory": "Multiple Choice",
            "items": {
              "description": "",
              "factory": "Choice",
              "title": "",
              "type": "string",
              "vocabulary": {
                "@id": "groups"
              }
            },
            "title": "Group name",
            "type": "array",
            "uniqueItems": true
          }
        },
        "required": ["group_names"],
        "type": "object"
      }
    },
    {
      "addview": "user_role",
      "title": "User’s role",
      "description": "Apply only when the current user has the given role",
      "@schema": {
        "fieldsets": [
          {
            "fields": ["role_names"],
            "id": "default",
            "title": "Default"
          }
        ],
        "properties": {
          "role_names": {
            "additionalItems": true,
            "description": "The roles to check for.",
            "factory": "Multiple Choice",
            "items": {
              "description": "",
              "factory": "Choice",
              "title": "",
              "type": "string",
              "vocabulary": {
                "@id": "roles"
              }
            },
            "title": "Roles",
            "type": "array",
            "uniqueItems": true
          }
        },
        "required": ["role_names"],
        "type": "object"
      }
    },
    {
      "addview": "workflow_state",
      "title": "Workflow state",
      "description": "Apply only to a objects in a particular workflow state",
      "@schema": {
        "fieldsets": [
          {
            "fields": ["wf_states"],
            "id": "default",
            "title": "Default"
          }
        ],
        "properties": {
          "wf_states": {
            "additionalItems": true,
            "description": "The workflow states to check for.",
            "factory": "Multiple Choice",
            "items": {
              "description": "",
              "factory": "Choice",
              "title": "",
              "type": "string",
              "vocabulary": {
                "@id": "workflowStates"
              }
            },
            "title": "Workflow state",
            "type": "array",
            "uniqueItems": true
          }
        },
        "required": ["wf_states"],
        "type": "object"
      }
    }
  ],
  "assignments": [
    {
      "description": "",
      "title": "Events",
      "url": "http://localhost:8080/events"
    }
  ]
}

Creating a new Action on a Content rule with POST

To create a new action on a content rule, send a POST request to the /@controlpanels/content-rules/{rule-id}/action endpoint:

POST /@controlpanels/content-rules/rule-1/action HTTP/1.1
Accept: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhZG1pbiIsImZ1bGxuYW1lIjoiQWRtaW4iLCJpYXQiOjE2NDkzMTI0NDl9.RS1Ny_r0v7vIylFfK6q0JVJrkiDuTOh9iG9IL8xbzAk
Content-Type: application/json

{
  "type": "logger",
  "message": "Test message"
}

Or use the client directly:

import { Client } from '@robgietema/nick';

const cli = Client.initialize({ apiPath: 'http://localhost:8080' });
const login = await cli.login({
  data: { login: 'admin', password: 'admin' },
});

const { data } = await cli.createControlpanelContentRuleAction({
  token: login.data.token,
  data: {
    type: 'logger',
    message: 'Test message',
  },
});

Response:

HTTP/1.1 201 Created
Content-Type: application/json

{
  "@id": "http://localhost:8080/@controlpanels/content-rules/rule-1",
  "id": "rule-1",
  "title": "Content Rule 1",
  "description": "Description for Content Rule 1",
  "assigned": true,
  "enabled": false,
  "trigger": "onAfterAdd",
  "actions": [
    {
      "idx": 0,
      "title": "Transition workflow state",
      "description": "Perform a workflow transition on the triggering object",
      "summary": "Execute transition publish",
      "first": true,
      "last": false
    },
    {
      "idx": 1,
      "title": "Logger",
      "description": "Log a particular event",
      "summary": "Log message Test message",
      "first": false,
      "last": false
    },
    {
      "idx": 2,
      "title": "Logger",
      "description": "Log a particular event",
      "summary": "Log message Test message",
      "first": false,
      "last": true
    }
  ],
  "conditions": [
    {
      "idx": 0,
      "title": "File Extension",
      "description": "Apply only to a particular file extension",
      "summary": "File extension is jpg",
      "first": true,
      "last": false
    },
    {
      "idx": 1,
      "title": "Workflow state",
      "description": "Apply only to a objects in a particular workflow state",
      "summary": "Workflow states are: private",
      "first": false,
      "last": true
    }
  ],
  "cascading": false,
  "stop": false,
  "event": "onAfterAdd",
  "addable_actions": [
    {
      "addview": "copy_item",
      "title": "Copy to folder",
      "description": "Copy the triggering item to a specific folder",
      "@schema": {
        "fieldsets": [
          {
            "fields": ["target_folder"],
            "id": "default",
            "title": "Default"
          }
        ],
        "properties": {
          "target_folder": {
            "description": "As a path relative to the portal root.",
            "title": "Target folder",
            "widget": "object_browser",
            "factory": "Relation Choice"
          }
        },
        "required": ["target_folder"],
        "type": "object"
      }
    },
    {
      "addview": "delete_item",
      "title": "Delete item",
      "description": "Delete the triggering item",
      "@schema": {
        "fieldsets": [
          {
            "fields": [],
            "id": "default",
            "title": "Default"
          }
        ],
        "properties": {},
        "required": [],
        "type": "object"
      }
    },
    {
      "addview": "logger",
      "title": "Logger",
      "description": "Log a particular event",
      "@schema": {
        "fieldsets": [
          {
            "fields": ["message"],
            "id": "default",
            "title": "Default"
          }
        ],
        "properties": {
          "message": {
            "default": "",
            "description": "&e = the triggering event, &c = the context, &u = the user",
            "factory": "Text line (String)",
            "title": "Message",
            "type": "string"
          }
        },
        "required": ["message"],
        "type": "object"
      }
    },
    {
      "addview": "move_item",
      "title": "Move to folder",
      "description": "Move the triggering item to a specific folder",
      "@schema": {
        "fieldsets": [
          {
            "fields": ["target_folder"],
            "id": "default",
            "title": "Default"
          }
        ],
        "properties": {
          "target_folder": {
            "description": "As a path relative to the portal root.",
            "title": "Target folder",
            "widget": "object_browser",
            "factory": "Relation Choice"
          }
        },
        "required": ["target_folder"],
        "type": "object"
      }
    },
    {
      "addview": "send_email",
      "title": "Send email",
      "description": "Send an email on the triggering object",
      "@schema": {
        "fieldsets": [
          {
            "fields": [
              "subject",
              "source",
              "recipients",
              "exclude_actor",
              "message"
            ],
            "id": "default",
            "title": "Default"
          }
        ],
        "properties": {
          "exclude_actor": {
            "description": "Do not send the email to the user that did the action.",
            "factory": "Yes/No",
            "title": "Exclude actor from recipients",
            "type": "boolean"
          },
          "message": {
            "description": "The message that you want to mail.",
            "factory": "Text",
            "title": "Message",
            "type": "string",
            "widget": "textarea"
          },
          "recipients": {
            "description": "The email where you want to send this message. To send it to different email addresses, just separate them with ,",
            "factory": "Text line (String)",
            "title": "Email recipients",
            "type": "string"
          },
          "source": {
            "description": "The email address that sends the email. If no email is provided here, it will use the portal from address.",
            "factory": "Text line (String)",
            "title": "Email source",
            "type": "string"
          },
          "subject": {
            "description": "Subject of the message",
            "factory": "Text line (String)",
            "title": "Subject",
            "type": "string"
          }
        },
        "required": ["subject", "recipients", "message"],
        "type": "object"
      }
    },
    {
      "addview": "transition_workflow",
      "title": "Transition workflow state",
      "description": "Perform a workflow transition on the triggering object",
      "@schema": {
        "fieldsets": [
          {
            "fields": ["transition"],
            "id": "default",
            "title": "Default"
          }
        ],
        "properties": {
          "transition": {
            "description": "Select the workflow transition to attempt",
            "factory": "Choice",
            "title": "Transition",
            "type": "string",
            "vocabulary": {
              "@id": "workflowTransitions"
            }
          }
        },
        "required": ["transition"],
        "type": "object"
      }
    },
    {
      "addview": "version_item",
      "title": "Version item",
      "description": "Store a new version of the item",
      "@schema": {
        "fieldsets": [
          {
            "fields": ["comment"],
            "id": "default",
            "title": "Default"
          }
        ],
        "properties": {
          "comment": {
            "description": "The comment added to the history while versioning the content.",
            "factory": "Text line (String)",
            "title": "Comment",
            "type": "string"
          }
        },
        "required": [],
        "type": "object"
      }
    }
  ],
  "addable_conditions": [
    {
      "addview": "content_type",
      "title": "Content type",
      "description": "Apply only when the current content object is of a particular type",
      "@schema": {
        "fieldsets": [
          {
            "fields": ["check_types"],
            "id": "default",
            "title": "Default"
          }
        ],
        "properties": {
          "check_types": {
            "additionalItems": true,
            "description": "The content type to check for.",
            "factory": "Multiple Choice",
            "items": {
              "description": "",
              "factory": "Choice",
              "title": "",
              "type": "string",
              "vocabulary": {
                "@id": "types"
              }
            },
            "title": "Content type",
            "type": "array",
            "uniqueItems": true
          }
        },
        "required": ["check_types"],
        "type": "object"
      }
    },
    {
      "addview": "file_extension",
      "title": "File Extension",
      "description": "Apply only to a particular file extension",
      "@schema": {
        "fieldsets": [
          {
            "fields": ["file_extension"],
            "id": "default",
            "title": "Default"
          }
        ],
        "properties": {
          "file_extension": {
            "description": "The file extension to check for",
            "factory": "Text line (String)",
            "title": "File extension",
            "type": "string"
          }
        },
        "required": ["file_extension"],
        "type": "object"
      }
    },
    {
      "addview": "user_group",
      "title": "User’s group",
      "description": "Apply only when the current user is in the given group",
      "@schema": {
        "fieldsets": [
          {
            "fields": ["group_names"],
            "id": "default",
            "title": "Default"
          }
        ],
        "properties": {
          "group_names": {
            "additionalItems": true,
            "description": "The name of the group.",
            "factory": "Multiple Choice",
            "items": {
              "description": "",
              "factory": "Choice",
              "title": "",
              "type": "string",
              "vocabulary": {
                "@id": "groups"
              }
            },
            "title": "Group name",
            "type": "array",
            "uniqueItems": true
          }
        },
        "required": ["group_names"],
        "type": "object"
      }
    },
    {
      "addview": "user_role",
      "title": "User’s role",
      "description": "Apply only when the current user has the given role",
      "@schema": {
        "fieldsets": [
          {
            "fields": ["role_names"],
            "id": "default",
            "title": "Default"
          }
        ],
        "properties": {
          "role_names": {
            "additionalItems": true,
            "description": "The roles to check for.",
            "factory": "Multiple Choice",
            "items": {
              "description": "",
              "factory": "Choice",
              "title": "",
              "type": "string",
              "vocabulary": {
                "@id": "roles"
              }
            },
            "title": "Roles",
            "type": "array",
            "uniqueItems": true
          }
        },
        "required": ["role_names"],
        "type": "object"
      }
    },
    {
      "addview": "workflow_state",
      "title": "Workflow state",
      "description": "Apply only to a objects in a particular workflow state",
      "@schema": {
        "fieldsets": [
          {
            "fields": ["wf_states"],
            "id": "default",
            "title": "Default"
          }
        ],
        "properties": {
          "wf_states": {
            "additionalItems": true,
            "description": "The workflow states to check for.",
            "factory": "Multiple Choice",
            "items": {
              "description": "",
              "factory": "Choice",
              "title": "",
              "type": "string",
              "vocabulary": {
                "@id": "workflowStates"
              }
            },
            "title": "Workflow state",
            "type": "array",
            "uniqueItems": true
          }
        },
        "required": ["wf_states"],
        "type": "object"
      }
    }
  ],
  "assignments": [
    {
      "description": "",
      "title": "Events",
      "url": "http://localhost:8080/events"
    }
  ]
}

Reading a Content rule with GET

After a successful POST, access the content rule by sending a GET request to the endpoint /@controlpanels/content-rules/{rule-id}:

GET /@controlpanels/content-rules/rule-1 HTTP/1.1
Accept: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhZG1pbiIsImZ1bGxuYW1lIjoiQWRtaW4iLCJpYXQiOjE2NDkzMTI0NDl9.RS1Ny_r0v7vIylFfK6q0JVJrkiDuTOh9iG9IL8xbzAk

Or use the client directly:

import { Client } from '@robgietema/nick';

const cli = Client.initialize({ apiPath: 'http://localhost:8080' });
const login = await cli.login({
  data: { login: 'admin', password: 'admin' },
});

const { data } = await cli.getControlpanelContentRule({
  token: login.data.token,
  path: '/@controlpanels/content-rules/rule-1',
});

Response:

HTTP/1.1 200 OK
Content-Type: application/json

{
  "@id": "http://localhost:8080/@controlpanels/content-rules/rule-1",
  "id": "rule-1",
  "title": "Content Rule 1",
  "description": "Description for Content Rule 1",
  "assigned": true,
  "enabled": false,
  "trigger": "onAfterAdd",
  "actions": [
    {
      "description": "Perform a workflow transition on the triggering object",
      "first": true,
      "idx": 0,
      "last": false,
      "summary": "Execute transition publish",
      "title": "Transition workflow state"
    },
    {
      "description": "Log a particular event",
      "first": false,
      "idx": 1,
      "last": true,
      "summary": "Log message Test message",
      "title": "Logger"
    }
  ],
  "conditions": [
    {
      "description": "Apply only to a particular file extension",
      "first": true,
      "idx": 0,
      "last": false,
      "summary": "File extension is jpg",
      "title": "File Extension"
    },
    {
      "description": "Apply only to a objects in a particular workflow state",
      "first": false,
      "idx": 1,
      "last": true,
      "summary": "Workflow states are: private",
      "title": "Workflow state"
    }
  ],
  "cascading": false,
  "stop": false,
  "event": "onAfterAdd",
  "addable_actions": [
    {
      "@schema": {
        "fieldsets": [
          {
            "fields": ["target_folder"],
            "id": "default",
            "title": "Default"
          }
        ],
        "properties": {
          "target_folder": {
            "description": "As a path relative to the portal root.",
            "factory": "Relation Choice",
            "title": "Target folder",
            "widget": "object_browser"
          }
        },
        "required": ["target_folder"],
        "type": "object"
      },
      "addview": "copy_item",
      "description": "Copy the triggering item to a specific folder",
      "title": "Copy to folder"
    },
    {
      "@schema": {
        "fieldsets": [
          {
            "fields": [],
            "id": "default",
            "title": "Default"
          }
        ],
        "properties": {},
        "required": [],
        "type": "object"
      },
      "addview": "delete_item",
      "description": "Delete the triggering item",
      "title": "Delete item"
    },
    {
      "@schema": {
        "fieldsets": [
          {
            "fields": ["message"],
            "id": "default",
            "title": "Default"
          }
        ],
        "properties": {
          "message": {
            "default": "",
            "description": "&e = the triggering event, &c = the context, &u = the user",
            "factory": "Text line (String)",
            "title": "Message",
            "type": "string"
          }
        },
        "required": ["message"],
        "type": "object"
      },
      "addview": "logger",
      "description": "Log a particular event",
      "title": "Logger"
    },
    {
      "@schema": {
        "fieldsets": [
          {
            "fields": ["target_folder"],
            "id": "default",
            "title": "Default"
          }
        ],
        "properties": {
          "target_folder": {
            "description": "As a path relative to the portal root.",
            "factory": "Relation Choice",
            "title": "Target folder",
            "widget": "object_browser"
          }
        },
        "required": ["target_folder"],
        "type": "object"
      },
      "addview": "move_item",
      "description": "Move the triggering item to a specific folder",
      "title": "Move to folder"
    },
    {
      "@schema": {
        "fieldsets": [
          {
            "fields": [
              "subject",
              "source",
              "recipients",
              "exclude_actor",
              "message"
            ],
            "id": "default",
            "title": "Default"
          }
        ],
        "properties": {
          "exclude_actor": {
            "description": "Do not send the email to the user that did the action.",
            "factory": "Yes/No",
            "title": "Exclude actor from recipients",
            "type": "boolean"
          },
          "message": {
            "description": "The message that you want to mail.",
            "factory": "Text",
            "title": "Message",
            "type": "string",
            "widget": "textarea"
          },
          "recipients": {
            "description": "The email where you want to send this message. To send it to different email addresses, just separate them with ,",
            "factory": "Text line (String)",
            "title": "Email recipients",
            "type": "string"
          },
          "source": {
            "description": "The email address that sends the email. If no email is provided here, it will use the portal from address.",
            "factory": "Text line (String)",
            "title": "Email source",
            "type": "string"
          },
          "subject": {
            "description": "Subject of the message",
            "factory": "Text line (String)",
            "title": "Subject",
            "type": "string"
          }
        },
        "required": ["subject", "recipients", "message"],
        "type": "object"
      },
      "addview": "send_email",
      "description": "Send an email on the triggering object",
      "title": "Send email"
    },
    {
      "@schema": {
        "fieldsets": [
          {
            "fields": ["transition"],
            "id": "default",
            "title": "Default"
          }
        ],
        "properties": {
          "transition": {
            "description": "Select the workflow transition to attempt",
            "factory": "Choice",
            "title": "Transition",
            "type": "string",
            "vocabulary": {
              "@id": "workflowTransitions"
            }
          }
        },
        "required": ["transition"],
        "type": "object"
      },
      "addview": "transition_workflow",
      "description": "Perform a workflow transition on the triggering object",
      "title": "Transition workflow state"
    },
    {
      "@schema": {
        "fieldsets": [
          {
            "fields": ["comment"],
            "id": "default",
            "title": "Default"
          }
        ],
        "properties": {
          "comment": {
            "description": "The comment added to the history while versioning the content.",
            "factory": "Text line (String)",
            "title": "Comment",
            "type": "string"
          }
        },
        "required": [],
        "type": "object"
      },
      "addview": "version_item",
      "description": "Store a new version of the item",
      "title": "Version item"
    }
  ],
  "addable_conditions": [
    {
      "@schema": {
        "fieldsets": [
          {
            "fields": ["check_types"],
            "id": "default",
            "title": "Default"
          }
        ],
        "properties": {
          "check_types": {
            "additionalItems": true,
            "description": "The content type to check for.",
            "factory": "Multiple Choice",
            "items": {
              "description": "",
              "factory": "Choice",
              "title": "",
              "type": "string",
              "vocabulary": {
                "@id": "types"
              }
            },
            "title": "Content type",
            "type": "array",
            "uniqueItems": true
          }
        },
        "required": ["check_types"],
        "type": "object"
      },
      "addview": "content_type",
      "description": "Apply only when the current content object is of a particular type",
      "title": "Content type"
    },
    {
      "@schema": {
        "fieldsets": [
          {
            "fields": ["file_extension"],
            "id": "default",
            "title": "Default"
          }
        ],
        "properties": {
          "file_extension": {
            "description": "The file extension to check for",
            "factory": "Text line (String)",
            "title": "File extension",
            "type": "string"
          }
        },
        "required": ["file_extension"],
        "type": "object"
      },
      "addview": "file_extension",
      "description": "Apply only to a particular file extension",
      "title": "File Extension"
    },
    {
      "@schema": {
        "fieldsets": [
          {
            "fields": ["group_names"],
            "id": "default",
            "title": "Default"
          }
        ],
        "properties": {
          "group_names": {
            "additionalItems": true,
            "description": "The name of the group.",
            "factory": "Multiple Choice",
            "items": {
              "description": "",
              "factory": "Choice",
              "title": "",
              "type": "string",
              "vocabulary": {
                "@id": "groups"
              }
            },
            "title": "Group name",
            "type": "array",
            "uniqueItems": true
          }
        },
        "required": ["group_names"],
        "type": "object"
      },
      "addview": "user_group",
      "description": "Apply only when the current user is in the given group",
      "title": "User’s group"
    },
    {
      "@schema": {
        "fieldsets": [
          {
            "fields": ["role_names"],
            "id": "default",
            "title": "Default"
          }
        ],
        "properties": {
          "role_names": {
            "additionalItems": true,
            "description": "The roles to check for.",
            "factory": "Multiple Choice",
            "items": {
              "description": "",
              "factory": "Choice",
              "title": "",
              "type": "string",
              "vocabulary": {
                "@id": "roles"
              }
            },
            "title": "Roles",
            "type": "array",
            "uniqueItems": true
          }
        },
        "required": ["role_names"],
        "type": "object"
      },
      "addview": "user_role",
      "description": "Apply only when the current user has the given role",
      "title": "User’s role"
    },
    {
      "@schema": {
        "fieldsets": [
          {
            "fields": ["wf_states"],
            "id": "default",
            "title": "Default"
          }
        ],
        "properties": {
          "wf_states": {
            "additionalItems": true,
            "description": "The workflow states to check for.",
            "factory": "Multiple Choice",
            "items": {
              "description": "",
              "factory": "Choice",
              "title": "",
              "type": "string",
              "vocabulary": {
                "@id": "workflowStates"
              }
            },
            "title": "Workflow state",
            "type": "array",
            "uniqueItems": true
          }
        },
        "required": ["wf_states"],
        "type": "object"
      },
      "addview": "workflow_state",
      "description": "Apply only to a objects in a particular workflow state",
      "title": "Workflow state"
    }
  ],
  "assignments": [
    {
      "description": "",
      "title": "Events",
      "url": "http://localhost:8080/events"
    }
  ]
}

Updating a Content rule with PATCH

To update an existing content rule, send a PATCH request to the server. PATCH allows to provide just a subset of the resource, that is, the values you actually want to change:

PATCH /@controlpanels/content-rules/rule-1 HTTP/1.1
Accept: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhZG1pbiIsImZ1bGxuYW1lIjoiQWRtaW4iLCJpYXQiOjE2NDkzMTI0NDl9.RS1Ny_r0v7vIylFfK6q0JVJrkiDuTOh9iG9IL8xbzAk
Content-Type: application/json

{
  "title": "New Content Rule 1",
  "description": "Description for Content Rule 1",
  "event": "onAfterModify",
  "cascading": false,
  "enabled": false,
  "stop": false
}

Or use the client directly:

import { Client } from '@robgietema/nick';

const cli = Client.initialize({ apiPath: 'http://localhost:8080' });
const login = await cli.login({
  data: { login: 'admin', password: 'admin' },
});

const { data } = await cli.updateControlpanelContentRule({
  token: login.data.token,
  path: '/@controlpanels/content-rules/rule-1',
  data: {
    title: 'New Content Rule 1',
    description: 'Description for Content Rule 1',
    event: 'onAfterModify',
    cascading: false,
    enabled: false,
    stop: false,
  },
});

Response:

HTTP/1.1 204 No Content

Updating a Condition on a Content rule with PATCH

To update an existing condition on a content rule, send a PATCH request to the server. PATCH allows to provide just a subset of the resource, that is, the values you actually want to change:

PATCH /@controlpanels/content-rules/rule-1/condition/0 HTTP/1.1
Accept: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhZG1pbiIsImZ1bGxuYW1lIjoiQWRtaW4iLCJpYXQiOjE2NDkzMTI0NDl9.RS1Ny_r0v7vIylFfK6q0JVJrkiDuTOh9iG9IL8xbzAk
Content-Type: application/json

{
  "file_extension": "png"
}

Or use the client directly:

import { Client } from '@robgietema/nick';

const cli = Client.initialize({ apiPath: 'http://localhost:8080' });
const login = await cli.login({
  data: { login: 'admin', password: 'admin' },
});

const { data } = await cli.updateControlpanelContentRuleCondition({
  token: login.data.token,
  path: '/@controlpanels/content-rules/rule-1/condition/0',
  data: {
    file_extension: 'png',
  },
});

Response:

HTTP/1.1 204 No Content

Updating an Action on a Content rule with PATCH

To update an existing action on a content rule, send a PATCH request to the server. PATCH allows to provide just a subset of the resource, that is, the values you actually want to change:

PATCH /@controlpanels/content-rules/rule-1/action/0 HTTP/1.1
Accept: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhZG1pbiIsImZ1bGxuYW1lIjoiQWRtaW4iLCJpYXQiOjE2NDkzMTI0NDl9.RS1Ny_r0v7vIylFfK6q0JVJrkiDuTOh9iG9IL8xbzAk
Content-Type: application/json

{
  "transition": "submit"
}

Or use the client directly:

import { Client } from '@robgietema/nick';

const cli = Client.initialize({ apiPath: 'http://localhost:8080' });
const login = await cli.login({
  data: { login: 'admin', password: 'admin' },
});

const { data } = await cli.updateControlpanelContentRuleAction({
  token: login.data.token,
  path: '/@controlpanels/content-rules/rule-1/action/0',
  data: {
    transition: 'submit',
  },
});

Response:

HTTP/1.1 204 No Content

Reorder a Condition on a Content rule with PATCH

To reorder an existing condition on a content rule, send a PATCH request to the server. Specify the direction _move_up or _move_down in the form.button.Move attribute.

PATCH /@controlpanels/content-rules/rule-1/condition/1 HTTP/1.1
Accept: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhZG1pbiIsImZ1bGxuYW1lIjoiQWRtaW4iLCJpYXQiOjE2NDkzMTI0NDl9.RS1Ny_r0v7vIylFfK6q0JVJrkiDuTOh9iG9IL8xbzAk
Content-Type: application/json

{
  "form.button.Move": "_move_up"
}

Or use the client directly:

import { Client } from '@robgietema/nick';

const cli = Client.initialize({ apiPath: 'http://localhost:8080' });
const login = await cli.login({
  data: { login: 'admin', password: 'admin' },
});

const { data } = await cli.updateControlpanelContentRuleCondition({
  token: login.data.token,
  path: '/@controlpanels/content-rules/rule-1/condition/1',
  data: {
    'form.button.Move': '_move_up',
  },
});

Response:

HTTP/1.1 204 No Content

Reorder an Action on a Content rule with PATCH

To reorder an existing action on a content rule, send a PATCH request to the server. Specify the direction _move_up or _move_down in the form.button.Move attribute.

PATCH /@controlpanels/content-rules/rule-1/action/0 HTTP/1.1
Accept: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhZG1pbiIsImZ1bGxuYW1lIjoiQWRtaW4iLCJpYXQiOjE2NDkzMTI0NDl9.RS1Ny_r0v7vIylFfK6q0JVJrkiDuTOh9iG9IL8xbzAk
Content-Type: application/json

{
  "form.button.Move": "_move_down"
}

Or use the client directly:

import { Client } from '@robgietema/nick';

const cli = Client.initialize({ apiPath: 'http://localhost:8080' });
const login = await cli.login({
  data: { login: 'admin', password: 'admin' },
});

const { data } = await cli.updateControlpanelContentRuleAction({
  token: login.data.token,
  path: '/@controlpanels/content-rules/rule-1/action/0',
  data: {
    'form.button.Move': '_move_down',
  },
});

Response:

HTTP/1.1 204 No Content

Removing a Content rule with DELETE

Delete an existing content rule by sending a DELETE request to the URL of an existing content rule:

DELETE /@controlpanels/content-rules/rule-1 HTTP/1.1
Accept: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhZG1pbiIsImZ1bGxuYW1lIjoiQWRtaW4iLCJpYXQiOjE2NDkzMTI0NDl9.RS1Ny_r0v7vIylFfK6q0JVJrkiDuTOh9iG9IL8xbzAk

Or use the client directly:

import { Client } from '@robgietema/nick';

const cli = Client.initialize({ apiPath: 'http://localhost:8080' });
const login = await cli.login({
  data: { login: 'admin', password: 'admin' },
});

const { data } = await cli.deleteControlpanelContentRule({
  token: login.data.token,
  path: '/@controlpanels/content-rules/content-rule-1',
});

Response:

HTTP/1.1 204 No Content

Removing a Condition on a Content rule with DELETE

Delete an existing condition on a content rule by sending a DELETE request to the URL of an existing content rule:

DELETE /@controlpanels/content-rules/rule-1/condition/0 HTTP/1.1
Accept: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhZG1pbiIsImZ1bGxuYW1lIjoiQWRtaW4iLCJpYXQiOjE2NDkzMTI0NDl9.RS1Ny_r0v7vIylFfK6q0JVJrkiDuTOh9iG9IL8xbzAk

Or use the client directly:

import { Client } from '@robgietema/nick';

const cli = Client.initialize({ apiPath: 'http://localhost:8080' });
const login = await cli.login({
  data: { login: 'admin', password: 'admin' },
});

const { data } = await cli.deleteControlpanelContentRuleCondition({
  token: login.data.token,
  path: '/@controlpanels/content-rules/content-rule-1/condition/0',
});

Response:

HTTP/1.1 204 No Content

Removing an Action on a Content rule with DELETE

Delete an existing action on a content rule by sending a DELETE request to the URL of an existing content rule:

DELETE /@controlpanels/content-rules/rule-1/action/0 HTTP/1.1
Accept: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhZG1pbiIsImZ1bGxuYW1lIjoiQWRtaW4iLCJpYXQiOjE2NDkzMTI0NDl9.RS1Ny_r0v7vIylFfK6q0JVJrkiDuTOh9iG9IL8xbzAk

Or use the client directly:

import { Client } from '@robgietema/nick';

const cli = Client.initialize({ apiPath: 'http://localhost:8080' });
const login = await cli.login({
  data: { login: 'admin', password: 'admin' },
});

const { data } = await cli.deleteControlpanelContentRuleAction({
  token: login.data.token,
  path: '/@controlpanels/content-rules/content-rule-1/action/0',
});

Response:

HTTP/1.1 204 No Content


This site uses Just the Docs, a documentation theme for Jekyll.