{
  "$schema": "../rpc-schema-draft.json",
  "type": "object",
  "rpc": "autoclean-status",
  "title": "Examine auto-delete of old invoices/payments/forwards",
  "description": [
    "The **autoclean-status** RPC command tells you about the status of the autoclean plugin, optionally for only one subsystem."
  ],
  "request": {
    "required": [],
    "additionalProperties": false,
    "properties": {
      "subsystem": {
        "type": "string",
        "enum": [
          "succeededforwards",
          "failedforwards",
          "succeededpays",
          "failedpays",
          "paidinvoices",
          "expiredinvoices",
          "networkevents"
        ],
        "description": [
          "What subsystem to ask about. Currently supported subsystems are:",
          "    * `failedforwards`: routed payments which did not succeed (`failed` or `local_failed` in listforwards `status`).",
          "    * `succeededforwards`: routed payments which succeeded (`settled` in listforwards `status`).",
          "    * `failedpays`: payment attempts which did not succeed (`failed` in listpays `status`).",
          "    * `succeededpays`: payment attempts which succeeded (`complete` in listpays `status`).",
          "    * `expiredinvoices`: invoices which were not paid (and cannot be) (`expired` in listinvoices `status`).",
          "    * `paidinvoices`: invoices which were paid (`paid` in listinvoices `status).",
          "    * `networkevents`: all events in listnetworkevents (added *v25.12*)"
        ]
      }
    }
  },
  "response": {
    "required": [
      "autoclean"
    ],
    "additionalProperties": false,
    "properties": {
      "autoclean": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "succeededforwards": {
            "type": "object",
            "additionalProperties": true,
            "required": [
              "enabled",
              "cleaned"
            ],
            "properties": {
              "enabled": {
                "type": "boolean",
                "description": [
                  "Whether autocleaning is enabled for successful listforwards."
                ]
              },
              "cleaned": {
                "type": "u64",
                "description": [
                  "Total number of deletions done (ever)."
                ]
              }
            },
            "if": {
              "additionalProperties": true,
              "properties": {
                "enabled": {
                  "type": "boolean",
                  "enum": [
                    true
                  ]
                }
              }
            },
            "then": {
              "additionalProperties": false,
              "required": [
                "enabled",
                "age",
                "cleaned"
              ],
              "properties": {
                "enabled": {},
                "cleaned": {},
                "age": {
                  "type": "u64",
                  "description": [
                    "Age (in seconds) to delete successful listforwards."
                  ]
                }
              }
            },
            "else": {
              "additionalProperties": false,
              "required": [
                "enabled",
                "cleaned"
              ],
              "properties": {
                "enabled": {},
                "cleaned": {}
              }
            }
          },
          "failedforwards": {
            "type": "object",
            "additionalProperties": true,
            "required": [
              "enabled",
              "cleaned"
            ],
            "properties": {
              "enabled": {
                "type": "boolean",
                "description": [
                  "Whether autocleaning is enabled for failed listforwards."
                ]
              },
              "cleaned": {
                "type": "u64",
                "description": [
                  "Total number of deletions done (ever)."
                ]
              }
            },
            "if": {
              "additionalProperties": true,
              "properties": {
                "enabled": {
                  "type": "boolean",
                  "enum": [
                    true
                  ]
                }
              }
            },
            "then": {
              "additionalProperties": false,
              "required": [
                "enabled",
                "age",
                "cleaned"
              ],
              "properties": {
                "enabled": {},
                "cleaned": {},
                "age": {
                  "type": "u64",
                  "description": [
                    "Age (in seconds) to delete failed listforwards."
                  ]
                }
              }
            },
            "else": {
              "additionalProperties": false,
              "required": [
                "enabled",
                "cleaned"
              ],
              "properties": {
                "enabled": {},
                "cleaned": {}
              }
            }
          },
          "succeededpays": {
            "type": "object",
            "additionalProperties": true,
            "required": [
              "enabled",
              "cleaned"
            ],
            "properties": {
              "enabled": {
                "type": "boolean",
                "description": [
                  "Whether autocleaning is enabled for successful listpays/listsendpays."
                ]
              },
              "cleaned": {
                "type": "u64",
                "description": [
                  "Total number of deletions done (ever)."
                ]
              }
            },
            "if": {
              "additionalProperties": true,
              "properties": {
                "enabled": {
                  "type": "boolean",
                  "enum": [
                    true
                  ]
                }
              }
            },
            "then": {
              "additionalProperties": false,
              "required": [
                "enabled",
                "age",
                "cleaned"
              ],
              "properties": {
                "enabled": {},
                "cleaned": {},
                "age": {
                  "type": "u64",
                  "description": [
                    "Age (in seconds) to delete successful listpays/listsendpays."
                  ]
                }
              }
            },
            "else": {
              "additionalProperties": false,
              "required": [
                "enabled",
                "cleaned"
              ],
              "properties": {
                "enabled": {},
                "cleaned": {}
              }
            }
          },
          "failedpays": {
            "type": "object",
            "additionalProperties": true,
            "required": [
              "enabled",
              "cleaned"
            ],
            "properties": {
              "enabled": {
                "type": "boolean",
                "description": [
                  "Whether autocleaning is enabled for failed listpays/listsendpays."
                ]
              },
              "cleaned": {
                "type": "u64",
                "description": [
                  "Total number of deletions done (ever)."
                ]
              }
            },
            "if": {
              "additionalProperties": true,
              "properties": {
                "enabled": {
                  "type": "boolean",
                  "enum": [
                    true
                  ]
                }
              }
            },
            "then": {
              "additionalProperties": false,
              "required": [
                "enabled",
                "age",
                "cleaned"
              ],
              "properties": {
                "enabled": {},
                "cleaned": {},
                "age": {
                  "type": "u64",
                  "description": [
                    "Age (in seconds) to delete failed listpays/listsendpays."
                  ]
                }
              }
            },
            "else": {
              "additionalProperties": false,
              "required": [
                "enabled",
                "cleaned"
              ],
              "properties": {
                "enabled": {},
                "cleaned": {}
              }
            }
          },
          "paidinvoices": {
            "type": "object",
            "additionalProperties": true,
            "required": [
              "enabled",
              "cleaned"
            ],
            "properties": {
              "enabled": {
                "type": "boolean",
                "description": [
                  "Whether autocleaning is enabled for paid listinvoices."
                ]
              },
              "cleaned": {
                "type": "u64",
                "description": [
                  "Total number of deletions done (ever)."
                ]
              }
            },
            "if": {
              "additionalProperties": true,
              "properties": {
                "enabled": {
                  "type": "boolean",
                  "enum": [
                    true
                  ]
                }
              }
            },
            "then": {
              "additionalProperties": false,
              "required": [
                "enabled",
                "age",
                "cleaned"
              ],
              "properties": {
                "enabled": {},
                "cleaned": {},
                "age": {
                  "type": "u64",
                  "description": [
                    "Age (in seconds) to paid listinvoices."
                  ]
                }
              }
            },
            "else": {
              "additionalProperties": false,
              "required": [
                "enabled",
                "cleaned"
              ],
              "properties": {
                "enabled": {},
                "cleaned": {}
              }
            }
          },
          "expiredinvoices": {
            "type": "object",
            "additionalProperties": true,
            "required": [
              "enabled",
              "cleaned"
            ],
            "properties": {
              "enabled": {
                "type": "boolean",
                "description": [
                  "Whether autocleaning is enabled for expired (unpaid) listinvoices."
                ]
              },
              "cleaned": {
                "type": "u64",
                "description": [
                  "Total number of deletions done (ever)."
                ]
              }
            },
            "if": {
              "additionalProperties": true,
              "properties": {
                "enabled": {
                  "type": "boolean",
                  "enum": [
                    true
                  ]
                }
              }
            },
            "then": {
              "additionalProperties": false,
              "required": [
                "enabled",
                "age",
                "cleaned"
              ],
              "properties": {
                "enabled": {},
                "cleaned": {},
                "age": {
                  "type": "u64",
                  "description": [
                    "Age (in seconds) to expired listinvoices."
                  ]
                }
              }
            },
            "else": {
              "additionalProperties": false,
              "required": [
                "enabled",
                "cleaned"
              ],
              "properties": {
                "enabled": {},
                "cleaned": {}
              }
            }
          },
          "networkevents": {
            "type": "object",
            "added": "v25.12",
            "additionalProperties": true,
            "required": [
              "enabled",
              "cleaned"
            ],
            "properties": {
              "enabled": {
                "type": "boolean",
                "added": "v25.12",
                "description": [
                  "Whether autocleaning is enabled for networkevents."
                ]
              },
              "cleaned": {
                "type": "u64",
                "added": "v25.12",
                "description": [
                  "Total number of deletions done (ever)."
                ]
              }
            },
            "if": {
              "additionalProperties": true,
              "properties": {
                "enabled": {
                  "type": "boolean",
                  "enum": [
                    true
                  ]
                }
              }
            },
            "then": {
              "additionalProperties": false,
              "required": [
                "enabled",
                "age",
                "cleaned"
              ],
              "properties": {
                "enabled": {},
                "cleaned": {},
                "age": {
                  "added": "v25.12",
                  "type": "u64",
                  "description": [
                    "Age (in seconds) to clean networkevents."
                  ]
                }
              }
            },
            "else": {
              "additionalProperties": false,
              "required": [
                "enabled",
                "cleaned"
              ],
              "properties": {
                "enabled": {},
                "cleaned": {}
              }
            }
          }
        }
      }
    },
    "pre_return_value_notes": [
      "Note that the ages parameters are set by various `autoclean-...-age` parameters in your configuration: see lightningd-config(5)."
    ]
  },
  "author": [
    "Rusty Russell [rusty@rustcorp.com.au](mailto:rusty@rustcorp.com.au) is mainly responsible."
  ],
  "see_also": [
    "lightningd-config(5)",
    "lightning-listinvoices(7)",
    "lightning-listpays(7)",
    "lightning-listforwards(7)"
  ],
  "resources": [
    "Main web site: [https://github.com/ElementsProject/lightning](https://github.com/ElementsProject/lightning)"
  ],
  "examples": [
    {
      "request": {
        "id": "example:autoclean-status#1",
        "method": "autoclean-status",
        "params": {
          "subsystem": "expiredinvoices"
        }
      },
      "response": {
        "autoclean": {
          "expiredinvoices": {
            "enabled": true,
            "age": 300,
            "cleaned": 0
          }
        }
      }
    },
    {
      "request": {
        "id": "example:autoclean-status#2",
        "method": "autoclean-status",
        "params": {}
      },
      "response": {
        "autoclean": {
          "succeededforwards": {
            "enabled": false,
            "cleaned": 0
          },
          "failedforwards": {
            "enabled": false,
            "cleaned": 0
          },
          "succeededpays": {
            "enabled": false,
            "cleaned": 7
          },
          "failedpays": {
            "enabled": false,
            "cleaned": 0
          },
          "paidinvoices": {
            "enabled": false,
            "cleaned": 0
          },
          "expiredinvoices": {
            "enabled": true,
            "age": 300,
            "cleaned": 0
          }
        }
      }
    }
  ]
}
