Custom Content API Support

On This Page

    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.

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 { "bodyType": "storage", "supportedContainerTypes": [ "space", "page" ], "supportedChildTypes": [ "attachment", "comment" ], "supportedSpacePermissions": [], "preventDuplicateTitle": false, "indexing": { "enabled": true } }

    In the above example, you'll see we specify content type keys in the supportedContainerTypes and supportedChildTypes fields. There are 2 categories of content type you can reference \u2013 built-in content and custom content.

    Built-in content types example

    The following snippet shows the content type we're defining can:
    • Be contained in a space or a page
    • Have a child comment or a child attachment

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    {
      "bodyType": "storage",
      "supportedContainerTypes": [
        "space",
        "page"
      ],
      "supportedChildTypes": [
        "attachment",
        "comment"
      ],
      "supportedSpacePermissions": [],
      "preventDuplicateTitle": false,
      "indexing": {
        "enabled": true
      }
    }
    

    Custom content example

    The following snippet shows the content type we're defining can:
    • Be contained in a content item with type type1 or type2, defined in the app with the key my-first-addon
    • Have a child of a content item with type type1 or type2, defined in the app with the key my-second-addon

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    {
      "bodyType": "storage",
      "supportedContainerTypes": [
        "ac:my-first-addon:type2",
        "ac:my-first-addon:type1"
      ],
      "supportedChildTypes": [
        "ac:my-second-addon:type1",
        "ac:my-second-addon:type2"
      ],
      "supportedSpacePermissions": [],
      "preventDuplicateTitle": false,
      "indexing": {
        "enabled": true
      }
    }
    

    Raw body type custom content example

    You can define custom content to support a content body with a type of raw.
    This is useful when you want to store, for example, stringified JSON to the content.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    {
      "bodyType": "raw",
      "supportedContainerTypes": [
        "space"
      ],
      "supportedChildTypes": [],
      "supportedSpacePermissions": [],
      "preventDuplicateTitle": false,
      "indexing": {
        "enabled": true
      }
    }
    

    Content with a raw body looks like this:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    
     {
         "title": "My title",
         "space": {"key": "DS"},
         "type": "ac:add-on-key:module-key",
         "body": {
             "raw": {
                 "value": "{\"field\": \"value\"}",
                 "representation": "raw"
             }
         }
     }
     

    Properties

    supportedContainerTypes
    Type
    [string,...]
    Required
    Yes
    Description

    Defines types that this custom content can be contained in.
    The supported content types are:

    • space: This custom content can be contained in a space.
    • page: This custom content can be contained in a page.
    • blogpost: This custom content can be contained in a blog post.
    • Any other content type of defined custom content within the same app.
      Any other custom content type defined in the same app.
      Please refer to The content type key for how to construct the content type key.


    bodyType
    Type
    string
    Defaults to
    storage
    Allowed values
    • storage
    • STORAGE
    • raw
    • RAW
    Description

    Defines the content body type of this custom content. Currently supported content body types are:

    • storage: This is Confluence's default storage representation which can be rendered using the Content Body Conversion API
    • raw: This representation is used for storing raw data in the body that is not storage format, this format is opaque to Confluence


    indexing
    Type
    Macro Parameter Indexing
    Description

    Defines how this content type will be indexed

    Defines how this macro parameter will be indexed for site search

    1
    2
    3
    4
    {
      "enabled": true
    }
    

    The macro parameter indexing property allows apps to hook into the mechanism by which Confluence populates its search index for site search. Each time macro is created or updated in Confluence, the value that is stored in the macro parameter will be added to the search index. The value of this macro parameter will also be used in displaying the excerpt text for search result.

    This is useful when the body of the macro is not searchable, for example: macros with bodyType: none. The app can still provide meaningful search text for this content by storing the extracted information to the macro parameter. The data in this macro parameter will get indexed as is without any modification.

    Properties

    enabled
    Type
    boolean
    Defaults to
    false
    Description

    Defines whether this macro parameter should be indexed for site search.


    preventDuplicateTitle
    Type
    boolean
    Defaults to
    false
    Description

    Defines whether Confluence should prevent content with duplicate title from being created in the same space or container.


    supportedChildTypes
    Type
    [string,...]
    Description

    Defines types that can be contained in this custom content.
    Currently supported content types:

    • attachment: This custom content can contain attachment.
    • comment: This custom content can contain comment.
    • Any other custom content type defined in the same app.
      Please refer to The content type key for how to construct the content type key.


    supportedSpacePermissions
    Type
    [string,...]
    Description

    Defines the space permissions that this custom content supports. Allowable values are : read, create and delete. It is required that these permissions be granted through the space permissions UI in order to perform the given operation.

    Otherwise the default permissions will be used.


    Rate this page: