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

# Routines: a video a day

> Turn one film you like into a template, then let a scheduled agent make and post a new one from it every day.

## What a routine is

A routine is a scheduled agent run on your side: Claude Code, Codex or Cursor
wakes up on a timer you set, opens the Lavendly MCP server and makes a video.
Lavendly does the making and the posting (generate, render, publish to your
channel). The schedule itself lives in your agent, not in Lavendly. Lavendly
schedules posts (`schedule_video`), never agent runs.

## Your template is a film you already like

Make one film by hand, in the Studio or with your agent, until you are happy
with it. That film is the template. It holds everything that should stay the
same: the look, the music, the structure, the scenes that never change (an
intro, a product shot, a sign-off).

Each run copies the template and changes only two things: the **subject** and
the **hook**. Today it is cold brew, tomorrow matcha, the day after oat milk.
Same channel, same feel, a new video every day.

Two rules make this cheap and safe:

* A scene that already has a clip is **reused and never charged**. Only the
  scenes you change get generated, so a run usually costs one or two clips.
* The template is **never edited by the run**. The run makes a new film from a
  copy, so tomorrow starts from the same template.

To change the series, change the template. Swap the music, tighten the intro,
try a new opening shot: the next run picks it up, because every run reads the
template fresh.

## Example: a daily coffee short

A 3-scene vertical short for a coffee channel. Scene 1 is a hook about the
day's drink (generated), scene 2 is the same pour shot every day (reused),
scene 3 is the brand sign-off (reused). One music track runs across the film.

### 1. Set up once

Find the two ids the routine needs, by asking your agent once:

* the template film: `list_workflows`, then note the `id` of "Coffee daily (template)"
* the channel: `list_channels`, then note the `id` of your TikTok channel

Use the [hosted MCP endpoint](/mcp/overview.md#connect). A scheduled run in the
cloud cannot start a local `npx` server.

### 2. Give Claude Code the schedule

Run `/schedule` in Claude Code (or create a routine on the Routines page of
Claude Code on the web), with the Lavendly connector attached, and paste:

```text theme={null}
Every day at 09:00 Europe/Paris:

Make today's coffee short with Lavendly.

Template: workflow wf_TEMPLATE_ID ("Coffee daily (template)"). Never edit it.
Channel: ch_TIKTOK_ID. Credit cap: 60 per run.

1. Pick today's drink. It must not appear in the names of the last 14 films
   in the "Coffee daily" project (list_workflows).
2. get_workflow on the template. Copy its nodes and edges. In scene 1 only,
   rewrite the image and clip prompts for today's drink and remove data.url
   and data.video_url so it is made fresh. Leave every other scene as it is.
3. create_workflow with the copied nodes and edges, name
   "Coffee daily | <drink> | <date>", project_name "Coffee daily",
   idempotency_key "coffee-<date>-create".
4. estimate_cost. If remaining is over 60 or sufficient is false, stop and
   tell me why. Nothing is spent.
5. generate_scene with max_credits 60, idempotency_key "coffee-<date>-gen".
   Poll get_generation_status every 10 seconds until done.
6. quality_check scene 1. If pass is false, regenerate it once with the
   reroll_hint added to its prompt. If it fails again, stop and tell me.
7. create_render with max_credits 60, idempotency_key "coffee-<date>-render".
   Poll get_render until status is done.
8. publish_video to ch_TIKTOK_ID with a caption under 150 characters about
   the drink and idempotency_key "coffee-<date>-post".
9. update_workflow on the new film: put the drink, credits spent, quality
   result and post link in its description. Reply with the same report.
```

That prompt is the whole routine. Setting it up with a channel and a credit cap
is your yes to posting: the run does not stop to ask.

### 3. What the run does

| Step | Tool | What happens |
| - | - | - |
| Read the template | `get_workflow` | Full nodes and edges of the template film. |
| Make today's film | `create_workflow` | A new film from the copied graph, with the day's subject in the changed scene. The template is untouched. |
| Price it | `estimate_cost` | `remaining` is what this run will spend, since reused scenes are free. |
| Generate | `generate_scene` | Makes only the scenes without a clip. `max_credits` refuses with `quote_exceeded` instead of spending more. |
| Watch it | `get_generation_status` | Phase and progress, per-scene clips as they land. |
| Check it | `quality_check` | `pass`, `score` and a `reroll_hint` for a weak scene. |
| Stitch | `create_render`, `get_render` | Free: it reuses every clip. `result.video_url` when `status` is `done`. |
| Post | `publish_video` or `schedule_video` | To the `channel_id` you gave it, now or at a set `when`. |

### Budget

* **`estimate_cost` first, every run.** The routine stops before spending if the
  price is over your cap or your balance is short.
* **`max_credits` on every spending call.** The server holds the cap, so a
  confused run cannot spend more than you approved.
* **`idempotency_key` with the date.** A retried step replays the first
  answer, so a hiccup never makes two films, charges twice or posts twice.
* **Watch the month.** `get_ledger` and `get_monthly_usage` show what the
  routine has spent; your plan's monthly cap still applies.

Rendering is free. A run like this one spends only on scene 1: one short clip a
day. Check the exact number with `estimate_cost` on your own template.

### Post now or later

`publish_video` posts as soon as the film is ready. To post at your channel's
best hour instead, use `schedule_video` with a `when` in the future: the run
makes the film at 09:00 and Lavendly posts it at 18:00. Review queued posts with
`list_scheduled_posts` and stop one with `cancel_scheduled_post`.

To review before anything goes out, leave step 8 out and the run ends with the
finished film in your project.

## Example: a weekly roundup

A Monday recap built from the week's films. Nothing new is generated, so it
costs nothing but the render, which is free.

```text theme={null}
Every Monday at 08:00:

With Lavendly, list_workflows and take the films in the "Coffee daily"
project from the last 7 days. Make a new film "Coffee week | <date>" with
create_workflow: one scene per film, each a clip node whose data.video_url is
that film's latest render (list_renders), trimmed to its best 3 seconds with
edit_clip. Attach one music track with attach_track (kind music, scope film).
estimate_cost must be 0, otherwise stop. create_render, poll get_render, then
schedule_video to ch_YOUTUBE_ID at 12:00 today with the title
"This week in coffee". Report the post time.
```

## Other agents

* **Codex:** run `codex exec "<the routine prompt>"` from cron or a scheduled CI job, with Lavendly in `~/.codex/config.toml`.
* **Cursor:** run `cursor-agent -p "<the routine prompt>"` from cron or a scheduled CI job, with Lavendly in `~/.cursor/mcp.json`.

Connection details for each agent are on the [MCP overview](/mcp/overview.md), and
every tool used here is in the [tools reference](/mcp/tools-reference.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.