Get Process Instances (POST)

Queries for historic process instances that fulfill the given parameters. This method is slightly more powerful than the Get Process Instances method because it allows filtering by multiple process variables of types String, Number or Boolean.

Method

POST /history/process-instance

Parameters

Query Parameters

firstResult Pagination of results. Specifies the index of the first result to return.
maxResults Pagination of results. Specifies the maximum number of results to return. Will return less results if there are no more results left.

Request Body

A JSON object with the following properties:

Name Description
processInstanceId Filter by process instance id.
processInstanceIds Filter by process instance ids. Must be a JSON array process instance ids.
processInstanceBusinessKey Filter by process instance business key.
processInstanceBusinessKeyIn Filter by a list of business keys. A process instance must have one of the given business keys and must be a JSON array of strings.
processInstanceBusinessKeyLike Filter by process instance business key that the parameter is a substring of.
rootProcessInstances Restrict the query to all process instances that are top level process instances.
superProcessInstanceId Restrict query to all process instances that are sub process instances of the given process instance. Takes a process instance id.
subProcessInstanceId Restrict query to one process instance that has a sub process instance with the given id.
superCaseInstanceId Restrict query to all process instances that are sub process instances of the given case instance. Takes a case instance id.
subCaseInstanceId Restrict query to one process instance that has a sub case instance with the given id.
caseInstanceId Restrict query to all process instances that are sub process instances of the given case instance. Takes a case instance id.
processDefinitionId Filter by the process definition the instances run on.
processDefinitionKey Filter by the key of the process definition the instances run on.
processDefinitionKeyIn Filter by a list of process definition keys. A process instance must have one of the given process definition keys. Must be a JSON array of Strings.
processDefinitionKeyNotIn Exclude instances that belong to a set of process definitions. Must be a JSON array of process definition keys.
processDefinitionName Filter by the name of the process definition the instances run on.
processDefinitionNameLike Filter by process definition names that the parameter is a substring of.
finished Only include finished process instances. This flag includes all process instances that are completed or terminated. Value may only be true, as false is the default behavior.
unfinished Only include unfinished process instances. Value may only be true, as false is the default behavior.
withIncidents Only include process instances which have an incident. Value may only be true, as false is the default behavior.
withRootIncidents Only include process instances which have a root incident. Value may only be true, as false is the default behavior.
incidentType Filter by the incident type. See the User Guide for a list of incident types.
incidentStatus Only include process instances which have an incident in status either open or resolved. To get all process instances, use the query parameter withIncidents.
incidentMessage Filter by the incident message. Exact match.
incidentMessageLike Filter by the incident message that the parameter is a substring of.
startedBy Only include process instances that were started by the given user.
startedBefore Restrict to instances that were started before the given date. By default*, the date must have the format yyyy-MM-dd'T'HH:mm:ss.SSSZ, e.g., 2013-01-23T14:42:45.000+0200.
startedAfter Restrict to instances that were started after the given date. By default*, the date must have the format yyyy-MM-dd'T'HH:mm:ss.SSSZ, e.g., 2013-01-23T14:42:45.000+0200.
finishedBefore Restrict to instances that were finished before the given date. By default*, the date must have the format yyyy-MM-dd'T'HH:mm:ss.SSSZ, e.g., 2013-01-23T14:42:45.000+0200.
finishedAfter Restrict to instances that were finished after the given date. By default*, the date must have the format yyyy-MM-dd'T'HH:mm:ss.SSSZ, e.g., 2013-01-23T14:42:45.000+0200.
tenantIdIn Filter by a list of tenant ids. A process instance must have one of the given tenant ids. Must be a JSON array of Strings.
withoutTenantId Only include historic process instances which belong to no tenant. Value may only be true, as false is the default behavior.
variables A JSON array to only include process instances that have/had variables with certain values.
The array consists of objects with the three properties name, operator and value. name (String) is the variable name, operator (String) is the comparison operator to be used and value the variable value.
value may be String, Number or Boolean.
Valid operator values are: eq - equal to; neq - not equal to; gt - greater than; gteq - greater than or equal to; lt - lower than; lteq - lower than or equal to; like.
variableNamesIgnoreCase Match all variable names provided in variables case-insensitively. If set to true variableName and variablename are treated as equal.
variableValuesIgnoreCase Match all variable values provided in variables case-insensitively. If set to true variableValue and variablevalue are treated as equal.
sorting A JSON array of criteria to sort the result by. Each element of the array is a JSON object that specifies one ordering. The position in the array identifies the rank of an ordering, i.e., whether it is primary, secondary, etc. The ordering objects have the following properties:
Name Description
sortBy Mandatory. Sort the results lexicographically by a given criterion. Valid values are instanceId, definitionId, definitionKey, definitionName, definitionVersion, businessKey, startTime, endTime, duration and tenantId.
sortOrder Mandatory. Sort the results in a given order. Values may be asc for ascending order or desc for descending order.
executedActivityBefore Restrict to instances that executed an activity before the given date (inclusive). By default*, the date must have the format yyyy-MM-dd'T'HH:mm:ss.SSSZ, e.g., 2013-01-23T14:42:45.000+0200.
executedActivityAfter Restrict to instances that executed an activity after the given date (inclusive). By default*, the date must have the format yyyy-MM-dd'T'HH:mm:ss.SSSZ, e.g., 2013-01-23T14:42:45.000+0200.
executedActivityIdIn Restrict to instances that executed an activity with one of given ids.
activeActivityIdIn Restrict to instances that have an active activity with one of given ids.
executedJobBefore Restrict to instances that executed an job before the given date (inclusive). By default*, the date must have the format yyyy-MM-dd'T'HH:mm:ss.SSSZ, e.g., 2013-01-23T14:42:45.000+0200.
executedJobAfter Restrict to instances that executed an job after the given date (inclusive). By default*, the date must have the format yyyy-MM-dd'T'HH:mm:ss.SSSZ, e.g., 2013-01-23T14:42:45.000+0200.
active Restrict to instances that are active
suspended Restrict to instances that are suspended
completed Restrict to instances that are completed
externallyTerminated Restrict to instances that are externally terminated
internallyTerminated Restrict to instances that are internally terminated
orQueries A JSON array of nested historic process instance queries with OR semantics. A process instance matches a nested query if it fulfills at least one of the query's predicates. With multiple nested queries, a process instance must fulfill at least one predicate of each query (Conjunctive Normal Form).

