These endpoints are system-only. They are authenticated with a shared
secret: every
/api/v1/cron/* route accepts CRON_SECRET or the legacy
CRON_TOKEN alias (whichever is set), and the legacy /api/cron/tick accepts
either as well. They are intended to be invoked by the in-process maintenance
scheduler, AWS EventBridge Scheduler, or an equivalent external cron.During pilot / initial deployment, EventBridge is typically not wired.
That means:/api/cron/tickexists and is callable, but is effectively unused until a scheduler starts hitting it.- Alert rules and report schedules will not fire automatically until a caller invokes this endpoint.
- Features like Run Now (reports) and on-demand alert evaluation work independently and do not require any cron wiring.
GET /api/v1/cron/export-interactions
Exports new interaction history rows for all active tenants as Hive-partitioned NDJSON files. Uses checkpoint tracking to export only rows created since the last run. Intended to be called by a cron scheduler (e.g., Vercel Cron Jobs, Kubernetes CronJob). Processes up to 10,000 rows per tenant per invocation.Authentication
Requires aCRON_SECRET token via either:
Authorization: Bearer <CRON_SECRET>headerX-Cron-Secret: <CRON_SECRET>header
File Layout
Response
Error Handling
If export fails for one tenant, other tenants continue processing. Failed tenants include anerror field and their checkpoint is marked as failed for retry on the next run.
In production, replace the local filesystem writes with S3 uploads via
@aws-sdk/client-s3. The file paths follow the same Hive-style partitioning scheme.GET /api/v1/cron/cleanup
Periodic data cleanup that removes expired suppressions, purges interaction history, interaction summaries, and decision traces according to each tenant’s retention configuration, and ensures future database partitions exist.Authentication
RequiresCRON_SECRET via Authorization: Bearer <secret> or X-Cron-Secret header. If CRON_SECRET is not set in the environment, the endpoint is fail-closed and rejects every request with 401.
Cleanup Operations
A failure inside one tenant’s purge is captured in
perTenantErrors and does not abort the run — the cron will continue with the remaining tenants and still emit a 200 response.
Response
Error Codes
GET /api/v1/cron/staging-janitor
Reaps leaked_flow_* staging tables — the per-run source/transform/branch
scratch tables the pipeline runtime materializes. Tables belonging to
in-flight runs are never dropped; only orphaned tables (the run row was
deleted, or the run finished before the retention cutoff) are removed. Tables
matching the _flow_* prefix but not the expected shape are counted as
unparseable and left in place.
Authentication
RequiresCRON_SECRET (or the legacy CRON_TOKEN alias) via
Authorization: Bearer <secret>. Fail-closed with 401 when neither is set.
Configuration
Response
droppedTables is capped at the first 50 entries in the response; the full
list is written to the log.
Error Codes
Invoked hourly by the in-process maintenance scheduler when a cron secret is
set (see Cron tier), and available to any
external scheduler (EventBridge, Kubernetes CronJob).
GET /api/v1/cron/approvals-expire
Sweeps every pending approval request and flips any that has aged pastAPPROVAL_MAX_AGE_HOURS (default 168 hours = 7 days) to status = "expired".
The operation is a single bulk database write and is fully idempotent — running
it again immediately is a no-op because no rows match the cutoff anymore.
Authentication
SameCRON_SECRET shared-header pattern as /api/v1/cron/cleanup:
Authorization: Bearer <CRON_SECRET>headerX-Cron-Secret: <CRON_SECRET>header
CRON_SECRET → the endpoint rejects all requests with 401 (fail-closed).
Configuration
Recommended schedule
Every 15 minutes is plenty — the operation is O(rows-to-expire) at the database with zero per-row work in Node. Once nothing is left to expire, each invocation is essentially free.Response
Error codes
GET /api/v1/cron/ai-autopilot
Decisioning Autopilot sweep. For every tenant it gathers experiment-promotion and model-drift proposals, persists them asAiRecommendation rows (source: "autopilot"), then acts according
to the tenant’s aiAutopilot.mode:
suggest— inbox only (proposals created, nothing applied).auto_gated— opens an ApprovalRequest for each proposal.auto— applies the change and writes an audit entry.
Authentication
CRON_SECRET via Authorization: Bearer <secret> or X-Cron-Secret: <secret>. Fail-closed with
401 when CRON_SECRET is unset.
Response
GET /api/v1/cron/ai-sentinel
Decision Sentinel sweep (recommended every 30 min). Computessuppression_rate and
empty_candidate_rate per tenant, writes System Health alerts on
breach, and — only for tenants with aiAutopilot.sentinelAutoPause = true — pauses active flows on
a hard breach.
Authentication
CRON_SECRET via Authorization: Bearer <secret> or X-Cron-Secret: <secret>. Fail-closed with
401 when CRON_SECRET is unset.
Response
Complete cron job catalog
Every/api/v1/cron/* job uses the same CRON_SECRET (or legacy CRON_TOKEN) bearer auth and
fails closed when the secret is unset. Jobs documented in full above are cross-linked; the rest
share the same auth and an { "ok": true, ... } response shape.
POST /api/cron/tick
System cron endpoint that evaluates every enabled alert rule and fires every due report schedule for every tenant in a single pass. The intended automated caller is AWS EventBridge, invoking the endpoint at whatever cadence matches yourwindowMinutes values (every 1–5 minutes is
typical). See EventBridge Setup for the
wiring path.
Pilot deployments: During pilot / initial rollout, EventBridge is
typically not wired. The endpoint still exists and can be invoked on
demand via
curl with a valid CRON_TOKEN — useful for development,
smoke testing, or one-off evaluation pushes. Without an external caller
hitting it on a cadence, alerts and scheduled reports do not fire
automatically; use the UI’s Run Now / Test buttons or the
per-entity /run-now APIs for immediate delivery.Authentication
Requires aCRON_TOKEN via either:
x-cron-token: <CRON_TOKEN>header (preferred)x-cron-secret: <CRON_TOKEN>header (legacy, same value)Authorization: Bearer <CRON_TOKEN>header
CRON_TOKEN → the endpoint rejects all requests with 401 (fail-closed).
Example
Response
Error Isolation
Per-tenant and per-rule errors are caught and reported in theerrors array;
a failing tenant does not abort the tick for other tenants:
ok is true only when errors is empty.