> For the complete documentation index, see [llms.txt](https://docs.malwation.com/hookmesh/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.malwation.com/hookmesh/legacy-version-s/hookmesh-and-cdr-integration-document-legacy-version-s.md).

# HookMesh & CDR Integration Document Legacy Version(s)

This page group has the documentations about old versions of HookMesh, if you will/are using the versions v2.1.4 do not follow the documentation here.

## Documentation

***

The system provides a way to run files through a specific flow (e.g., for CDR sanitization) and then retrieve the analysis results once processing is complete. The workflow is as follows:

1. **POST File to Flow:** Submit a file to a specified flow for processing.
2. **Check Submission Status:** Poll the system until the file processing is complete, through */listen/{uuid} request.*
3. **Download Sanitized File:** Once the processing is done, download the sanitized file if available(CDR has been successfully ran).

## Authentication

All requests to the public API endpoints require an `Authorization` header containing a Bearer token:

```makefile
Authorization: Bearer <hookmesh api token>
```

Replace `<hookmesh api token>` with your valid token.

## Endpoints

### Run Flow

**Endpoint:**

```arduino
POST /public-api/runFlow/{flowId}
```

**Description:**\
This endpoint takes in a file, processes it through the specified flow, and returns a UUID representing the submission. Use this UUID to check the status and retrieve results.

**Path Parameters:**

* `flowId` (string, required): The ID or Alias of the flow.

**Headers:**

* `Authorization: Bearer <hookmesh api token>`

**Request (multipart/form-data):**

* `file`: The file to be analyzed/sanitized. Provide the file from your local system.

**cURL Example:**

```bash
curl --location 'https://<IP_OR_DOMAIN>/public-api/runFlow/{flowId}' \
--header 'Authorization: Bearer <hookmesh api token>' \
--form 'file=@"/path/to/yourfile.pdf"'
```

**Success Response Example:**

```json
{
  "uuid": "fc10193b-eb5c-4c8c-be09-d9b325bf3cca",
  "message": "Successfully ran the flow, you can check your submission by sending GET request to /listen/:uuid."
}
```

**Notes:**

* After you get the success message, you will need to periodically query the `/listen/{uuid}` endpoint to check the submission status.

***

### Listen for Submission Results

**Endpoint:**

```arduino
GET /public-api/listen/{uuid}
```

**Description:** Check the status of a previously submitted file. Once processing is complete, details about the sanitized file and other metadata are returned.

**Path Parameters:**

* `uuid` (string, required): The UUID returned from the `runFlow` request.

**Headers:**

* `Authorization: Bearer <hookmesh api token>`

**cURL Example:**

```bash
curl --location 'https://<IP_OR_DOMAIN>/public-api/listen/541c5d79-86b3-423f-b320-7a4bda1ed2f1' \
--header 'Authorization: Bearer <hookmesh api token>'
```

**Example Successful Response**

```json
{
  "submission": {
    "result": [
      {
        "moduleId": "6731ed402266ca5d56e95a7f",
        "moduleName": "CDR",
        "startTime": "17 December 2024 14:20:49",
        "endTime": "17 December 2024 14:20:53",
        "moduleData": {
          "link": "https://<IP_OR_DOMAIN>/public-api/download/module_result?moduleId=6731ed402266ca5d56e95a7f&uuid=541c5d79-86b3-423f-b320-7a4bda1ed2f1"
        },
        "links": [
          {
            "link": "https://<IP_OR_DOMAIN>/public-api/download/module_file?id=676188c5efb6046f975337a7&uuid=541c5d79-86b3-423f-b320-7a4bda1ed2f1",
            "linkName": "HookMesh_Docs_sanitized.pdf"
          }
        ]
      }
    ],
    "uuid": "541c5d79-86b3-423f-b320-7a4bda1ed2f1",
    "filename": "HookMesh_Docs.pdf",
    "fileSize": 63970,
    "source": "<IP_OR_DOMAIN>",
    "status": {
      "statusID": 3,
      "statusString": "Completed"
    },
    "level": "Not Measured",
    "sanitized": true,
    "submissionDate": "17 December 2024 14:20:49",
    "startDate": "17 December 2024 14:20:49",
    "endDate": "17 December 2024 14:20:53",
    "createdAt": "17 December 2024 14:20:49",
    "updatedAt": "17 December 2024 14:20:53",
    "hashes": {
      "md5": "e74f9fdc64e4890e23fca50f3bbf9e4b",
      "sha1": "b0a6a46a985c6abf5b570cadb68978a7511585e6",
      "sha256": "c2ae040166d35ddc5546129b0b9e9ea70d8ea1504639d891b030f40ee5365ca7"
    }
  }
}

```

**Response Details**

* `submission.status.statusID` indicates the current status of processing:
  * `1` or `2`: Processing or pending.
  * `3`: Completed (File has been analyzed and sanitized).
* `submission.hashes` includes hash values (MD5, SHA1, SHA256) for the submitted file.
* `submission.level` indicates the risk or maliciousness level of the file if available.
  * Not Measured
  * Informative
  * Suspicious
  * Malicious

### Download Sanitized File

**Endpoint:**

```bash
GET /public-api/download/module_file?id={moduleId}&uuid={uuid}
```

**PS:** Since this link will be provided in both **Webhook & Listen Request** you don't need to build this URL in your own, just use the URL provided to you in `result[0].links[0].link`  .

**Query Parameters:**

* `id` (string, required): The module ID retrieved from the listen response.
* `uuid` (string, required): The UUID retrieved from the original submission.

**Headers:**

* `Authorization: Bearer <hookmesh api token>`

**cURL Example:**

```bash
curl --location 'https://<IP_OR_DOMAIN>/public-api/download/module_file?id=676188c5efb6046f975337a7&uuid=541c5d79-86b3-423f-b320-7a4bda1ed2f1' \
--header 'Authorization: Bearer <hookmesh api token>' \
--output sanitized_file.pdf
```

### Troubleshooting

* **401 Unauthorized:** Ensure your `Authorization` header and token are correct.
* **404 Not Found:** Check if you used the correct `uuid` or `moduleId`.
* **Timeouts:** The sanitization process can take time. If no webhook is used, continue polling until completion.
* If you checked this document and still the issue persists, send email to <batuhan.isildak@malwation.com>
