> ## Documentation Index
> Fetch the complete documentation index at: https://docs.automate.ax/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Automate.ax automations are TypeScript programs.
> Use Bun for installation and command examples.
> Use Automate.ax for the product name and automate.ax for the package, CLI, and domain.
> Treat documented public APIs as current; do not invent transitional or deprecated names.

# On document created

> Run an automation when Convex creates a document.

`convex.onDocumentCreated` watches one table and starts the automation for documents that appear after the initial Data Sync baseline.

```ts automations/new-convex-message.automation.ts theme={null}
import { automation, sendEmail } from "automate.ax"
import { convex } from "automate.ax/convex"

export default automation("New Convex message", () => {
  const event = convex.onDocumentCreated({ table: "messages" })
  sendEmail({ subject: "New message", text: event.documentId })
})
```

Options are `table`, optional `component` (default `""`), optional OAuth `deployment` (default `prod`), and optional `account`. Trigger data includes the complete `document`, `documentId`, `revision`, `table`, `component`, and `action: "created"`.

This trigger requires Convex Pro Data Sync and `deployment:data:view`. Existing documents are recorded silently when you first deploy the automation.
