# ledger_cleaner

[[Source]](https://github.com/XRPLF/rippled/blob/master/src/xrpld/rpc/handlers/LedgerCleanerHandler.cpp)

The `ledger_cleaner` command controls the [Ledger Cleaner](https://github.com/XRPLF/rippled/tree/master/src/xrpld/app/ledger#the-ledger-cleaner), an asynchronous maintenance process that can find and repair corruption in `rippled`'s database of ledgers.

*The `ledger_cleaner` method is an [admin method](/es-es/docs/references/http-websocket-apis/admin-api-methods) that cannot be run by unprivileged users.*

### Request Format

An example of the request format:

WebSocket

```json
{
    "command": "ledger_cleaner",
    "max_ledger": 13818756,
    "min_ledger": 13818000,
    "stop": false
}
```

The request includes the following parameters:

| `Field` | Type | Description |
|  --- | --- | --- |
| `ledger` | Number - [Ledger Index](/docs/references/protocol/data-types/basic-data-types#ledger-index) | *(Optional)* If provided, check and correct the specified ledger only. |
| `max_ledger` | Number - [Ledger Index](/docs/references/protocol/data-types/basic-data-types#ledger-index) | *(Optional)* Configure the ledger cleaner to check ledgers with ledger indexes equal or lower than this. |
| `min_ledger` | Number - [Ledger Index](/docs/references/protocol/data-types/basic-data-types#ledger-index) | *(Optional)* Configure the ledger cleaner to check ledgers with ledger indexes equal or higher than this. |
| `full` | Boolean | *(Optional)* If true, fix ledger state objects and transactions in the specified ledger(s). Defaults to false. Automatically set to `true` if `ledger` is provided. |
| `fix_txns` | Boolean | *(Optional)* If true, correct transaction in the specified ledger(s). Overrides `full` if provided. |
| `check_nodes` | Boolean | *(Optional)* If true, correct ledger state objects in the specified ledger(s). Overrides `full` if provided. |
| `stop` | Boolean | *(Optional)* If true, disable the ledger cleaner. |


### Response Format

An example of a successful response:

JSON-RPC

```json
200 OK

{
   "result" : {
      "message" : "Cleaner configured",
      "status" : "success"
   }
}
```

The response follows the [standard format](/docs/references/http-websocket-apis/api-conventions/response-formatting), with a successful result containing the following fields:

| `Field` | Type | Description |
|  --- | --- | --- |
| `message` | String | `Cleaner configured` on success. |


### Possible Errors

* Any of the [universal error types](/docs/references/http-websocket-apis/api-conventions/error-formatting#universal-errors).
* `internal` if one the parameters is specified incorrectly. (This is a bug; the intended error code is `invalidParams`.)