# Process Instance

## Query process instance list
Interface Request Invoking Description <br>
HTTP Request Method: POST <br>
Request Address: http://127.0.0.1:8080/demo/horizon/workflow/rest/monitor/instance/page${suffix} <br>
**Post Data Description：**
```
{
  "accessToken": "",
  "page": "1",
  "limit": "10",
  "sort": "created"
}
```
Request Parameter Description:

| Parameter   | Required | Description                                                                                                |
|-------------|----------|------------------------------------------------------------------------------------------------------------|
| accessToken | Yes      | Invoking interface credentials, unique user ID                                                             |
| page        | No       | Page number, if blank, display all data                                                                    |
| limit       | No       | The number of data items displayed on each page, if left blank, default to 10 items displayed              |
| sort        | No       | if a minus sign is added before the field. If sort=- created, it is arranged in reverse order of 'created' |
**Example of returned results：**
```
{
  "code": 0,
  "data": [
    {
      "created": "2022-05-18 15:39:05",
      "creator": "admin",
      "flowId": "testhuiqian",
      "flowName": "Newflow Multi-Operator :",
      "id": "HZ28858f80d61b260180d61b26ee0001",
      "nodeId": "Node2",
      "nodeName": "Task2",
      "status": "Normal",
      "title": "Newflow Multi-Operator ",
      "trackId": "HZ28858f80d61b260180d61b26f00002",
      "typeName": "",
      "ver": "4",
      "version": "2"
    }
  ],
  "message": "",
  "recordsTotal": "3",
  "success": true
}
```
**Result parameter description:**

| Parameter | Type   | Description                       |
|-----------|--------|-----------------------------------|
| created   | String | Launched Time                     |
| creator   | String | The user who created the instance |
| flowId    | String | Flow id                           |
| flowName  | String | Flow Name                         |
| id        | String | Instance ID                       |
| nodeId    | String | Node ID of instance               |
| nodeName  | String | Node name of instanc              |
| typeName  | String | Flow category                     |
| status    | String | Status of instance                |
| title     | String | Title of instance                 |
| trackId   | String | Track ID of instance              |
| ver       | String | Flow release version              |
| version   | String | Flow version in instance          |

## Recoverable flow versions of instances
Interface Request Invoking Description <br>
HTTP Request Method: POST <br>
Request Address: http://127.0.0.1:8080/demo/horizon/workflow/rest/monitor/instance/recover/vernum${suffix} <br>
**Post Data Description：**
```
{
  "accessToken": " ",
  "workId": " "
}
```
Request Parameter Description:

| Parameter   | Required | Description                                    |
|-------------|----------|------------------------------------------------|
| accessToken | Yes      | Invoking interface credentials, unique user ID |
| workId      | Yes      | Instance ID                                    |
**Example of returned results：**
```
{
  "code": 0,
  "data": [
    1
  ],
  "message": "",
  "success": true
}
```
**Result parameter description:**

| Parameter | Type | Description           |
|-----------|------|-----------------------|
| data      | List | Array of flow version |

## Restore  instances to the specified flow version
Interface Request Invoking Description <br>
HTTP Request Method: POST <br>
Request Address: http://127.0.0.1:8080/demo/horizon/workflow/rest/monitor/instance/recover/version${suffix} <br>
**Post Data Description：**
```
{
  "accessToken": " ",
  "workId": " ",
  "selectVer":" "
}
```
Request Parameter Description:

| Parameter   | Required | Description                                     |
|-------------|----------|-------------------------------------------------|
| accessToken | Yes      | Invoking interface credentials, unique user ID  |
| workId      | Yes      | Instance id                                     |
| selectVer   | Yes      | The flow version of the instance to be restored |
**Example of returned results：**
```
{
  "message": "Recovered successful",
  "code": 1,
  "success": true
}
```

## Terminate Process Instance
Interface Request Invoking Description <br>
HTTP Request Method: POST <br>
Request Address: http://127.0.0.1:8080/demo/horizon/workflow/rest/monitor/instance/state/end${suffix} <br>
**Post Data Description：**
```
{
  "accessToken": " ",
  "workId": "HZ28811c72024d8d0172024da7b60007",
  "trackId":"HZ28811c72024d8d0172024da7b40006"
}
```
Request Parameter Description:

| Parameter   | Required | Description                                    |
|-------------|----------|------------------------------------------------|
| accessToken | Yes      | Invoking interface credentials, unique user ID |
| workId      | Yes      | Instance ID                                    |
| trackId     | Yes      | Track ID of instance                           |
**Example of returned results：**
```
{
  "code": 0,
  "message": "Terminate Instance successful",
  "success": true
}
```

## Replace process operator
Interface Request Invoking Description <br>
HTTP Request Method: POST <br>
Request Address: http://127.0.0.1:8080/demo/horizon/workflow/rest/monitor/instance/replace/author${suffix} <br>
**Post Data Description：**
```
{
  "accessToken": " ",
  "workId": "HZ28811c72024d8d0172024da7b60007",
  "trackId":"HZ28811c72024d8d0172024da7b40006",
  "author":"admin"
}
```
Request Parameter Description:

| Parameter   | Required | Description                                    |
|-------------|----------|------------------------------------------------|
| accessToken | Yes      | Invoking interface credentials, unique user ID |
| workId      | Yes      | Instance ID                                    |
| trackId     | Yes      | Track ID of intsance                           |
| author      | Yes      | User ID  of  to-do                             |
**Example of returned results：**
```
{
  "code": 0,
  "message": "Successfully replaced the operator for the instance",
  "success": true
}
```

## Update the flow version of the instance
Interface Request Invoking Description <br>
HTTP Request Method: POST <br>
Request Address: http://127.0.0.1:8080/demo/horizon/workflow/rest/monitor/instance/update${suffix} <br>
**Post Data Description：**
```
{
  "accessToken": " ",
  "workId": "HZ28811c72024d8d0172024da7b60007"
}
```
Request Parameter Description:

| Parameter   | Required | Description                                    |
|-------------|----------|------------------------------------------------|
| accessToken | Yes      | Invoking interface credentials, unique user ID |
| workId      | Yes      | Instance ID                                    |
**Example of returned results：**
```
{
  "code": 0,
  "message": "Successfully updated the process version of the instance",
  "success": true
}
```

## Delete Process Instance
Interface Request Invoking Description <br>
HTTP Request Method: POST <br>
Request Address: http://127.0.0.1:8080/demo/horizon/workflow/rest/monitor/instance/delete${suffix} <br>
**Post Data Description：**
```
{
  "accessToken": " ",
  "workId": "HZ28811c72024d8d0172024da7b60007"
}
```
Request Parameter Description:

| Parameter   | Required | Description                                                             |
|-------------|----------|-------------------------------------------------------------------------|
| accessToken | Yes      | Invoking interface credentials, unique user ID                          |
| workId      | Yes      | Process instance ID, multiple process instances separated by semicolons |
**Example of returned results：**
```
{
  "message": "Instance deletion failed",
  "code": 1,
  "success": true,
  "data": [
    "HZ28858f80d529f40180d55429610064 "
  ]
}
```
**Result parameter description:**

| Parameter | Type | Description                                                 |
|-----------|------|-------------------------------------------------------------|
| data      | List | When deletion fails, return an array of failed instance IDs |
