The Workflow REST API allows you to create, modify, and execute Workflows and Workflow actions via standard REST API calls.
Common Operations
The most commonly used Workflow operations are to find which Workflow Actions are available to a specific content item or Content Type, and to execute a Workflow action for a specific piece of content. The following endpoints perform the common operations.
Endpoint | Method | Usage | Description |
---|---|---|---|
findActionsByStep | GET | /steps/STEP_ID/actions | Returns all Workflow Actions associated with the specified Workflow Step.
|
findAvailableActions | GET | /contentlet/CONTENT_ID/actions | Returns the available Workflow Actions for the specified content item.
|
findInitialAvailable ActionsByContentType | GET | /initialactions/contenttype/CONTENT_TYPE_ID | Finds the available actions of the initial/first step(s) of the workflow scheme(s) associated with a content type Id. |
fireAction | PUT | /actions/actionId/fire | Executes the specified Workflow Action. |
In addition to the most common operations, you also may use the Workflow API to create, modify, and delete all parts of Workflows, including Workflow Schemes, Workflow Steps, and Workflow Actions. The following sections list all endpoints in the Workflow REST API.
Workflow Schemes
Endpoint | Method | Usage | Description |
---|---|---|---|
copyScheme | POST | /schemes/SCHEME_ID/copy | Copies the specified Workflow Scheme to a new Scheme.
|
deleteScheme | DEL | /schemes/SCHEME_ID | Deletes an existing Workflow Scheme.
|
exportScheme | GET | /schemes/SCHEME_ID/export | Exports the specified Workflow Scheme.
|
importScheme | POST | /schemes/import | Imports a Workflow Scheme previously exported with exportScheme. |
findAllSchemesAnd SchemesByContentType | GET | /schemes/schemescontenttypes/SCHEME_ID | Returns all Workflow Schemes used by the specified Content Type.
|
findSchemes | GET | /schemes/ | Returns all Workflow Schemes assigned to the specified Content Type.
|
saveScheme | POST | /schemes | Creates a new Workflow Scheme. Body: {"schemeName": "{Name}", "schemeDescription": "{Description}", "schemeArchived": "false"} |
updateScheme | PUT | /schemes/SCHEME_ID | Updates the specified existing Workflow Scheme. Body: {"schemeName": "{Name}", "schemeDescription": "{Description}", "schemeArchived": "false"} |
Workflow Steps
Endpoint | Method | Usage | Description |
---|---|---|---|
addStep | POST | /step | Creates a new Step in the specified Workflow Scheme. Please see below for the data to send in the body of the request. |
deleteStep | DEL | /steps/STEP_ID | Deletes the specified Workflow Step from its Workflow Scheme. |
findStepById | GET | /steps/STEP_ID | Returns the specified Workflow Step. |
findStepsByScheme | GET | /workflow/schemes/SCHEME_ID/steps | Returns all Workflow Steps associated with the specified Workflow Scheme.
|
reorderStep | PUT | /reorder/step/STEP_ID/order/ORDER | Changes the order of the specified Workflow Step within the Workflow Scheme the Step is in. |
updateStep | PUT | /steps/STEP_ID | Updates the specified existing Workflow Step. Please see below for the data to send in the body of the request. |
Updating a Workflow Step
The addStep and updateStep methods expect data in the following format within the body of the request:
{
"stepOrder":{ORDER},
"stepName":"{STEP_NAME}",
"enableEscalation":{true|false},
"escalationAction":"{ACTION_ID}", // Optional
"escalationTime":"0", // Optional
"stepResolved":{true|false}
}
Workflow Actions
Executing Actions
The fire
endpoint executes a Workflow Action. The fire
endpoint may be called using either the Workflow Action identifier or the Workflow Action name:
Endpoint | Method | Usage | Description |
---|---|---|---|
fireAction | PUT | /actions/actionId/fire | Executes the specified Workflow Action. |
fireAction | PUT | /actions/fire | Executes the Workflow Action specified in the request body. |
fireDefaultAction | PUT | /actions/default/fire/defaultAction | Executes ONLY SYSTEM default actions NEW, EDIT, PUBLISH, UNPUBLISH ARCHIVE, UNARCHIVE, DELETE, DESTROY. For more information on Default Workflow Actions, please see the documentation on Default Workflow Actions. |
Contents of the Request
The fire
endpoint expects data in the body of the request with the JSON name "contentlet"
, which includes a list of the fields of the content and a “name” field which specifies the name of the application accessing the endpoint (for logging purposes).
If you wish to specify the Workflow Action via the action name, you must include an actionname
field as well. This field is not required when specifying the Workflow Action identifier in the URL.
{
"actionname" : "save",
"contentlet" : {
"stInode" : "{Action Inode}",
"languageId" : {LANGUAGE_ID},
"name": "{Application Name}"
}
}
For information on how to send different Content Type Fields, please see the Save Content Using the REST API documentation.
Example
The following curl command demonstrates how to submit a full fire
endpoint request (for the fileAsset Content Type), including specification of a Binary field using a multipart upload:
curl -v -u admin@dotcms.com:admin -X PUT \ http://localhost:8082/api/v1/workflow/actions/b9d89c803d/fire?identifier=b105eddc-e4b0-4a7f-85ad-b09d29a1c31b -F "json={ 'contentlet': { "contentType":"fileAsset", "languageId":1, "hostFolder":"demo.dotcms.com", "fileName":"liz2.jpg", "title":"liz!" } }; type=application/json" -F "file=@//Users/fabrizzio/Downloads/liz.jpg; type=application/jpg"
Finding Actions
Endpoint | Method | Usage | Description |
---|---|---|---|
findAction | GET | /actions/ACTION_ID | Returns the specified Workflow Action.
|
findActionByStep | GET | /steps/STEP_ID/actions/ACTION_ID | Returns the specified Workflow Action associated with the specified Workflow Step.
|
findActionsByScheme | GET | /schemes/SCHEME_ID/actions | Returns all Workflow Actions associated with the specified Workflow Scheme. |
findActionsByStep | GET | /steps/STEP_ID/actions | Returns all Workflow Actions associated with the specified Workflow Step.
|
findAvailableActions | GET | /contentlet/CONTENT_ID/actions | Returns the available Workflow Actions for the specified content item.
|
findAvailableDefault ActionsByContentType | GET | /defaultactions/contenttype/CONTENT_TYPE_ID | Returns the default Workflow Actions associated with all Workflow Schemes assigned to the specified Content Type.
|
findAvailableDefault ActionsBySchemes | GET | /defaultactions/schemes | Returns the Default Workflow Actions associated with all Workflow Schemes.
|
findInitialAvailable ActionsByContentType | GET | /initialactions/contenttype/CONTENT_TYPE_ID | Finds the available actions of the initial/first step(s) of the workflow scheme(s) associated with the specified Content Type. |
Adding and Updating Actions
Endpoint | Method | Usage | Description |
---|---|---|---|
deleteAction | DEL | /actions/ACTION_ID | Deletes all references to a Workflow Action.
|
deleteActionFromStep | DEL | /steps/STEP_ID/actions/ACTION_ID | Deletes the specified Workflow Action from the specified Workflow Step.
|
reorderAction | PUT | /reorder/steps/STEP_ID/actions/ACTION_ID | Changes the order of the specified Workflow Action within the specified Workflow Step. Body: {"order" : 3} |
saveAction | POST | /actions | Saves an action.
|
saveActionToStep | POST | /steps/STEP_ID/actions | Saves the specified Workflow Action into the specified Workflow Step. Body: { "actionId": "{ACTION_ID}" } |
updateAction | PUT | /actions/ACTION_ID | Updates the specified existing Workflow Action. Please see below for the data to pass in the body of the request. |
Saving or Updating an Action
The saveAction and updateAction methods expect data in the following format within the body of the request:
{
"stepId": "{STEP_ID}",
"actionName": "{Name of the new Action}",
"schemeId": "{SCHEME_ID}",
"actionCondition": "",
"actionNextStep": "{STEP_ID or 'currentStep'}",
"actionNextAssign": "{USER_ID or ROLE_ID}",
"actionRoleHierarchyForAssign": false,
"actionAssignable": false,
"actionCommentable": true,
"whoCanUse":[],
"showOn": [
"UNPUBLISHED",
"NEW",
"LOCKED",
"PUBLISHED"
]
}