Maintenance
Cleanup expired sessions, nightly
Sweep your sessions, tokens, password resets, and rate-limit buckets every night.
Use this template →schedule: 30 2 * * *
Why this exists
Most apps accumulate dead state — expired sessions, used password-reset tokens, stale magic links, rate-limit windows. A nightly sweep keeps the table small and queries fast. This template fires nightly at 02:30 UTC (off-peak for most regions) and POSTs to a cleanup endpoint on your backend.
Every app with an auth system over a year old. The 'just delete old sessions' job often gets written but never scheduled — this fixes that.
When to use it
- You have sessions, password reset tokens, OAuth state, or temporary uploads in your DB
- Your sessions table is growing forever and you've never cleaned it
- You want predictable nightly maintenance instead of cleanup-on-read
Common variations
- Weekly instead of nightly if your volume is low
- Chain multiple cleanup jobs (sessions, then password resets, then audit logs)
- Add a soft-delete sweep (rows older than 30 days) before hard delete
Setup in 4 steps
- 01Write a cleanup endpoint that DELETEs expired rows by index
- 02Make it idempotent and fast — should run in under 30 seconds
- 03Use this template — it fires at 02:30 UTC nightly
- 04Optional: log how many rows were deleted so you can track buildup
Template configuration
- Name
- nightly-cleanup
- Schedule
- 30 2 * * *
- Method
- POST
- Timeout
- 60s
- Max retries
- 1
- Retry delay
- 300s
Webhook URL
https://api.example.com/internal/cleanupBody
{
"tables": [
"sessions",
"password_resets",
"magic_links"
]
}Ready
Use this template in 30 seconds.
Sign in, edit the webhook URL and any secrets, hit create. The job is live on the next tick.