# PATCH /v1/routines/{routine_id}

> Change what it asks, when it runs (every, schedule or timezone), its filters, or pause and resume it.

In [Routines API](https://vestra.ai/developers/reference/api/routines.md): Jobs Bash runs on a schedule in plain words, or whenever your system calls.

Send `Authorization: Bearer vk_test_...` on every call.

Change what it asks, when it runs (every, schedule or timezone), its filters, or pause and resume it.

Your API key, scope `runtime` or `all`. On the card: [`routines`](https://vestra.ai/developers/routines.md). Every call here is a checked sample.

## Request

Path:

- `routine_id` (`string`, required): The routine's id (`rtn_...`).

Body:

- `name` (`string`): A new name, up to 200 characters. Limits: 1 to 200 characters.
- `ask` (`string`): What Bash is asked on every run from now on, up to 8,000 characters. Limits: 1 to 8000 characters.
- `every` (`string`): A new schedule. When it runs, in plain words: `weekday at 08:00`, `mon, wed, fri at 18:30`, `30 minutes`, `month on the 1st at 09:00`. At most once every 15 minutes. Limits: 1 to 100 characters.
- `timezone` (`string`): A new zone, an IANA name, for the schedule it already has or for new plain words. Limits: 1 to 64 characters.
- `schedule` (`object`): A new schedule as cron, instead of `every`.
  - `cron` (`string`, required): A cron expression of five fields: `0 7 * * *` runs at 7:00 every day. Limits: 1 to 120 characters. Example: `0 7 * * 1-5`.
  - `timezone` (`string`): The zone the cron is read in, an IANA name such as `Asia/Kolkata`. Absent: the user's own, then UTC. Limits: 1 to 64 characters. Example: `Asia/Kolkata`.
- `filters` (`map of any`): New filters, for a routine that runs on a call.
- `enabled` (`boolean`): false pauses it; true resumes it.

## Answers 200

- `id` (`string`): The routine's id. Example: `rtn_8f2k`.
- `object` (`"routine"`): Always `routine`.
- `user_id` (`string | null`): Your id for the user whose Bash runs it; null for your company's own Bash.
- `conversation_id` (`string | null`): The conversation each run posts into, named or made when the routine was; null for a routine not made through the API.
- `name` (`string`): Its name.
- `ask` (`string`): What Bash is asked on every run.
- `kind` (`"schedule" | "trigger" | "app_event"`): `schedule`: it runs on its schedule. `trigger`: it runs when your system posts to `trigger_url`. `app_event`: an event in a connected app runs it.
- `schedule` (`object | null`): When it runs; null for one that runs on a call.
  - `every` (`string | null`): The plain words it was given; null for a cron.
  - `cron` (`string`): The schedule as cron, worked out from `every` when it was given in words.
  - `timezone` (`string`): The zone it runs in, an IANA name.
- `trigger` (`object | null`): For one that runs on a call, what it listens for; null for one on a schedule.
  - `filters` (`map of any | null`): What a payload must carry for it to run; null: any payload.
- `trigger_url` (`string | null`): For one that runs on a call: POST here, with your key and any JSON object, to run it. Null otherwise.
- `enabled` (`boolean`): false while it is paused.
- `status` (`"active" | "completed" | "failed"`): `active`: it runs as it should. `completed`: it has finished and will not run again. `failed`: it stopped on an error.
- `last_run_at` (`string | null`): When it last ran; null when it never has.
- `next_run_at` (`string | null`): When it runs next; null when paused, finished, or run on a call.
- `run_count` (`integer`): How many times it has run.
- `created_at` (`string`): When it was made, as an ISO 8601 date and time in UTC.
- `updated_at` (`string`): When it last changed, as an ISO 8601 date and time in UTC.

## Code

**TypeScript**

```ts
await vestra.routines.pause('rtn_5kd');
```

**Python**

```python
vestra.routines.pause("rtn_5kd")
```

**CLI**

```bash
vestra routines pause rtn_5kd
```

**HTTP**

```bash
# Run on a schedule. Write it in plain words, read in the user's own time zone. The response gives the cron
# expression and the next run.
curl "$VESTRA_BASE_URL/v1/routines" \
  -H "Authorization: Bearer $VESTRA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "user_id": "traveller-42",
    "ask": "Check my trips for today and tell me about any delay.",
    "every": "weekday at 08:00"
  }'

# Run when your system calls. Post a payload to the routine's trigger_url.
curl "$VESTRA_BASE_URL/v1/routines" \
  -H "Authorization: Bearer $VESTRA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "user_id": "traveller-42", "ask": "A train of mine is late. Find me another way.", "on": "call" }'

curl "$VESTRA_BASE_URL/v1/routines/rtn_7qp/trigger" \
  -H "Authorization: Bearer $VESTRA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "train": "12127", "delay_minutes": 45 }'

# Manage a routine. Pause it (enabled: true resumes it), run it once now, and list the user's routines.
curl -X PATCH "$VESTRA_BASE_URL/v1/routines/rtn_5kd" \
  -H "Authorization: Bearer $VESTRA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "enabled": false }'

curl -X POST "$VESTRA_BASE_URL/v1/routines/rtn_5kd/run" \
  -H "Authorization: Bearer $VESTRA_API_KEY"

curl "$VESTRA_BASE_URL/v1/routines?user_id=traveller-42" \
  -H "Authorization: Bearer $VESTRA_API_KEY"
```

**MCP**

```json
{
  "method": "tools/call",
  "params": {
    "name": "routines_add",
    "arguments": {
      "user": "traveller-42",
      "ask": "Check my trips for today and tell me about any delay.",
      "every": "weekday at 08:00",
      "timezone": "Asia/Kolkata"
    }
  }
}
```
