Documentation

Custom Content

You can declare custom content in Confluence, which behaves like built-in Confluence content types—page, blog post, or comment, for example.

Custom content can be:

  • Created, retrieved, updated or deleted using the Confluence REST API.
  • Indexed as a built-in content type and rendered in quick search and site-wide search.
  • Viewed in a customized viewer supplied by the add-on.
  • Listed in a content list page in a space or shown as a tab in page attachment screen.
  • Created from create dialog.
  • Created or edited via a customized UI supplied by the add-on.

You can also find a step by step tutorial series covering all the aspects of custom content here: Custom Content with Confluence Connect

{
  "modules": {
    "customContent": [
      {
        "uiSupport": {
          "contentViewComponent": {
            "addonKey": "addon-key",
            "moduleKey": "dialog-module-key"
          },
          "icons": {
            "item": {
              "width": 16,
              "height": 16,
              "url": "/item.png"
            }
          }
        },
        "apiSupport": {
          "bodyType": "storage",
          "supportedContainerTypes": [
            "space",
            "page"
          ],
          "supportedChildTypes": [
            "attachment",
            "comment"
          ],
          "supportedSpacePermissions": [],
          "preventDuplicateTitle": false,
          "indexing": {
            "enabled": true
          }
        },
        "name": {
          "value": "My Content Type Name"
        },
        "key": "my-custom-content"
      }
    ]
  }
}

Create custom content via the Confluence REST API

The above snippet defines your custom content: my-custom-content. You can create a new piece of content with this type by posting the following JSON to the Confluence /rest/api/content endpoint.


 {
     "type":"ac:my-addon-key:my-custom-content",
     "title":"My content title",
     "space":{
         "key":"ds"
     },
     "body":{
         "storage":{
             "value":"This is my content body",
             "representation":"storage"
         }
     }
 }
 

The content type key

The content type key for custom content is defined in 3 parts:

  • ac
    This is always the same, indicating that this content type is defined in a Connect add-on.
  • my-addon-key
    The key of the Connect add-on.
  • my-custom-content
    The key of the module which defines the custom content.

For example:

Content type key ac:my-addon-key:my-custom-content should be used for creating custom content that's defined in a Connect add-on with the key of my-addon-key and module key of my-custom-content

Properties

apiSupport

Required
Yes
Description

This property allows you to specify the container types your custom content can appear in, and its supported child content types. It also allows you to enable indexing of your custom content.

key

Type
string
Required
Yes
Description

A key to identify this module.

This key must be unique relative to the add on, with the exception of Confluence macros: Their keys need to be globally unique.

Keys must only contain alphanumeric characters and dashes.

The key is used to generate the url to your add-on's module. The url is generated as a combination of your add-on key and module key. For example, an add-on which looks like:

{
    "key": "my-addon",
    "modules": {
        "configurePage": {
            "key": "configure-me",
        }
    }
}

Will have a configuration page module with a URL of /plugins/servlet/ac/my-addon/configure-me.

name

Required
Yes
Description

A human readable name.

uiSupport

Required
Yes
Description

Declares information for rendering the custom content in the UI.

description

Description

The description of the custom content