p202 system retention delete-before

Schedule the deletion of all click data from before a day (irreversible; previews and asks first)

New in 1.9.77Writescannot be staged
All commands

01Run it

Straight from the command's own help.

p202 system retention delete-before --date 2026-01-01 --dry-run
p202 system retention delete-before --date 2026-01-01

02What you get

Pick the shape you need. People get a table. Add --json, --csv or --ndjson for scripts, or -q for ids only. An AI agent gets compact JSON without asking. All output formats

03Build your command

Pick values and the command line writes itself, quoted and ready to paste.

p202 system retention delete-before

Set flags below; the command updates as you type.

04Flags

3 flags, plus the global flags every command takes.

FlagWhat it does
--datestringrequiredDelete click data from before this day, YYYY-MM-DD in the account's time zone (required)
--dry-runboolPreview what would be deleted and schedule nothing
--force, -fboolSchedule it without asking (the preview still runs)

05How it works

Schedules what Account › Settings › Advanced › "Delete click data from before" does: the cron job deletes, in batches, every click of every account on this install all of whose visits were recorded before midnight that begins --date (the account's time zone), from every click table. A click visited again that day or later is kept whole. Setup data is kept. It cannot be undone.

It always previews first (POST …/delete-before?dry_run=1) and says how many clicks and rows would go now, then asks (--force skips the question, never the preview; --dry-run ends with the preview). The write carries the cutoff_time the preview named and the server schedules only that, so it never schedules a different cutoff than was shown. Cannot be staged.

Needs an Admin or Super user key whose role has access_to_settings (as Account › Settings asks), and system:write.

06For agents

Running this from an agent

  • Read the same facts as JSON: p202 commands system retention delete-before --json.
  • With AI_AGENT, CLAUDECODE or another agent variable set, output is compact JSON and errors arrive on stderr as a JSON envelope with a hint.
  • Exit codes: 0 ok, 1 bad input, 2 auth, 3 network, 4 server error, 5 partial failure.
  • This command writes and cannot be staged: --staged is refused before anything is sent. Have a person run it, or give the agent a key without write scope.
p202 commands system retention delete-before --json
{
  "path": "p202 system retention delete-before",
  "use": "delete-before --date YYYY-MM-DD",
  "short": "Schedule the deletion of all click data from before a day (irreversible; previews and asks first)",
  "long": "Schedules what Account › Settings › Advanced › \"Delete click data from before\" does: the\ncron job deletes, in batches, every click of every account on this install all of whose\nvisits were recorded before midnight that begins --date (the account's time zone), from\nevery click table. A click visited again that day or later is kept whole. Setup data is\nkept. It cannot be undone.\n\nIt always previews first (POST …/delete-before?dry_run=1) and says how many clicks and rows\nwould go now, then asks (--force skips the question, never the preview; --dry-run ends with\nthe preview). The write carries the cutoff_time the preview named and the server schedules\nonly that, so it never schedules a different cutoff than was shown. Cannot be staged.\n\nNeeds an Admin or Super user key whose role has access_to_settings (as Account › Settings asks), and system:write.",
  "runnable": true,
  "example": "p202 system retention delete-before --date 2026-01-01 --dry-run\n  p202 system retention delete-before --date 2026-01-01",
  "flags": [
    {
      "name": "date",
      "type": "string",
      "default": "",
      "usage": "Delete click data from before this day, YYYY-MM-DD in the account's time zone (required)",
      "required": true
    },
    {
      "name": "dry-run",
      "type": "bool",
      "default": "false",
      "usage": "Preview what would be deleted and schedule nothing",
      "required": false
    },
    {
      "name": "force",
      "shorthand": "f",
      "type": "bool",
      "default": "false",
      "usage": "Schedule it without asking (the preview still runs)",
      "required": false
    }
  ]
}