> For the complete documentation index, see [llms.txt](https://apidocs.akinon.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://apidocs.akinon.com/integrator/logs.md).

# Logs

This page provides comprehensive information and documentation on a set of API methods specifically designed to handle logs in the Integrator.

Before calling these log APIs, you must first authenticate and obtain an access token using the Login endpoint. The login method is documented in the [Login API documentation](https://apidocs.akinon.com/integrator/authentication), and the returned token must be included in the `Authorization` header as `Bearer <token>` when accessing the log endpoints.

## <mark style="color:red;">`GET`</mark> <mark style="color:red;">List Logs</mark>

This method is used to list all logs associated with a flow ID, providing information such as their running state, success result, amount of lines, subflow logs, and more.

**Path**: `/logs?projectid=<projectId>&limit=20&page=1&flowId=<flowId>&log_type=1`

* Prod Integrator:`https://flow.entegrator.akinon.net:3000/logs`
* Dev Integrator:`https://flow-dev.entegrator.akinon.net:3000/logs`

#### **Query Parameters**

<table><thead><tr><th width="102.546875">Parameter</th><th width="87.1875">In</th><th width="246.77734375">Description</th><th width="89.14453125" align="center">Required</th><th width="88.87109375" align="center">Default</th><th width="123.65625" align="center">Limits</th></tr></thead><tbody><tr><td>projectId</td><td>query</td><td>Project identifier</td><td align="center">✓</td><td align="center">-</td><td align="center">-</td></tr><tr><td>flowId</td><td>query</td><td>Flow identifier</td><td align="center">✓</td><td align="center">-</td><td align="center">-</td></tr><tr><td>limit</td><td>query</td><td>Limits the amount of logs</td><td align="center"></td><td align="center">25</td><td align="center">Min:1 Max:100</td></tr><tr><td>page</td><td>query</td><td>Offsets the returned log page</td><td align="center"></td><td align="center">1</td><td align="center">Min:1</td></tr><tr><td>log_type</td><td>query</td><td>Log type enum, "1" for main logs, "2" for sub logs, "3" for line logs</td><td align="center"></td><td align="center">-</td><td align="center">One of following values: 1,2,3</td></tr><tr><td>filename_uuid</td><td>query</td><td>Execution ID of the process, used for filtering "main logs"</td><td align="center"></td><td align="center">-</td><td align="center">-</td></tr><tr><td>original_filename_uuid</td><td>query</td><td>ID of the process, used for finding "line logs" belonging to "main log"</td><td align="center"></td><td align="center">-</td><td align="center">-</td></tr><tr><td>Authentication</td><td>header</td><td>Auth token for current user</td><td align="center">✓</td><td align="center"></td><td align="center"></td></tr></tbody></table>

#### **Example Response (200 OK)**

* `state`:
  * 1 - Start
  * 2 - In Progress
  * 3 - Finished
* `status`:
  * 1 - In Progress
  * 2 - Success
  * 3 - Failed
  * 4 - Empty
* `next` : URL for the next log page
* `previous`: URL for the previous log page
* `triggered_by` : E-mail address of the user who triggered the flow ("System" for automatically triggered flows)
* `is_triggered`: True for manually triggered inbound flows
* `created` : Timestamp for `log_type=1` , datetime string for others
* `finished` : Timestamp for `log_type=1` , datetime string for others

```json
  {
    "count": 1,
    "limit": 20,
    "page": 1,
    "previous": "",
    "next": "<next-page-url>",
    "results": [
      {
        "created": "1687519997186",
        "id": <logId>,
        "process_group_id": "<flowId>",
        "process_group_name": "price",
        "parent_process_group_id": null,
        "original_filename_uuid": "<exection_id>",
        "filename_uuid": "<exection_id>",
        "state": 1,
        "status": 1,
        "finished": null,
        "fragment_count": null,
        "process_count": 0,
        "success_count": 0,
        "fail_count": 0,
        "in_bound": false,
        "schedule": null,
        "is_triggered": true,
        "triggered_by": "test@akinon.com\n",
        "log_type": 1,
        "flow_order": 1,
        "is_send_S3": 0,
        "sub_flows": [
          {
            "created": "2023-06-23T11:33:17.898+00:00",
            "id": <logId>,
            "process_group_id": "login",
            "process_group_name": "Login",
            "parent_process_group_id": "<flowId>",
            "original_filename_uuid": "<exection_id>",
            "filename_uuid": "<step log id>",
            "state": 3,
            "status": 2,
            "finished": "2023-06-23T11:33:42.00073+00:00",
            "process_count": 1,
            "success_count": 0,
            "fail_count": 0,
            "in_bound": false,
            "schedule": null,
            "is_triggered": true,
            "triggered_by": "test@akinon.com\n",
            "log_type": 2,
            "flow_order": 2,
            "is_send_S3": 0,
            "fragment_count": null,
            "row_num": 1
          },
          {
            "created": "2023-06-23T11:33:18.46+00:00",
            "id": <logId>,
            "process_group_id": "read_data_from_erp",
            "process_group_name": "Read Data From ERP",
            "parent_process_group_id": "<flowId>",
            "original_filename_uuid": "<exection_id>",
            "filename_uuid": "<step log id>",
            "state": 3,
            "status": 2,
            "finished": "2023-06-23T11:33:42.000768+00:00",
            "process_count": 1,
            "success_count": 0,
            "fail_count": 0,
            "in_bound": false,
            "schedule": null,
            "is_triggered": true,
            "triggered_by": "test@akinon.com\n",
            "log_type": 2,
            "flow_order": 4,
            "is_send_S3": 1,
            "fragment_count": null,
            "row_num": 1
          }
        ]
      }
    ]
  }
```

**Response Errors**

* Status Code 401: This status code is returned when the token is incorrect or the Authentication header is missing.
* Status Code 400: This status code is returned when the required fields are missing or incorrect.
* Status Code 404: This status code is returned when the search result is empty.

**Example Request URL**

Filter line logs with option to search within main log.

To filter using search options, the line logs (log\_type=3) need to be searched within. For each search option, the corresponding search option field should be provided, and an index (starting from 1) should be assigned to match the search option field and its values. If an `original_filename_uuid` is provided as the main log execution ID, the search will be limited to that specific main log.

**Path:** `/logs?flowId=123456-12345-1234&log_type=3&projectid=98765-9876-9875&limit=20&page=1&search_field.1=sku&search_value.1=examplesku`

| parameter                | value              | description                |
| ------------------------ | ------------------ | -------------------------- |
| flowId                   | 123456-12345-1234  | Flow identifier            |
| log\_type                | 3                  | line log type              |
| original\_filename\_uuid | asdefgh-12345-9875 | Execution ID               |
| projectid                | 98765-9876-9875    | Project identifier         |
| limit                    | 20                 | Amount of log              |
| page                     | 1                  | Page count of the log      |
| search\_field.1          | sku                | Name of the search option  |
| search\_value.1          | examplesku         | Value of the search option |

## <mark style="color:red;">`GET`</mark> <mark style="color:red;">Download Logs</mark>

This method is used to download the log file for the process.

**Path**: `/logs/download?id=<log_id>&flowId=<flowId>&projectid=<projectId>&projectslug=<projectSlug>`

* Prod Integrator: `https://flow.entegrator.akinon.net:3000/logs/download`
* Dev Integrator:`https://flow-dev.entegrator.akinon.net:3000/logs/download`

#### **Query Parameters**

| Parameter      | In     | Description                 | Required |
| -------------- | ------ | --------------------------- | :------: |
| id             | query  | Log ID                      |     ✓    |
| projectId      | query  | Project identifier          |     ✓    |
| flowId         | query  | Flow identifier             |     ✓    |
| projectslug    | query  | Name of the project slug    |     ✓    |
| Authentication | header | Auth token for current user |     ✓    |

**Response**: The response is an encoded `base64` zip file. When the zip file is extracted, it contains a `json` file with log details such as errors, request body, response body, and so on.

#### **Example Request**

Example Python Code for Downloading, Decoding and Reading Log:

```python
  from io import BytesIO
  import base64
  import json
  import zipfile
  
  import requests
  
  url = "https://flow-dev.entegrator.akinon.net:3000/logs/download"
  params = {
      "id": 000000,
      "projectId": "<projectId>",
      "flowId": "<flowId>",
      "projectslug": "<projectSlug>"
  }
  
  headers = {
    'Authorization': 'Bearer <token>'
  }
  
  response = requests.request("GET", url, headers=headers, params=params)
  
  base64_decoded = base64.b64decode(response.text)
  zip_input = BytesIO(base64_decoded)
  zip_file = zipfile.ZipFile(zip_input, "r")
  json_text = zip_file.read(zip_file.filelist[0].filename)
  log = json.loads(json_text)
  print(log)
```

**Response Errors**

* Status Code 401: This status code is returned when the token is incorrect or the Authentication header is missing.
* Status Code 400: This status code is returned when the required fields are missing or incorrect.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://apidocs.akinon.com/integrator/logs.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
