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

# Run Agents Autonomously

> Trigger agents from external events with webhooks, or run them on a schedule

Once deployed, agents don't need you to press "Run." They can react to external events via webhooks or run on a recurring schedule -- fully hands-free.

***

## Webhooks: Trigger from External Events

Every deployed agent gets a unique webhook URL. Any system that can make an HTTP POST request can trigger your agent.

### Getting Your Webhook URL

Your webhook URL is available in:

* **Web UI** -- On the agent's detail page, click the copy icon next to the webhook URL
* **CLI** -- `datagen agents show <agent-id>`
* **Plugin** -- Displayed after running `/datagen:deploy-agent`

<Frame>
  <img src="https://mintcdn.com/datagen/LWL3BGYwXkq1W4fz/images/agents/webhook-url.png?fit=max&auto=format&n=LWL3BGYwXkq1W4fz&q=85&s=fb3b8c9beb9e032079471359be0d977e" alt="Webhook URL" width="1501" height="791" data-path="images/agents/webhook-url.png" />
</Frame>

### Triggering with cURL

```bash theme={null}
curl -X POST "https://api.datagen.dev/agent/YOUR_AGENT_ID" \
  -H "Content-Type: application/json" \
  -d '{
    "task": "Process new data",
    "source": "github",
    "data": { "pr_number": 42 }
  }'
```

The JSON body is passed to your agent as context for the run.

### Payload Format

The webhook accepts any valid JSON. Your agent receives the full payload and can reference it during execution.

**Simple trigger (no data):**

```bash theme={null}
curl -X POST "https://api.datagen.dev/agent/YOUR_AGENT_ID"
```

**With structured data:**

```json theme={null}
{
  "task": "Enrich these leads",
  "leads": [
    {"name": "Acme Corp", "domain": "acme.com"},
    {"name": "Globex", "domain": "globex.com"}
  ]
}
```

### Integration Examples

Use your webhook URL with any system that supports HTTP webhooks:

* **n8n / Make / Zapier** -- HTTP action in automation workflows
* **GitHub** -- Trigger on push, PR, or issue events
* **HeyReach** -- Real-time LinkedIn campaign monitoring
* **Fireflies** -- Auto-generate follow-ups after meetings
* **Custom apps** -- Any system that can make HTTP POST requests

When triggered via webhook, results are also sent to any configured [channels](/guide/channels-overview) (Slack, email).

***

## Schedules: Run on a Recurring Basis

Schedules let you run agents automatically -- hourly, daily, weekly, or with custom cron expressions. No manual intervention needed.

### Set Up via the Web UI

<Steps>
  <Step title="Open Schedule Settings">
    Click **Schedule** on your deployed agent.

    <Frame>
      <img src="https://mintcdn.com/datagen/LWL3BGYwXkq1W4fz/images/agents/schedule-dialog.png?fit=max&auto=format&n=LWL3BGYwXkq1W4fz&q=85&s=e3e0eeb8681c56f0a5e3af30282c8ba0" alt="Schedule dialog" width="1501" height="791" data-path="images/agents/schedule-dialog.png" />
    </Frame>
  </Step>

  <Step title="Choose Schedule Type">
    * **Hourly** -- Run every hour
    * **Daily** -- Run once per day at a specific time
    * **Weekly** -- Run on specific days of the week
    * **Custom** -- Define a custom cron expression
  </Step>

  <Step title="Set Timezone">
    Choose your timezone to ensure the agent runs at the expected times.
  </Step>

  <Step title="Add Payload (Optional)">
    Provide JSON payload passed to your agent on each run.

    ```json theme={null}
    {
      "target_branch": "main",
      "dry_run": false
    }
    ```
  </Step>

  <Step title="Save">
    Click **Save** to activate the schedule.
  </Step>
</Steps>

### Set Up via the CLI

```bash theme={null}
# Daily at 9 AM Eastern
datagen agents schedule <agent-id> \
  --cron "0 9 * * *" \
  --timezone "America/New_York"

# Every Monday at 2 PM UTC
datagen agents schedule <agent-id> \
  --cron "0 14 * * 1"
```

### Schedule Types

| Type         | Example                | Cron Expression |
| ------------ | ---------------------- | --------------- |
| **Hourly**   | Every hour on the hour | `0 * * * *`     |
| **Daily**    | Every day at 9 AM      | `0 9 * * *`     |
| **Weekly**   | Every Monday at 2 PM   | `0 14 * * 1`    |
| **Weekdays** | Monday-Friday at 8 AM  | `0 8 * * 1-5`   |
| **Custom**   | Every 6 hours          | `0 */6 * * *`   |

### Managing Schedules

```bash theme={null}
# List schedules
datagen agents schedule <agent-id>

# Pause a schedule
datagen agents schedule <agent-id> --pause <schedule-id>

# Resume a schedule
datagen agents schedule <agent-id> --resume <schedule-id>

# Delete a schedule
datagen agents schedule <agent-id> --delete <schedule-id>
```

You can also pause, resume, and delete schedules from the web UI.
