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

# Routines

> Recurring tasks and scheduled triggers — Apollo Space's cron to automate what repeats.

It's Friday, 6 PM. The office is empty. On its own schedule, Athena pulls
the week's activity, compiles the summary, drops it in the shared folder,
and pings the owners — the report that used to eat your Friday evening is
already waiting when you log off.

That's a **routine**: the work that should happen on a clock, happening
without anyone remembering to press go. It's how your company keeps
running while no one is watching the keyboard.

## What routines are for

**Routines** are tasks that **repeat on a fixed cadence** —
every Monday at 9 AM, every weekday at 6 PM, every first day of the month.

Instead of you remembering to do it + executing it manually, a routine
**fires automatically** at the configured time and runs what you defined —
which can involve an agent, creating a task, sending an outbound, or a combination.

## When to use a routine vs a task

| Scenario                                                 | Use                     |
| -------------------------------------------------------- | ----------------------- |
| "I need to do X once, next week"                         | **Task** with a date    |
| "I need to do X every week, indefinitely"                | **Routine**             |
| "I want the agent to review stalled leads every Tuesday" | **Routine** + agent     |
| "I'm going to launch a campaign now for new leads"       | **Outbound** (one-shot) |
| "I want a weekly email report every Friday at 6 PM"      | **Routine** + Marcus    |

The general rule: **if you'll need to do it again next week**, it's worth creating a routine.

## Anatomy of a routine

<CardGroup cols={2}>
  <Card title="Cadence" icon="calendar">
    When it fires — daily / weekly / monthly / custom cron expression.
    Supports the org's timezone.
  </Card>

  <Card title="Action" icon="bolt">
    What runs when it fires — call an agent, create a task, send a message,
    run an outbound pipeline.
  </Card>

  <Card title="Context" icon="brain">
    Inputs the routine passes to the action (e.g., "leads with no activity
    in the last 7 days"). Can be static or dynamic.
  </Card>

  <Card title="History" icon="clock-rotate-left">
    Every execution is recorded — when it ran, what it did,
    whether it succeeded, and how many Stars it spent.
  </Card>
</CardGroup>

## Common patterns

<AccordionGroup>
  <Accordion title="Weekly team report" icon="file-chart-column">
    **Cadence:** every Friday at 6 PM
    **Action:** Athena reviews the week's activity and compiles a summary
    document
    **Output:** new doc in a shared folder + chat notification to owners

    Useful for: recurring visibility without manual effort.
  </Accordion>

  <Accordion title="Re-engaging stalled leads" icon="reply-clock">
    **Cadence:** every Tuesday at 10 AM
    **Action:** Marcus reviews leads with no activity in the last 14 days
    and proposes follow-up drafts (HITL on — you approve)
    **Output:** drafts waiting for approval in chat

    Useful for: keeping opportunities from dying due to lack of follow-through.
  </Accordion>

  <Accordion title="Monthly pipeline cleanup" icon="broom">
    **Cadence:** first day of the month at 8 AM
    **Action:** Athena archives leads in terminal state for more than 90
    days + identifies duplicates
    **Output:** review task for the pipeline owner

    Useful for: preventing the pipeline from getting inflated with historical noise.
  </Accordion>

  <Accordion title="Automatic lead import" icon="file-import">
    **Cadence:** every weekday at 7 AM
    **Action:** runs an Apify actor (Maps lead search with a pre-defined
    query) and adds new results to the "New Outbound" pipeline
    **Output:** N new leads ready for Marcus to work

    Useful for: keeping the funnel fed without manual effort.
  </Accordion>
</AccordionGroup>

## Setting up a routine

<Steps>
  <Step title="Sidebar → Routines → New routine">
    Opens the configurator.

    **Expected result:** panel with 4 tabs (Cadence / Action /
    Context / Notification).
  </Step>

  <Step title="Define the cadence">
    Options:

    * **Daily** (choose a time)
    * **Weekly** (days of the week + time)
    * **Monthly** (day of the month + time)
    * **Custom** (cron expression — for complex scenarios)

    <Tip>
      For cron expressions, standard Linux format: `0 18 * * 5` =
      Friday at 6 PM. See [crontab.guru](https://crontab.guru)
      to test your expression.
    </Tip>
  </Step>

  <Step title="Choose the action">
    What will run:

    * **Call agent** — passes a pre-defined prompt to Scout /
      Marcus / Athena
    * **Create task** — new task on a specific board
    * **Trigger outbound** — run an existing campaign on a filtered audience
    * **Execute tool** — e.g., run `maps_lead_search` directly

    Each type opens its own configurator.
  </Step>

  <Step title="Define notification (optional)">
    When the routine finishes, who gets notified:

    * Nobody (silent)
    * You (inbox notification)
    * Specific people (mention)
    * External channel (Slack via Composio)
  </Step>

  <Step title="Activate">
    Toggle **Active**. The next scheduled execution appears below —
    confirm the cadence looks right before closing.
  </Step>
</Steps>

## Limits and gotchas

<Warning>
  **Routines consume Stars** — just like any billable action.
  A routine that calls an agent daily will debit Stars every day.
  Review the cost estimate before activating; it appears in the
  configurator based on the org's history.
</Warning>

<CardGroup cols={2}>
  <Card title="Agent daily cap applies" icon="gauge-high">
    If a routine triggers an agent that has a daily cap, and the routine
    exceeds that cap, the execution is blocked. You're notified to
    decide: raise the cap or accept the one-off failure.
  </Card>

  <Card title="Skip during sensitive windows" icon="moon">
    Org settings can define sensitive windows (weekends, holidays,
    after-hours) where routines don't fire outbound to customers.
    Internal-only routines keep running.
  </Card>

  <Card title="Idempotency per execution" icon="shield-check">
    If a routine fails and retries, it uses an Idempotency-Key
    to prevent double-firing. You won't accidentally send the
    same message twice.
  </Card>

  <Card title="Backfill off by default" icon="ban">
    If a routine was paused for 3 days and you reactivate it, **it does
    not run the 3 missed executions**. It only runs the next scheduled
    one. For an explicit backfill, use "Run now" manually.
  </Card>
</CardGroup>

## Audit log

Every routine execution creates an entry in the history:

| Field                         | What it records                                  |
| ----------------------------- | ------------------------------------------------ |
| `executed_at`                 | Execution timestamp                              |
| `routine_id` + `routine_name` | Which routine                                    |
| `action_type`                 | Action type (agent / task / outbound / tool)     |
| `status`                      | success / failed / skipped                       |
| `cost_stars`                  | Stars spent                                      |
| `output_ref`                  | Link to the created resource (task, draft, etc.) |

Owners and Admins can inspect this under **Routines → click a routine → History tab**.

## Next steps

<CardGroup cols={2}>
  <Card title="Outbound" icon="paper-plane" href="/en/features/outbound">
    How Marcus operates the campaigns that routines can trigger.
  </Card>

  <Card title="Agents" icon="robot" href="/en/concepts/agents">
    Who you can call from within a routine.
  </Card>

  <Card title="Caps" icon="gauge-high" href="/en/billing/caps">
    How to limit spending from routines that run out of control.
  </Card>

  <Card title="Composio" icon="puzzle-piece" href="/en/integrations/composio">
    For external integrations that routines trigger (Slack notifications,
    Calendar, Notion).
  </Card>
</CardGroup>
