{
  "name": "paperless alte Dokumente löschen",
  "nodes": [
    {
      "parameters": {},
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        0
      ],
      "id": "ad088051-7a7f-48a8-b746-06e3c9014f2c",
      "name": "When clicking ‘Execute workflow’"
    },
    {
      "parameters": {
        "url": "=http://paperless.example.local:8010/api/documents/",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "custom_field_query",
              "value": "=[\"Dokument läuft ab\",\"lte\",\"{{ $now.format(\"yyyy-MM-dd\") }}\"]"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.3,
      "position": [
        208,
        0
      ],
      "id": "2980810e-972d-4bd5-8478-34d811db0490",
      "name": "HTTP Request",
      "credentials": {
        "httpHeaderAuth": {
          "id": "zQn0ENjxIiA12bCK",
          "name": "Paperless Authentication"
        }
      }
    },
    {
      "parameters": {
        "fieldToSplitOut": "results",
        "options": {}
      },
      "type": "n8n-nodes-base.splitOut",
      "typeVersion": 1,
      "position": [
        624,
        0
      ],
      "id": "ed6a53b3-abfb-486e-8433-010b8ba6574c",
      "name": "Split Out"
    },
    {
      "parameters": {
        "fieldsToAggregate": {
          "fieldToAggregate": [
            {
              "fieldToAggregate": "id"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.aggregate",
      "typeVersion": 1,
      "position": [
        832,
        0
      ],
      "id": "baaa02a0-b6aa-41e7-9a0d-e7cd5dc452c3",
      "name": "Aggregate"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=http://paperless.example.local:8010/api/documents/bulk_edit/",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {}
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"documents\": [{{ $json.id }}],\n  \"method\": \"delete\"\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.3,
      "position": [
        1056,
        0
      ],
      "id": "05ebbced-796b-468f-b8a2-d7c2a58d5c16",
      "name": "Delete Documents",
      "credentials": {
        "httpHeaderAuth": {
          "id": "zQn0ENjxIiA12bCK",
          "name": "Paperless Authentication"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 3
          },
          "conditions": [
            {
              "id": "945b4e81-3b03-4f52-a5a6-36351772201a",
              "leftValue": "={{ $json.count }}",
              "rightValue": 0,
              "operator": {
                "type": "number",
                "operation": "gt"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.3,
      "position": [
        416,
        0
      ],
      "id": "91499664-f6fb-45d3-99b6-da437040b64b",
      "name": "If"
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 1
            }
          ]
        }
      },
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.3,
      "position": [
        0,
        176
      ],
      "id": "c4a9c836-b2c9-4867-b482-2e091e8455f1",
      "name": "Schedule Trigger"
    }
  ],
  "pinData": {},
  "connections": {
    "When clicking ‘Execute workflow’": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out": {
      "main": [
        [
          {
            "node": "Aggregate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate": {
      "main": [
        [
          {
            "node": "Delete Documents",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If": {
      "main": [
        [
          {
            "node": "Split Out",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate",
    "availableInMCP": false
  },
  "versionId": "efc0ae30-8143-46a2-9437-3b873ddf8b49",
  "meta": {
    "instanceId": ""
  },
  "nodeGroups": [],
  "id": "26GTrHE1lMWkRK13TQzYT",
  "tags": []
}