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

# Events & Event Sources (event-triggered tasks)

> Make your AI workforce reactive — fire Tasks automatically when something happens. Learn internal Events, event_conditions, and third-party Event Sources, and how they differ from webhooks.

**Events make your [Tasks](/developer/guides/tasks) reactive: instead of running on a clock, an event-triggered task fires the moment something happens.** A buyer pays, a form is submitted, a connected app reports a change — and the agent goes to work. Crevio recognizes two kinds of triggers: **internal Events** (things that happen inside your Crevio account) and **Event Sources** (things that happen in third-party apps you connect). Both drive Tasks with `trigger_type: event`.

## Three things that sound alike — keep them straight

| Concept                                    | Direction                    | What it does                                                                                    |
| ------------------------------------------ | ---------------------------- | ----------------------------------------------------------------------------------------------- |
| **Events**                                 | Crevio → your agent          | Internal signals that **trigger Tasks** to run inside Crevio.                                   |
| **Event Sources**                          | Third-party app → your agent | A connected app's events that **trigger Tasks**, so external activity can drive your workforce. |
| **[Webhooks](/developer/guides/webhooks)** | Crevio → your server         | HTTP notifications pushed to **your own backend** so your code can react.                       |

The rule of thumb: **Events and Event Sources trigger Crevio's AI; webhooks notify your code.** The two systems share an event vocabulary (e.g. `order.paid` exists in both) but do different jobs — and you can use both for the same event.

## Internal Events

`GET /v1/events` lists the events you can subscribe a Task to, each with a description, plus an `external` array describing third-party triggers available through Event Sources.

```bash theme={null}
curl https://api.crevio.co/v1/events \
  -H "Authorization: Bearer YOUR_API_TOKEN"
```

The subscribable internal events:

| Domain                | Events                                                                                                                                                 |
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **Leads & forms**     | `lead.created`, `form_submission.created`, `form_submission.confirmed`                                                                                 |
| **Customers**         | `customer.confirmed`                                                                                                                                   |
| **Checkout & orders** | `checkout.created`, `order.created`, `order.paid`                                                                                                      |
| **Refunds**           | `refund.created`, `refund.updated`                                                                                                                     |
| **Invoices**          | `invoice.created`, `invoice.paid`, `invoice.past_due`, `invoice.voided`                                                                                |
| **Products**          | `product.created`, `product.updated`                                                                                                                   |
| **AI tasks**          | `task.created`, `task_run.completed`, `task_run.failed`, `task_run.needs_input`                                                                        |
| **Jobs**              | `job.completed`, `job.failed`                                                                                                                          |
| **Email**             | `email_message.received`, `email_message.sent`, `email_message.delivered`, `email_message.bounced`, `email_message.complained`, `email_message.failed` |

## Triggering a Task from an event

Create a Task with `trigger_type: event` and use `event_conditions` to say which event(s) it fires on (and, optionally, what must match for it to run).

```bash theme={null}
curl -X POST https://api.crevio.co/v1/tasks \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Onboard paid buyers",
    "prompt": "When an order is paid, send the buyer a personalized thank-you email referencing what they bought, then add them to the onboarding email sequence.",
    "trigger_type": "event",
    "event_conditions": { "event": "order.paid" },
    "agent": "business",
    "approval_mode": "autonomous",
    "delivery_methods": ["notification"]
  }'
```

Every time an order is paid in your account, a new [Task Run](/developer/guides/tasks#task-runs) starts, the agent receives the event context, and it carries out the prompt. Use `approval_mode: supervised` if you want to approve the agent's actions before they take effect.

<Tip>
  Combine event triggers with autonomy: an `autonomous` event-task is a hands-off automation, while a `supervised` one is an assistant that drafts the response and waits for your go-ahead.
</Tip>

## Event Sources (third-party triggers)

The `external` array in `GET /v1/events` is currently driven by **Event Sources** — connectors that let events from third-party apps trigger your Tasks. This is how activity *outside* Crevio (a new row in a sheet, a message in a channel, a payment in another tool) can put your AI workforce to work.

### 1. Discover what you can connect

```bash theme={null}
curl https://api.crevio.co/v1/event_sources/available \
  -H "Authorization: Bearer YOUR_API_TOKEN"
```

Each available source describes a `vendor_component_id`, the `event_name`(s) it emits, and the `configured_props` it needs (the configuration for that specific trigger — accounts, channels, filters, etc.).

### 2. Create the Event Source

```bash theme={null}
curl -X POST https://api.crevio.co/v1/event_sources \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "vendor_component_id": "VENDOR_COMPONENT_ID",
    "event_name": "new_row",
    "configured_props": { "sheet_id": "abc123" }
  }'
```

Once created, the source emits events into Crevio. Point an event-Task at it via `event_conditions`, and external activity now drives your agent the same way internal events do.

### Manage event sources

```bash theme={null}
# List your connected sources
curl https://api.crevio.co/v1/event_sources \
  -H "Authorization: Bearer YOUR_API_TOKEN"

# Remove one
curl -X DELETE https://api.crevio.co/v1/event_sources/SOURCE_ID \
  -H "Authorization: Bearer YOUR_API_TOKEN"
```

## Worked example: the same event, three ways

Say you want everything to happen when **`order.paid`** fires:

1. **Trigger the agent** — an event-Task (`trigger_type: event`, `event_conditions: { "event": "order.paid" }`) sends a personalized welcome and starts onboarding.
2. **React in your own code** — a [webhook endpoint](/developer/guides/webhooks) subscribed to `order.paid` provisions the buyer in your external system.
3. **React to external activity** — an Event Source lets a payment in a *connected app* trigger a Crevio task too.

Events and webhooks are independent and complementary: use Events to put Crevio's AI to work, and webhooks to keep your own systems in sync.

## Next steps

<CardGroup cols={2}>
  <Card title="Tasks (your AI workforce)" icon="list-check" href="/developer/guides/tasks">
    Triggers, agents, autonomy modes, and responding to supervised runs.
  </Card>

  <Card title="Webhooks" icon="webhook" href="/developer/guides/webhooks">
    Notify your own server when events happen — and verify signatures.
  </Card>

  <Card title="AI & Agents overview" icon="robot" href="/developer/guides/agents-overview">
    How Events fit into Crevio's broader agentic model.
  </Card>

  <Card title="MCP Server" icon="robot" href="/developer/mcp">
    Let an agent discover and create event sources in code.
  </Card>
</CardGroup>
