# Set when a schedule runs

Set how often a schedule runs with a cron expression and a time zone, cap how many times it runs, and pause it.

## Before you start

You need an active schedule. See [Schedule a run](/docs/orchestration/schedules.md).

## Change when it runs

**Studio**

1. In your project, open **Orchestration** > **Triggers**.
2. Click your schedule, `Weekday stand-up`.
3. Click **Edit schedule**.
4. Under **Choose when it runs**, set **Frequency** to **Every hour**. The summary reads "Runs every hour, on the hour."
5. Turn on **Stop after a set number of runs**.
6. Enter `5` as the **Number of runs**. The summary reads "Runs every hour, on the hour, 5 times."
7. Click **Save schedule**. You should now see **Cron** `0 * * * *` and **Run limit** `0 of 5`: the runs it has made so far, of 5.
8. Open the **More actions** menu.
9. Click **Pause**. You should now see **Status** read **Paused**. A paused schedule shows **Resume** instead.

**Resume** in the same menu starts it again. **One time**, beside **Repeating**, runs it once on a **Date** and **Time** you pick.

**Code**

1. In your project, change the schedule's file. `schedule` is the cron expression and `maxRuns` stops it after that many runs:

```ts title="schedules/weekday-standup.ts"
import { schedule } from "veryfront/schedule";

export default schedule({
  id: "weekday-standup",
  name: "Weekday stand-up",
  schedule: "0 * * * *",
  timezone: "UTC",
  maxRuns: 5,
  target: { kind: "agent", id: "stand-up-host", conversationMode: "create_new" },
  agentMessage: { prompt: "Write today's stand-up questions." },
});
```

2. [Push the project](/docs/projects/local.md). You should now see the schedule in **Orchestration** > **Triggers**, **Source-defined**, with its new timing.

### Try it in a sandbox

```playground
step: Create a project | npm create -y veryfront@latest standup -- --template minimal --yes
step: Add the agent | cd standup && mkdir -p agents schedules && printf '%s\n' 'import { agent } from "veryfront/agent";' '' 'export default agent({' '  id: "stand-up-host",' '  name: "Stand-up host",' '  system: "Write three short stand-up questions for the team: what they did, what they will do, what blocks them. Nothing else.",' '});' > agents/stand-up-host.ts
step: Change the schedule | printf '%s\n' 'import { schedule } from "veryfront/schedule";' '' 'export default schedule({' '  id: "weekday-standup",' '  name: "Weekday stand-up",' '  schedule: "0 * * * *",' '  timezone: "UTC",' '  maxRuns: 5,' '  target: { kind: "agent", id: "stand-up-host", conversationMode: "create_new" },' '  agentMessage: { prompt: "Write today'"'"'s stand-up questions." },' '});' > schedules/weekday-standup.ts
step: Push the project | npx veryfront push
check: curl -s https://api.veryfront.com/projects/$VERYFRONT_PROJECT_REFERENCE/source-schedules -H "Authorization: Bearer $VERYFRONT_API_KEY"
expect: 0 * * * *
```

**API**

1. Set `PROJECT` to your project's ID ([Find your IDs](/docs/authentication/api-keys.md#find-your-ids)): `export PROJECT=<id>`.
2. List the project's schedules, with your [API key](/docs/authentication/api-keys.md). You should now see each schedule's `id` and `name`:

```bash
curl https://api.veryfront.com/projects/$PROJECT/schedules \
  -H "Authorization: Bearer $VERYFRONT_API_KEY"
```

3. Set `SCHEDULE_ID` to your schedule's `id`: `export SCHEDULE_ID=<id>`.
4. Change it to every hour, for 5 runs:

```bash
curl -X PATCH https://api.veryfront.com/projects/$PROJECT/schedules/$SCHEDULE_ID \
  -H "Authorization: Bearer $VERYFRONT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "schedule": "0 * * * *", "max_runs": 5 }'
```

5. Pause it. You should now see `"status": "paused"` in the answer:

```bash
curl -X PATCH https://api.veryfront.com/projects/$PROJECT/schedules/$SCHEDULE_ID \
  -H "Authorization: Bearer $VERYFRONT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "status": "paused" }'
```

`"status": "active"` resumes it.

## With MCP

1. Find the schedule's ID with `veryfront__list_schedules` and `{ "project_reference": "my-project" }`. The project reference is its slug or its ID.
2. Call `veryfront__update_schedule` with `{ "project_reference": "my-project", "schedule_id": "<id>", "schedule": "0 * * * *", "max_runs": 5, "status": "paused" }`.
3. Call `veryfront__get_schedule` with the same `project_reference` and `schedule_id`. It worked when `schedule` is `0 * * * *`, `max_runs` is `5` and `status` is `paused`.

## Next steps

* [Find a run that failed](/docs/observability/runs.md)
* [Start a run](/docs/orchestration/start-run.md)
