Skip to main content

# Lite Scheduled Cleanup

BAF Lite provides the ability to clean up data — both on a scheduled basis and manually for a specific date. As a result, both the attempts themselves (endeavors) and their associated biometric data are deleted.

Cleanup works per aggregation and is configured independently for each. This means that different aggregations can have different cleanup schedules. Each attempt is created within a specific aggregation. In BAF Lite, the aggregation with the identifier `28608d66-a571-44ec-94db-04a00143ff51` is used.

Manual cleanup allows you to delete all data created before a specified point in time, which is set when calling the procedure. Scheduled cleanup allows you to configure automatic data deletion according to a schedule, triggered at specific intervals (for example, at the end of a quarter, month, week, etc.).

note

For more details on how to configure cleanup procedures, see the cleanup configuration section.

# API for Cleanup Settings

Cleanup settings contain the data used to perform cleanups. These settings are the input identifier for all operations related to data cleanup for a specific aggregation. Settings are created for an aggregation and use its ID. For configuring BAF Lite, the following aggregation must be used: `28608d66-a571-44ec-94db-04a00143ff51`.

## Creating a Cleanup Settings Object​

This request creates a cleanup settings object for the specified aggregation. Only one active settings object can exist per aggregation.

Request schema: `POST /lrs/settings?aggregate_entity=<aggregate_id>`

### Example Request​

    curl -X 'POST' \
      'http://192.168.10.1/lrs/settings?aggregate_entity=28608d66-a571-44ec-94db-04a00143ff51' \
      -H 'accept: application/json' \
      -H 'token: token' \
      -H 'Content-Type: application/json' \
      -d '{
      "retention_settings": {
        "enable": true,
        "content_retention": 1,
        "content_retention_dimension": "days",
        "execution_cron": "* 1 1 * *"
      }
    }'

### Query Parameters​

Parameter | Description
--- | ---
`aggregate_entity` | Identifier of the aggregation for which the cleanup settings are being created. Required.

### Request Headers​

Header | Description
--- | ---
`token` | Token of the `video-recorder` service. Stored in the `video-recorder-token` secret in the `./cfg/video-recorder.secrets.json` file. Required.

### Request Body Parameters (application/json)​

The request body must contain a `retention_settings` object with the following fields:

Field | Description
--- | ---
`enable` | Enables or disables scheduled cleanup. Type: `bool`. Required.
`content_retention` | Data retention period expressed in the units specified in `content_retention_dimension`. Data created earlier than `(scheduled cleanup start time - content_retention)` will be deleted. Type: `int`. Required.
`content_retention_dimension` | Unit of measurement for the retention period. Allowed values: `"seconds"`, `"minutes"`, `"hours"`, `"days"`, `"weeks"`. Required.
`execution_cron` | Schedule for running the cleanup procedure in cron format (e.g., `* 1 1 * *` — every 1st day of the month at 1:00). Type: `string`. Required.

### Example Request Body​

    {
      "retention_settings": {
        "enable": true,
        "content_retention": 1,
        "content_retention_dimension": "days",
        "execution_cron": "* 1 1 * *"
      }
    }

## Updating a Cleanup Settings Object​

This request updates an existing cleanup settings object for the specified aggregation.

Request schema: `PUT /lrs/settings?aggregate_entity=<aggregate_id>`

### Example Request​

    curl -X 'PUT' \
      'http://192.168.10.1/lrs/settings?aggregate_entity=28608d66-a571-44ec-94db-04a00143ff51' \
      -H 'accept: application/json' \
      -H 'token: token' \
      -H 'Content-Type: application/json' \
      -d '{
      "retention_settings": {
        "enable": true,
        "content_retention": 1,
        "content_retention_dimension": "days",
        "execution_cron": "* 1 1 * *"
      }
    }'

### Query Parameters​

Parameter | Description
--- | ---
`aggregate_entity` | Identifier of the aggregation whose settings are being updated. Required.

### Request Headers​

Header | Description
--- | ---
`token` | Token of the `video-recorder` service. Stored in the `video-recorder-token` secret in the `./cfg/video-recorder.secrets.json` file. Required.

### Request Body Parameters (application/json)​

The request body contains a `retention_settings` object with the following fields:

Field | Description
--- | ---
`enable` | Enables or disables scheduled cleanup. Type: `bool`. Required.
`content_retention` | Data retention period expressed in the units specified in `content_retention_dimension`. Data created earlier than `(scheduled cleanup start time - content_retention)` will be deleted. Type: `int`. Required.
`content_retention_dimension` | Unit of measurement for the retention period. Allowed values: `"seconds"`, `"minutes"`, `"hours"`, `"days"`, `"weeks"`. Required.
`execution_cron` | Schedule for running the cleanup procedure in cron format (e.g., `* 1 1 * *` — every 1st day of the month at 1:00). Type: `string`. Required.

### Example Request Body​

    {
      "retention_settings": {
        "enable": true,
        "content_retention": 1,
        "content_retention_dimension": "days",
        "execution_cron": "* 1 1 * *"
      }
    }

