Skip to content

Automations

Automations

Every automation is one default export at exactly src/automation/+<lower_snake_case>.ts. The filename is the canonical automation ID. Plural directories, camel case, kebab case, missing +, and nested files are rejected.

Definition

import { defineAutomation } from '@norbital-ai/pod/authoring';
import type { Api } from './$types.js';

export default defineAutomation(
  { schedule: '0 6 * * *' },
  async (api: Api) => {
    const sites = await api.db.query.sites.findMany({ limit: 250 });
    return { count: sites.length };
  }
);

Save this declaration as src/automation/+daily_site_digest.ts.

Triggers

  • Schedule — cron execution after the automation is deployed
  • Collection event — background work triggered by collection changes

Use hooks for same-transaction mutation logic and remotes for request/response endpoints. Automation schedule changes take effect only after the new build is live.