Remote Publishing / Bundle API documentation for the dotCMS Content Management System

dotCMS allows users to create bundles of content / sites / templates / content types and other objects that can be used for batch remote publishing or even in a CI/CD process. Below are example commands on how to use the RemotePublishAjaxAction endpoint to create and manage bundles via api. This endpoint allows you to use the API to :

Retrieve and Store the Authorization Token

The first thing you must do is retrieve the authorization token, which you will then use to perform all the other API operations. The following example uses the Linux export command and a simple Python command to store the Auth token for later use:

export TOK=`curl -H "Content-Type:application/json" -s -X POST http://localhost:8080/api/v1/authentication/api-token -d  '
{ 
    "user":"admin@dotcms.com", 
    "password":"admin", 
    "expirationDays": 1, 
    "label":"for testing" 
}'  | python -c 'import json,sys;print json.load(sys.stdin)["entity"]["token"]'`

Add an object to bundle by Identifier

Note: Any object can be added to a bundle, not just content.

This creates or appends an asset to a bundle with the name and/or id specified. The following example creates a new Bundle and adds the home page Template to the Bundle.

curl -H "Content-Type: application/json" -H "Authorization:Bearer $TOK" -XPOST  http://localhost:8080/DotAjaxDirector/com.dotcms.publisher.ajax.RemotePublishAjaxAction/cmd/addToBundle -d '
{
    "assetIdentifier": "71bf1747-56b9-41ca-a3fa-1fc7b8471dba",
    "bundleName":"testing",
    "bundleId":"01E1YNZBZWWNVHJBK5KFVNF8ZZ"
}
'

Add Content Using a Query

You can add content to a Bundle using a Lucene query; all content matching the query is added to the Bundle. When content is added to a Bundle, the Content Types of the content are added by dependency.

curl -H "Content-Type: application/json" -H "Authorization:Bearer $TOK" -XPOST  http://localhost:8080/DotAjaxDirector/com.dotcms.publisher.ajax.RemotePublishAjaxAction/cmd/addToBundle -d '
{
    "query": "+contenttype:news",
    "bundleId":"01E1YNZBZWWNVHJBK5KFVNF8ZZ"
}
'

Add a Site by Name

You can also add a Site to a bundle using a content query. When a site is added to a bundle, all the content/templates and containers beloging the site are added by dependency.

curl -H "Content-Type: application/json" -H "Authorization:Bearer $TOK" -XPOST  http://localhost:8080/DotAjaxDirector/com.dotcms.publisher.ajax.RemotePublishAjaxAction/cmd/addToBundle -d '
{
    "query": "+host.hostname:demo.dotcms.com +live:true",
    "bundleName":"testing"
}
'

Push the Bundle

THe following example pushes the Bundle to two different Push Publishing Environments. The assetIdentifier is the identifier of the Bundle to be pushed, and the whoToSend is the environments to send to, specified as a comma separated list of Identifiers (UUIDs) of the Environments to send to.

curl -H "Content-Type: application/json" -H "Authorization:Bearer $TOK" -XPOST  http://localhost:8080/DotAjaxDirector/com.dotcms.publisher.ajax.RemotePublishAjaxAction/cmd/pushBundle -d '
{
    "assetIdentifier": "01E1YNZBZWWNVHJBK5KFVNF8ZZ",
    "remotePublishDate":"2001-01-01",
    "remotePublishTime":"10-00",
    "remotePublishExpireDate":"2051-01-01",
    "remotePublishExpireTime":"10-00",
    "iWantTo":"publish|expire",
    "whoToSend":"UUID-prod-environ1,UUID-prod-environ2",
    "forcePush":true|false
}
'

Download the Bundle

You can download the bundle as a .tar.gz file, either for publish or unpublish. The following example downloads the bundle from the above examples, for publishing.

curl -H "Content-Type: application/json" -H "Authorization:Bearer $TOK" -XPOST  --output my-bundle.tar.gz http://localhost:8080/DotAjaxDirector/com.dotcms.publisher.ajax.RemotePublishAjaxAction/cmd/downloadUnpushedBundle -d '
{
    "bundleId":"01E1YNZBZWWNVHJBK5KFVNF8ZZ",
    "paramOperation": "publish"
}
'