## Retrieving a Cleanup Settings Object​

This request returns previously created cleanup settings for the specified aggregation.

Request schema: `GET /lrs/settings?aggregate_entity=<aggregate_id>`

### Example Request​

    curl -X 'GET' \
      'http://192.168.10.1/lrs/settings?aggregate_entity=28608d66-a571-44ec-94db-04a00143ff51' \
      -H 'accept: application/json' \
      -H 'token: token'

### Query Parameters​

Parameter | Description
--- | ---
`aggregate_entity` | Identifier of the aggregation for which the cleanup settings are requested. Required.

### Request Headers​

Header | Description
--- | ---
`token` | Token of the `video-recorder` service. Stored in the `video-recorder-token` secret in the `./cfg/video-recorder.secrets.json` file. Required.

### Example Response​

On successful execution, a `200 OK` status is returned along with the cleanup settings object:

    {
      "retention_settings": {
        "enable": true,
        "content_retention": 1,
        "content_retention_dimension": "days",
        "execution_cron": "* 1 1 * *"
      }
    }

# API for Manual Cleanup and Cleanup Results

## Retrieving Cleanup Results​

This request returns the results of the last executed cleanup for all aggregations for which settings have been created. The results include the cleanup status and the date relative to which it was performed. If cleanup is currently running, the status will reflect that state.

Request schema: `GET /lrs/retention/metrics`

### Example Request​

    curl -X 'GET' \
      'http://192.168.10.1/lrs/retention/metrics' \
      -H 'accept: application/json' \
      -H 'token: token'

### Request Headers​

Header | Description
--- | ---
`token` | Token of the `video-recorder` service. Stored in the `video-recorder-token` secret in the `./cfg/video-recorder.secrets.json` file. Required.

### Example Response​

On successful execution, a `200 OK` status is returned and an object where the key is the aggregation ID and the value is the cleanup result object:

    {
      "28608d66-a571-44ec-94db-04a00143ff51": {
        "result": {
          "exception": null
        },
        "status": 1,
        "planned_retention_date": "2026-06-29T11:10:15.843710+00:00",
        "actual_retention_date": "2026-06-29T10:56:00+00:00",
        "last_modified": "2026-06-29T11:10:15.843715+00:00"
      }
    }

### Response Structure​

Field | Description
--- | ---
`result` | Object containing information about the cleanup result. Currently contains the `exception` field with error details, if any occurred.
`status` | Cleanup status. Possible values: `0` — cleanup is currently running; `1` — cleanup completed successfully; `2` — an error occurred during cleanup.
`planned_retention_date` | Scheduled time of the previous cleanup run (according to the schedule).
`actual_retention_date` | Actual date relative to which the cleanup was performed. All attempts created before this date were deleted.
`last_modified` | Last modification time of the cleanup result record.

## Retrieving the Next Scheduled Cleanup Time​

This request returns the date and time of the next scheduled cleanup run for the specified aggregation.

note

To obtain the next scheduled cleanup time for a newly created settings object, you must wait for the first run of the internal schedule check procedure. For more details, see the cleanup configuration section.

Request schema: `GET /lrs/retention/retention_time/<aggregate_id>`

### Example Request​

    curl -X 'GET' \
      'http://192.168.10.1/lrs/retention/retention_time/28608d66-a571-44ec-94db-04a00143ff51' \
      -H 'accept: application/json' \
      -H 'token: token'

### Path Parameters​

Parameter | Description
--- | ---
`aggregate_id` | Identifier of the aggregation for which the next cleanup time is requested. Required.

### Request Headers​

Header | Description
--- | ---
`token` | Token of the `video-recorder` service. Stored in the `video-recorder-token` secret in the `./cfg/video-recorder.secrets.json` file. Required.

### Example Response​

    "2026-08-01T01:00:00+00:00"

## Starting Manual Data Cleanup​

This request initiates manual data cleanup, deleting all attempts created before the specified date.

Request schema: `POST /lrs/retention/priority_execution/<aggregate_id>?priority_date=<priority_date>&execute_as_planned=false`

### Example Request​

    curl -X 'POST' \
      'https://baf.3divi.ru/lrs/retention/priority_execution/28608d66-a571-44ec-94db-04a00143ff51?priority_date=2022-08-01T01%3A00%3A00%2B00%3A00&execute_as_planned=false' \
      -H 'accept: application/json' \
      -H 'token: token'

### Query Parameters​

Parameter | Description
--- | ---
`aggregate_id` | Identifier of the aggregation for which manual cleanup is performed. Required.
`priority_date` | Date before which all attempts will be deleted. Required.
`execute_as_planned` | Internal parameter. Must always be `false`. Required.

### Request Headers​

Header | Description
--- | ---
`token` | Token of the `video-recorder` service. Stored in the `video-recorder-token` secret in the `./cfg/video-recorder.secrets.json` file. Required.