{
  "workflow": {
    "id": 6122,
    "name": "Auto-clean Gmail spam folder - monthly using Gmail API",
    "views": 521,
    "recentViews": 0,
    "totalViews": 521,
    "createdAt": "2025-07-18T07:42:32.989Z",
    "description": "This automated n8n workflow uses the Gmail API to clean the spam folder by permanently deleting all emails on the first day of each month. The system ensures efficient email management and improves Gmail storage by removing unwanted spam emails.\n\n## Good to Know\n- Gmail API rate limits should be respected to ensure proper email fetching\n- A short delay is introduced to avoid hitting API limits\n- The workflow runs automatically on the first day of every month\n- Improves Gmail hygiene by removing spam emails\n\n## How It Works\n- **Monthly Trigger (1st Day)** - Starts the workflow automatically on the first of every month to perform email cleanup\n- **Fetch Gmail Emails** - Uses Gmail API to retrieve all emails in the spam folder for the Gmail account\n- **Pause Before Deletion (5s)** - Introduces a short delay to avoid hitting Gmail's API rate limits and ensure all emails are fetched properly\n- **Delete Fetched SPAM Emails** - Permanently deletes all retrieved emails from the spam folder to free up Gmail space and improve email hygiene\n\n## How to Use\n- Import the workflow into n8n\n- Configure Gmail API credentials for access\n- Test the workflow on a sample date to verify email fetching and deletion\n- Adjust the pause duration if needed based on API limits\n- Monitor the workflow to ensure proper spam cleanup\n\n## Requirements\n- Gmail API credentials\n\n## Customizing This Workflow\n- Adjust the pause duration in the Pause node to align with Gmail API rate limits\n- Modify the trigger schedule if a different cleanup frequency is preferred",
    "workflow": {
      "id": "hdBpjh9528K5FyWV",
      "meta": {
        "instanceId": "dd69efaf8212c74ad206700d104739d3329588a6f3f8381a46a481f34c9cc281",
        "templateCredsSetupCompleted": true
      },
      "name": "Auto-Clean Gmail Spam Folder Monthly with Gmail API",
      "tags": [],
      "nodes": [
        {
          "id": "e214c477-6d39-426f-8a34-cd38bb6f5ae2",
          "name": "Monthly Trigger (1st Day)",
          "type": "n8n-nodes-base.scheduleTrigger",
          "position": [
            -380,
            120
          ],
          "parameters": {
            "rule": {
              "interval": [
                {
                  "field": "months",
                  "triggerAtHour": 6
                }
              ]
            }
          },
          "typeVersion": 1.2
        },
        {
          "id": "e8eb600c-9b45-44e2-8ee6-409c9b61b171",
          "name": "Fetch SPAM Emails (Gmail)",
          "type": "n8n-nodes-base.gmail",
          "position": [
            -160,
            120
          ],
          "webhookId": "c47419de-278c-40d1-a5da-c9414d3f89c6",
          "parameters": {
            "filters": {
              "labelIds": [
                "SPAM"
              ]
            },
            "operation": "getAll",
            "returnAll": true
          },
          "credentials": {
            "gmailOAuth2": {
              "id": "credential-id",
              "name": "gmailOAuth2 Credential"
            }
          },
          "typeVersion": 2.1
        },
        {
          "id": "96a0fd3c-63bd-48f4-87d7-7eda528b50a3",
          "name": "Pause Before Deletion (5s)",
          "type": "n8n-nodes-base.wait",
          "position": [
            60,
            120
          ],
          "webhookId": "0b2f9902-fd7b-4a98-87a3-f36c74b0af32",
          "parameters": {},
          "typeVersion": 1.1
        },
        {
          "id": "e172bbb8-069c-4c68-b72f-cf2a7f304f0b",
          "name": "Delete Fetched SPAM Emails",
          "type": "n8n-nodes-base.gmail",
          "position": [
            280,
            120
          ],
          "webhookId": "46b0fe0f-cc00-4994-8364-9048c888e9ef",
          "parameters": {
            "messageId": "={{ $json.id }}",
            "operation": "delete"
          },
          "credentials": {
            "gmailOAuth2": {
              "id": "credential-id",
              "name": "gmailOAuth2 Credential"
            }
          },
          "typeVersion": 2.1
        },
        {
          "id": "a07dd87f-1216-44de-91b8-a6d7d36877e8",
          "name": "Sticky Note",
          "type": "n8n-nodes-base.stickyNote",
          "position": [
            -415,
            -80
          ],
          "parameters": {
            "color": 3,
            "width": 170,
            "height": 360,
            "content": "Starts the workflow automatically on the 1st of every month to perform email cleanup."
          },
          "typeVersion": 1
        },
        {
          "id": "0de7be15-2ebe-4c28-ab52-59f35f6a3135",
          "name": "Sticky Note1",
          "type": "n8n-nodes-base.stickyNote",
          "position": [
            -200,
            -80
          ],
          "parameters": {
            "color": 5,
            "width": 170,
            "height": 360,
            "content": "Uses Gmail API to retrieve all emails in the SPAM folder for the authenticated Gmail account."
          },
          "typeVersion": 1
        },
        {
          "id": "11c0f2f1-1480-4512-ad4d-1d9544838e2c",
          "name": "Sticky Note2",
          "type": "n8n-nodes-base.stickyNote",
          "position": [
            20,
            -80
          ],
          "parameters": {
            "width": 170,
            "height": 360,
            "content": "Introduces a short delay to avoid hitting Gmail’s API rate limits or ensure all emails are fetched properly."
          },
          "typeVersion": 1
        },
        {
          "id": "0600f919-8315-431a-8420-9c0931b9c097",
          "name": "Sticky Note3",
          "type": "n8n-nodes-base.stickyNote",
          "position": [
            240,
            -80
          ],
          "parameters": {
            "color": 4,
            "width": 170,
            "height": 360,
            "content": "Permanently deletes all emails retrieved from the SPAM folder to free up Gmail space and improve email hygiene."
          },
          "typeVersion": 1
        }
      ],
      "active": false,
      "pinData": {},
      "settings": {
        "executionOrder": "v1"
      },
      "versionId": "ad4a18bb-1aff-4520-9e68-4844bf365d8f",
      "connections": {
        "Fetch SPAM Emails (Gmail)": {
          "main": [
            [
              {
                "node": "Pause Before Deletion (5s)",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Monthly Trigger (1st Day)": {
          "main": [
            [
              {
                "node": "Fetch SPAM Emails (Gmail)",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Pause Before Deletion (5s)": {
          "main": [
            [
              {
                "node": "Delete Fetched SPAM Emails",
                "type": "main",
                "index": 0
              }
            ]
          ]
        }
      }
    },
    "lastUpdatedBy": 29,
    "workflowInfo": {
      "nodeCount": 8,
      "nodeTypes": {
        "n8n-nodes-base.wait": {
          "count": 1
        },
        "n8n-nodes-base.gmail": {
          "count": 2
        },
        "n8n-nodes-base.stickyNote": {
          "count": 4
        },
        "n8n-nodes-base.scheduleTrigger": {
          "count": 1
        }
      }
    },
    "status": "published",
    "user": {
      "name": "Oneclick AI Squad",
      "username": "oneclick-ai",
      "bio": "The AI Squad Initiative is a pioneering effort to build, automate and scale AI-powered workflows using n8n.io. Our mission is to help individuals and businesses integrate AI agents seamlessly into their daily operations  from automating tasks and enhancing productivity to creating innovative, intelligent solutions. We design modular, reusable AI workflow templates that empower creators, developers and teams to supercharge their automation with minimal effort and maximum impact.",
      "verified": true,
      "links": [
        "https://www.oneclickitsolution.com/"
      ],
      "avatar": "https://gravatar.com/avatar/848fca91367142f65f9e5c55d64e5c9952b160d7b060d103b52aa343c6bc7b3d?r=pg&d=retro&size=200"
    },
    "nodes": [
      {
        "id": 356,
        "icon": "file:gmail.svg",
        "name": "n8n-nodes-base.gmail",
        "codex": {
          "data": {
            "alias": [
              "email",
              "human",
              "form",
              "wait",
              "hitl",
              "approval"
            ],
            "resources": {
              "generic": [
                {
                  "url": "https://n8n.io/blog/why-business-process-automation-with-n8n-can-change-your-daily-life/",
                  "icon": "🧬",
                  "label": "Why business process automation with n8n can change your daily life"
                },
                {
                  "url": "https://n8n.io/blog/supercharging-your-conference-registration-process-with-n8n/",
                  "icon": "🎫",
                  "label": "Supercharging your conference registration process with n8n"
                },
                {
                  "url": "https://n8n.io/blog/no-code-ecommerce-workflow-automations/",
                  "icon": "store",
                  "label": "6 e-commerce workflows to power up your Shopify s"
                },
                {
                  "url": "https://n8n.io/blog/how-to-get-started-with-crm-automation-and-no-code-workflow-ideas/",
                  "icon": "👥",
                  "label": "How to get started with CRM automation (with 3 no-code workflow ideas"
                },
                {
                  "url": "https://n8n.io/blog/automate-google-apps-for-productivity/",
                  "icon": "💡",
                  "label": "15 Google apps you can combine and automate to increase productivity"
                },
                {
                  "url": "https://n8n.io/blog/your-business-doesnt-need-you-to-operate/",
                  "icon": " 🖥️",
                  "label": "Hey founders! Your business doesn't need you to operate"
                },
                {
                  "url": "https://n8n.io/blog/using-automation-to-boost-productivity-in-the-workplace/",
                  "icon": "💪",
                  "label": "Using Automation to Boost Productivity in the Workplace"
                }
              ],
              "primaryDocumentation": [
                {
                  "url": "https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.gmail/"
                }
              ],
              "credentialDocumentation": [
                {
                  "url": "https://docs.n8n.io/integrations/builtin/credentials/google/oauth-single-service/"
                }
              ]
            },
            "categories": [
              "Communication",
              "HITL"
            ],
            "nodeVersion": "1.0",
            "codexVersion": "1.0",
            "subcategories": {
              "HITL": [
                "Human in the Loop"
              ]
            }
          }
        },
        "group": "[\"transform\"]",
        "defaults": {
          "name": "Gmail"
        },
        "iconData": {
          "type": "file",
          "fileBuffer": "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNTYiIGhlaWdodD0iMTkzIiBwcmVzZXJ2ZUFzcGVjdFJhdGlvPSJ4TWlkWU1pZCI+PHBhdGggZmlsbD0iIzQyODVGNCIgZD0iTTU4LjE4MiAxOTIuMDVWOTMuMTRMMjcuNTA3IDY1LjA3NyAwIDQ5LjUwNHYxMjUuMDkxYzAgOS42NTggNy44MjUgMTcuNDU1IDE3LjQ1NSAxNy40NTV6Ii8+PHBhdGggZmlsbD0iIzM0QTg1MyIgZD0iTTE5Ny44MTggMTkyLjA1aDQwLjcyN2M5LjY1OSAwIDE3LjQ1NS03LjgyNiAxNy40NTUtMTcuNDU1VjQ5LjUwNWwtMzEuMTU2IDE3LjgzNy0yNy4wMjYgMjUuNzk4eiIvPjxwYXRoIGZpbGw9IiNFQTQzMzUiIGQ9Im01OC4xODIgOTMuMTQtNC4xNzQtMzguNjQ3IDQuMTc0LTM2Ljk4OUwxMjggNjkuODY4bDY5LjgxOC01Mi4zNjQgNC42NyAzNC45OTItNC42NyA0MC42NDRMMTI4IDE0NS41MDR6Ii8+PHBhdGggZmlsbD0iI0ZCQkMwNCIgZD0iTTE5Ny44MTggMTcuNTA0VjkzLjE0TDI1NiA0OS41MDRWMjYuMjMxYzAtMjEuNTg1LTI0LjY0LTMzLjg5LTQxLjg5LTIwLjk0NXoiLz48cGF0aCBmaWxsPSIjQzUyMjFGIiBkPSJtMCA0OS41MDQgMjYuNzU5IDIwLjA3TDU4LjE4MiA5My4xNFYxNy41MDRMNDEuODkgNS4yODZDMjQuNjEtNy42NiAwIDQuNjQ2IDAgMjYuMjN6Ii8+PC9zdmc+"
        },
        "displayName": "Gmail",
        "typeVersion": 2,
        "nodeCategories": [
          {
            "id": 6,
            "name": "Communication"
          },
          {
            "id": 28,
            "name": "HITL"
          }
        ]
      },
      {
        "id": 514,
        "icon": "fa:pause-circle",
        "name": "n8n-nodes-base.wait",
        "codex": {
          "data": {
            "alias": [
              "pause",
              "sleep",
              "delay",
              "timeout"
            ],
            "resources": {
              "generic": [
                {
                  "url": "https://n8n.io/blog/how-to-get-started-with-crm-automation-and-no-code-workflow-ideas/",
                  "icon": "👥",
                  "label": "How to get started with CRM automation (with 3 no-code workflow ideas"
                },
                {
                  "url": "https://n8n.io/blog/aws-workflow-automation/",
                  "label": "7 no-code workflow automations for Amazon Web Services"
                }
              ],
              "primaryDocumentation": [
                {
                  "url": "https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.wait/"
                }
              ]
            },
            "categories": [
              "Core Nodes"
            ],
            "nodeVersion": "1.0",
            "codexVersion": "1.0",
            "subcategories": {
              "Core Nodes": [
                "Helpers",
                "Flow"
              ]
            }
          }
        },
        "group": "[\"organization\"]",
        "defaults": {
          "name": "Wait",
          "color": "#804050"
        },
        "iconData": {
          "icon": "pause-circle",
          "type": "icon"
        },
        "displayName": "Wait",
        "typeVersion": 1,
        "nodeCategories": [
          {
            "id": 9,
            "name": "Core Nodes"
          }
        ]
      },
      {
        "id": 565,
        "icon": "fa:sticky-note",
        "name": "n8n-nodes-base.stickyNote",
        "codex": {
          "data": {
            "alias": [
              "Comments",
              "Notes",
              "Sticky"
            ],
            "categories": [
              "Core Nodes"
            ],
            "nodeVersion": "1.0",
            "codexVersion": "1.0",
            "subcategories": {
              "Core Nodes": [
                "Helpers"
              ]
            }
          }
        },
        "group": "[\"input\"]",
        "defaults": {
          "name": "Sticky Note",
          "color": "#FFD233"
        },
        "iconData": {
          "icon": "sticky-note",
          "type": "icon"
        },
        "displayName": "Sticky Note",
        "typeVersion": 1,
        "nodeCategories": [
          {
            "id": 9,
            "name": "Core Nodes"
          }
        ]
      },
      {
        "id": 839,
        "icon": "fa:clock",
        "name": "n8n-nodes-base.scheduleTrigger",
        "codex": {
          "data": {
            "alias": [
              "Time",
              "Scheduler",
              "Polling",
              "Cron",
              "Interval"
            ],
            "resources": {
              "generic": [],
              "primaryDocumentation": [
                {
                  "url": "https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.scheduletrigger/"
                }
              ]
            },
            "categories": [
              "Core Nodes"
            ],
            "nodeVersion": "1.0",
            "codexVersion": "1.0"
          }
        },
        "group": "[\"trigger\",\"schedule\"]",
        "defaults": {
          "name": "Schedule Trigger",
          "color": "#31C49F"
        },
        "iconData": {
          "icon": "clock",
          "type": "icon"
        },
        "displayName": "Schedule Trigger",
        "typeVersion": 1,
        "nodeCategories": [
          {
            "id": 9,
            "name": "Core Nodes"
          }
        ]
      }
    ],
    "categories": [
      {
        "id": 43,
        "name": "Personal Productivity"
      }
    ],
    "image": []
  }
}