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

# Run an autonomous outreach agent

> Schedule a Task that researches leads on the web and drafts outreach email — with supervised approval before anything sends.

**A Task is an AI worker you schedule once and let run on its own.** This recipe creates a recurring Task that uses live web research to find leads, drafts personalized outreach email, and surfaces each run for your approval before anything goes out.

<Note>
  Tasks are your AI workforce. Each scheduled execution is a **Task Run** you can inspect. With `approval_mode: "supervised"`, runs that want to act pause as `needs_input` and show up in your dashboard for sign-off. See [Tasks](/developer/guides/tasks).
</Note>

## Recipe

<Steps>
  <Step title="Create the outreach Task">
    The `prompt` is the agent's standing instructions. `trigger_type: "cron"` plus a `cron_expression` schedules it; `approval_mode: "supervised"` means it won't send anything without you.

    ```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": "Weekly lead outreach",
        "agent": "business",
        "trigger_type": "cron",
        "cron_expression": "0 9 * * 1",
        "timezone": "America/New_York",
        "approval_mode": "supervised",
        "delivery_methods": ["email"],
        "prompt": "Each Monday, use web research to find 10 local businesses — dentists, law firms, and restaurants — whose websites look outdated or aren't mobile-friendly. For each, draft a short, personalized outreach email pitching our web-design studio's redesign service. Summarize who you found and attach the drafts for my review."
      }'
    ```

    ```json theme={null}
    {
      "id": "task_out01",
      "object": "task",
      "name": "Weekly lead outreach",
      "agent": "business",
      "trigger_type": "cron",
      "cron_expression": "0 9 * * 1",
      "approval_mode": "supervised",
      "delivery_methods": ["email"],
      "active": true,
      "next_run_at": "2026-06-22T13:00:00Z",
      "total_runs_count": 0
    }
    ```

    `agent: "business"` is the default operator agent (use `engineering` only for code/site builds). The cron `0 9 * * 1` runs every Monday at 09:00 in the given `timezone`.
  </Step>

  <Step title="Read the Task's runs">
    Every execution creates a Task Run. List them to see what the agent did and what's awaiting you.

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

    ```json theme={null}
    {
      "object": "list",
      "data": [
        {
          "id": "trun_run01",
          "object": "task_run",
          "task_id": "task_out01",
          "status": "needs_input",
          "summary": "Found 10 local businesses; drafted 10 outreach emails awaiting approval.",
          "credits_consumed": 42,
          "tool_calls_count": 18,
          "started_at": "2026-06-22T13:00:02Z"
        }
      ],
      "has_more": false
    }
    ```

    A `status` of `needs_input` means the supervised run is paused for your review.
  </Step>

  <Step title="Approve a supervised run">
    Supervised runs are reviewed and resumed in the dashboard — that's where the drafts and the agent's reasoning are shown for interactive approval. To resolve a run's state programmatically, `PATCH /task_runs/{id}`:

    ```bash theme={null}
    curl -X PATCH https://api.crevio.co/v1/task_runs/trun_run01 \
      -H "Authorization: Bearer YOUR_API_TOKEN" \
      -H "Content-Type: application/json" \
      -d '{ "status": "completed" }'
    ```

    <Tip>
      Interactive input (editing a draft, approving a send) happens in the dashboard and via notifications. The API `PATCH` resolves the run's status; it doesn't carry an approval payload.
    </Tip>
  </Step>
</Steps>

## Variation: trigger on an event instead of a schedule

Instead of cron, fire the agent when something happens in your account. Use `trigger_type: "event"` with `event_conditions` — for example, kick off a follow-up sequence whenever an order is paid.

```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": "Post-purchase follow-up",
    "agent": "business",
    "trigger_type": "event",
    "approval_mode": "autonomous",
    "delivery_methods": ["email"],
    "event_conditions": { "event": "order.paid" },
    "prompt": "When an order is paid, draft and send a warm thank-you email to the client with next steps and a link to book their project kickoff call."
  }'
```

<Note>
  Event-triggered Tasks and [Webhooks](/developer/guides/webhooks) both react to platform events, but they're different tools: a webhook notifies **your** server so your code acts; an event Task wakes up **Crevio's** AI to act on your behalf. See [Events](/developer/guides/events) for the subscribable event list.
</Note>

## Next steps

<CardGroup cols={2}>
  <Card title="Tasks" icon="robot" href="/developer/guides/tasks">
    Full Task model — triggers, agents, approval modes.
  </Card>

  <Card title="Events" icon="bolt" href="/developer/guides/events">
    Internal and third-party triggers for event Tasks.
  </Card>

  <Card title="AI content generation" icon="image" href="/developer/guides/ai-content">
    The web research tools your agent uses under the hood.
  </Card>

  <Card title="Usage & billing" icon="credit-card" href="/developer/guides/usage-billing">
    How Task runs consume credits.
  </Card>
</CardGroup>
