# Design: Scheduled exports - Author: Platform team - Reviewers: Backend, Security - Status: In review - Last updated: 2026-11-30 ## Summary Workspace owners can schedule a CSV export of their reports to run daily or weekly and arrive by email or in an S3 bucket they own. This document proposes a scheduler table, a worker job and a delivery step, and estimates three weeks for one engineer. ## Background Customers export reports by hand from the Reports page today. Twelve of our 40 largest accounts asked for automatic exports last quarter, and four wrote scripts against our API to do it, which causes most of our API rate-limit errors. ## Goals - An owner can create, pause and delete a schedule for any saved report. - Exports arrive within 15 minutes of the scheduled time. - A failed delivery is retried and the owner is told when it gives up. ## Non-goals - Formats other than CSV. XLSX can follow once this ships. - Schedules more frequent than daily. - Delivery to destinations other than email and S3. ## Proposed design ### Data model A new `export_schedules` table stores the report, the cadence (`daily` or `weekly` with a weekday), the time and time zone, the destination and `next_run_at`. Destinations store an S3 bucket and role ARN, never access keys. ### Scheduling A worker runs every minute, claims schedules with `next_run_at <= now()` using `FOR UPDATE SKIP LOCKED`, enqueues one export job per schedule and advances `next_run_at`. Computing the next run in the schedule's time zone keeps exports at the same local time across daylight saving changes. ### Export and delivery The export job reuses the existing CSV generator. Files under 10 MB are attached to the email. Larger files are uploaded to our storage and emailed as a link that expires after 7 days. S3 delivery assumes the customer's role with an external ID and uploads with `PutObject`. ### Failure handling Delivery retries three times with exponential backoff. After the last failure the schedule is paused and the owner gets an email and an in-app notification that says what failed. ## Alternatives considered - **A cron service per schedule** (such as EventBridge Scheduler). Precise timing, but adds a cloud dependency that self-hosted customers don't have. - **Let customers keep scripting the API.** No work for us, but rate-limit errors keep growing. ## Security and privacy Exports contain customer financial data. Email links are signed and single-workspace. S3 delivery uses role assumption with an external ID, so we hold no customer credentials. Every run is written to the audit log. ## Rollout 1. Ship behind a feature flag to five accounts that asked for it. 2. Watch delivery success rate and export duration for two weeks. 3. Enable for all paid plans and announce in the changelog. ## Open questions - Do we count scheduled exports against the API rate limit? - Should owners be able to send to more than one destination per schedule?