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

> Run an automation for an explicitly emitted Convex event.

`convex.onEvent` exposes a signed endpoint for app-defined events emitted from a Convex action.

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

export default automation("Convex invoice paid", () => {
  const event = convex.onEvent({ name: "invoice.paid" })
  sendEmail({ subject: "Invoice paid", text: event.id })
})
```

Copy the trigger's `endpoint`, connect Convex with the deployment-key method, and set `AUTOMATE_AX_EVENT_ENDPOINT` and `AUTOMATE_AX_WEBHOOK_SECRET` in Convex. Use the same signing secret on the connected account. Emit from a Convex action:

```ts theme={null}
import { v } from "convex/values"
import { action } from "./_generated/server"
import { emitConvexEvent } from "automate.ax/convex/events"

export const emitInvoicePaid = action({
  args: { invoiceId: v.id("invoices") },
  handler: async (_context, { invoiceId }) => {
    await emitConvexEvent({
      endpoint: process.env.AUTOMATE_AX_EVENT_ENDPOINT!,
      id: invoiceId,
      name: "invoice.paid",
      payload: { invoiceId },
      signingSecret: process.env.AUTOMATE_AX_WEBHOOK_SECRET!,
    })
  },
})
```

`id` is the idempotency key: retries with the same ID produce one event. The signature covers the exact body, timestamp, and ID, and Automate.ax rejects requests older than five minutes. Trigger data contains `id`, `name`, `payload`, and `emittedAt`.
