# Delete inactive customers older than N years

Runs monthly, finds customers older than a configurable age with no orders, and deletes them only when deletion is explicitly enabled.

Canonical URL: https://templates.jsworkflows.com/templates/delete-inactive-customers-older-than-5-years-monthly/

## When to use this template

This template is built for Shopify stores using the JsWorkflows app.

Use this template when you want a ready-made workflow for this use case: Runs monthly, finds customers older than a configurable age with no orders, and deletes them only when deletion is explicitly enabled.

It is designed for Shopify customer operations and gives you a production-ready starting point instead of building the automation from scratch.

This workflow uses the scheduled trigger model and starts from the "Monthly schedule" trigger. It includes setup fields for merchant-facing values, so you can configure the workflow before installing it.

## Metadata

- Category: Customers
- Trigger: Monthly schedule
- Workflow type: Scheduled
- Complexity: advanced
- Usage class: growth-friendly

## Connected services

- None

## Additional Shopify scopes

- None

## Setup fields

- Customer age in years (`CUSTOMER_AGE_YEARS`)
  - Type: number
  - Storage: config
  - Required: yes
  - Description: Delete only customers created more than this many years ago.
- Maximum customers per run (`MAX_CUSTOMERS_PER_RUN`)
  - Type: number
  - Storage: config
  - Required: yes
  - Description: Safety cap for how many eligible customers this workflow can process in one monthly run.
- Delete enabled (`DELETE_ENABLED`)
  - Type: checkbox
  - Storage: config
  - Required: yes
  - Description: When off, the workflow only logs customers that would be deleted. Turn on after reviewing a dry run.

## Setup guide

## Before you start

This template is destructive when `Delete enabled` is turned on. Run it once with deletion disabled and review the logs before enabling deletion.

## How it works

- Trigger: monthly scheduled workflow
- Searches customers using `orders_count:0` and `customer_date`
- Processes customers page by page
- Rechecks each customer before deletion using their current `createdAt`, `numberOfOrders`, and `canDelete` values
- Deletes only customers that still match the criteria and are deletable

## Configure in setup

- `Customer age in years`: minimum customer account age before deletion
- `Maximum customers per run`: safety cap for one monthly run
- `Delete enabled`: off means dry-run logging only; on performs deletion

## Notes

- No extra Shopify scopes are requested by this template because customer write access is already part of the app's default install scopes.
- If a customer has placed an order, Shopify will not allow deletion and this workflow also skips them before attempting deletion.