All process instance query properties can be used except for: sorting

See the user guide for more information about OR queries.

* For further information, please see the documentation.

Result

A JSON array of historic process instance objects. Each historic process instance object has the following properties:

Name Type Description
id String The id of the process instance.
rootProcessInstanceId String The process instance id of the root process instance that initiated the process.
superProcessInstanceId String The id of the parent process instance, if it exists.
superCaseInstanceId String The id of the parent case instance, if it exists.
caseInstanceId String The id of the parent case instance, if it exists.
processDefinitionName String The name of the process definition that this process instance belongs to.
processDefinitionKey String The key of the process definition that this process instance belongs to.
processDefinitionVersion Integer The version of the process definition that this process instance belongs to.
processDefinitionId String The id of the process definition that this process instance belongs to.
businessKey String The business key of the process instance.
startTime String The time the instance was started. Default format* yyyy-MM-dd'T'HH:mm:ss.SSSZ.
endTime String The time the instance ended. Default format* yyyy-MM-dd'T'HH:mm:ss.SSSZ.
removalTime String The time after which the instance should be removed by the History Cleanup job. Default format* yyyy-MM-dd'T'HH:mm:ss.SSSZ.
durationInMillis Number The time the instance took to finish (in milliseconds).
startUserId String The id of the user who started the process instance.
startActivityId String The id of the initial activity that was executed (e.g., a start event).
deleteReason String The provided delete reason in case the process instance was canceled during execution.
tenantId String The tenant id of the process instance.
state String last state of the process instance, possible values are:
  • ACTIVE - running process instance
  • SUSPENDED - suspended process instances
  • COMPLETED - completed through normal end event
  • EXTERNALLY_TERMINATED - terminated externally, for instance through REST API
  • INTERNALLY_TERMINATED - terminated internally, for instance by terminating boundary event

* For further information, please see the documentation.

Response Codes

Code Media type Description
200 application/json Request successful.
400 application/json Returned if some of the query parameters are invalid, for example if a sortOrder parameter is supplied, but no sortBy. See the Introduction for the error response format.

Example

Request

POST /history/process-instance

Request Body:

{
  "finishedAfter": "2013-01-01T00:00:00.000+0200",
  "finishedBefore": "2013-04-01T23:59:59.000+0200",
  "executedActivityAfter": "2013-03-23T13:42:44",
  "variables": [
    {
      "name": "myVariable",
      "operator": "eq",
      "value": "camunda"
    },
    {
      "name": "mySecondVariable",
      "operator": "neq",
      "value": 124
    }
  ],
  "sorting":[
    {
      "sortBy": "businessKey",
      "sortOrder": "asc"
    },
    {
      "sortBy": "startTime",
      "sortOrder": "desc"
    }
  ]
}

Response

[
  {
    "id":"7c80cc8f-ef95-11e6-b6e6-34f39ab71d4e",
    "businessKey":null,
    "processDefinitionId":"invoice:1:7bf79f13-ef95-11e6-b6e6-34f39ab71d4e",
    "processDefinitionKey":"invoice",
    "processDefinitionName":"Invoice Receipt",
    "processDefinitionVersion":1,
    "startTime":"2017-02-10T14:33:19.000+0200",
    "endTime":null,
    "removalTime": null,
    "durationInMillis":null,
    "startUserId":null,
    "startActivityId":"StartEvent_1",
    "deleteReason":null,
    "rootProcessInstanceId": "f8259e5d-ab9d-11e8-8449-e4a7a094a9d6",
    "superProcessInstanceId":null,
    "superCaseInstanceId":null,
    "caseInstanceId":null,
    "tenantId":null,
    "state":"ACTIVE"
  }
]

On this Page: