> ## 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 event

> Run an automation for any Convex document lifecycle change.

`convex.onDocumentEvent` watches one table and emits created, updated, and deleted document changes.

```ts automations/audit-convex-documents.automation.ts theme={null}
import { automation } from "automate.ax"
import { convex } from "automate.ax/convex"

export default automation("Audit Convex documents", () => {
  const event = convex.onDocumentEvent({ table: "messages" })
  // Route the Convex document event by action.
})
```

## Options

| Option       | Type                                              | Required | Default         | Description                                                |
| ------------ | ------------------------------------------------- | -------- | --------------- | ---------------------------------------------------------- |
| `table`      | `string`                                          | Yes      | None            | Convex table name.                                         |
| `component`  | `string`                                          | No       | `""`            | Component path; the empty path selects the root component. |
| `deployment` | `string`                                          | No       | `prod`          | Deployment reference for project OAuth.                    |
| `account`    | `string \| IntegrationAccountReference<"convex">` | No       | Project default | Connected Convex account.                                  |

Trigger data includes `action`, `component`, `table`, `documentId`, `revision: bigint`, and `document`. `document` is `null` for deletions.

Automate.ax uses [Convex Data Sync](https://docs.convex.dev/production/integrations/streaming-import-export), which requires a Convex Pro deployment and `deployment:data:view`. It establishes the initial table baseline without firing events and resumes from a durable cursor. A Convex import or table replacement also re-establishes the baseline without producing a burst of false creates.
