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

# Crons

> Schedule a message to your agent. Each firing wakes the instance, runs the turn on its own session, and lets the instance go back to sleep.

A **cron** is one sentence and a schedule: say this to my agent, every weekday at 9. Each firing sends the prompt to [`POST /v1/responses`](https://www.agent37.com/docs/agents-api/chat) on that instance's own gateway, on a fresh [session](https://www.agent37.com/docs/agents-api/sessions.md), and the request wakes the instance on its way in.

That last part is the reason to use this instead of the scheduler inside the agent. A crontab inside the container only runs while the container is running, so on an instance with [auto-sleep](https://www.agent37.com/docs/agents-api/instance-auto-sleep.md) it stops firing the moment the instance sleeps, and it keeps the instance awake for nothing when it doesn't. A platform cron is outside the instance: it fires whether the instance is awake or asleep, and between firings the instance is free to sleep and cost you nothing but disk.

Crons belong to an instance. Deleting the instance deletes its crons. `agent37-base` and `agent37-n8n` take none: they run no agent, so there is nothing to send a message to.

## Create a cron

`prompt` and `schedule` are required.

```bash curl wrap theme={null}
curl -X POST \
  https://api.agent37.com/v1/instances/ab12cd34ef/crons \
  -H "Authorization: Bearer sk_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Summarize the files in ~/reports.",
    "schedule": "0 9 * * 1-5",
    "agent": "hermes",
    "profile": "default",
    "timezone": "America/New_York",
    "name": "Weekday briefing",
    "enabled": true
  }'
```

```python Python wrap theme={null}
import requests

response = requests.post(
    "https://api.agent37.com/v1/instances/ab12cd34ef/crons",
    headers={
        "Authorization": "Bearer sk_live_...",
        "Content-Type": "application/json"
    },
    json={
        "prompt": "Summarize the files in ~/reports.",
        "schedule": "0 9 * * 1-5",
        "agent": "hermes",
        "profile": "default",
        "timezone": "America/New_York",
        "name": "Weekday briefing",
        "enabled": True
    },
)
response.raise_for_status()
print(response.json())
```

```javascript Node wrap theme={null}
const response = await fetch(
  "https://api.agent37.com/v1/instances/ab12cd34ef/crons",
  {
    method: "POST",
    headers: {
      "Authorization": "Bearer sk_live_...",
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      "prompt": "Summarize the files in ~/reports.",
      "schedule": "0 9 * * 1-5",
      "agent": "hermes",
      "profile": "default",
      "timezone": "America/New_York",
      "name": "Weekday briefing",
      "enabled": true
    }),
  },
);
if (!response.ok) {
  throw new Error(await response.text());
}
console.log(await response.json());
```

```json response wrap theme={null}
{
  "id": "9903c325ee3c",
  "name": "Weekday briefing",
  "agent": "hermes",
  "profile": null,
  "prompt": "Summarize the files in ~/reports.",
  "schedule": "0 9 * * 1-5",
  "timezone": "America/New_York",
  "enabled": true,
  "last_run": null,
  "next_run": 1790154000,
  "created": 1790067720
}
```

**prompt** `string` *required*

What to say to the agent. The same thing you would send as `input` on `POST /v1/responses`, so it can be a whole standing instruction, not just a line. Up to 8,000 characters.

**schedule** `string` *required*

A five-field cron expression: minute, hour, day of month, month, day of week. `0 9 * * 1-5` is 9am on weekdays; `*/15 * * * *` is every fifteen minutes; `* * * * *` is every minute. Ranges, lists, steps, and three-letter day and month names all work. There is no seconds field: a six-field expression is rejected.

**agent** `string`

Which harness runs the firing, for an image that ships more than one: `hermes`, `openclaw`, `claude-code`, `codex`, `opencode`, `grok` or `pi`. Omit it and the firing goes to the template's own agent, which is what a single-harness image wants. Naming a harness the image does not ship means the turn never starts: the run is recorded as `skipped` with `wake_failed`.

**profile** `string`

Which [profile](https://www.agent37.com/docs/agents-api/sessions.md#profiles) the firing runs in, for an instance that hosts several distinct agents: the same `profile` as on [`POST /v1/responses`](https://www.agent37.com/docs/agents-api/chat). Omit it, or send `default`, for the agent's own setup. Supported on `hermes` today: a `profile` with any other harness is `400 invalid_request`, and so is a name that is not lowercase letters, digits, `-` or `_`, or an instance whose image is older than profiles ([update it](https://www.agent37.com/docs/agents-api/instances/update.md) first). Whether the instance has the profile is checked when the cron fires: one it does not have means the turn never starts, and the run is recorded as `skipped` with `wake_failed`.

**timezone** `string` (default: UTC)

An IANA timezone name, for example `America/New_York`. The schedule is read in this zone, so "9am" stays 9am across daylight saving.

**name** `string`

A label for your own UI. Up to 80 characters.

**enabled** `boolean` (default: true)

`false` creates it paused. A paused cron has `next_run: null` and never fires.

## The cron object

**id** `string`

12-character hex id.

**last\_run** `number | null`

When it last fired on its schedule, epoch seconds. `null` until it has. [Running it now](#run-one-now) does not change it.

**next\_run** `number | null`

When it fires next, epoch seconds. `null` while `enabled` is `false`.

**created** `number`

Epoch seconds.

## List, read, edit, delete

```bash wrap theme={null}
GET    /v1/instances/{id}/crons            # { "data": [ ... ] }, oldest first
GET    /v1/instances/{id}/crons/{cronId}
PATCH  /v1/instances/{id}/crons/{cronId}
DELETE /v1/instances/{id}/crons/{cronId}   # { "id": "...", "deleted": true }
```

`PATCH` takes any of the create fields and changes only the keys you send: `"agent": null` hands the firing back to the template's own agent, and `"profile": null` hands it back to the agent's own setup. Changing `schedule`, `timezone` or `enabled` recomputes `next_run` from now, so a new schedule never replays a window that has already passed; editing only the `prompt` or the `name` leaves the next firing exactly where it was. Send only the fields you want to change. This example sets every field and pauses the cron:

```bash curl wrap theme={null}
curl -X PATCH \
  https://api.agent37.com/v1/instances/ab12cd34ef/crons/9903c325ee3c \
  -H "Authorization: Bearer sk_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Summarize the files in ~/reports.",
    "schedule": "0 9 * * 1-5",
    "agent": "hermes",
    "profile": "default",
    "timezone": "America/New_York",
    "name": "Weekday briefing",
    "enabled": false
  }'
```

```python Python wrap theme={null}
import requests

response = requests.patch(
    "https://api.agent37.com/v1/instances/ab12cd34ef/crons/9903c325ee3c",
    headers={
        "Authorization": "Bearer sk_live_...",
        "Content-Type": "application/json"
    },
    json={
        "prompt": "Summarize the files in ~/reports.",
        "schedule": "0 9 * * 1-5",
        "agent": "hermes",
        "profile": "default",
        "timezone": "America/New_York",
        "name": "Weekday briefing",
        "enabled": False
    },
)
response.raise_for_status()
print(response.json())
```

```javascript Node wrap theme={null}
const response = await fetch(
  "https://api.agent37.com/v1/instances/ab12cd34ef/crons/9903c325ee3c",
  {
    method: "PATCH",
    headers: {
      "Authorization": "Bearer sk_live_...",
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      "prompt": "Summarize the files in ~/reports.",
      "schedule": "0 9 * * 1-5",
      "agent": "hermes",
      "profile": "default",
      "timezone": "America/New_York",
      "name": "Weekday briefing",
      "enabled": false
    }),
  },
);
if (!response.ok) {
  throw new Error(await response.text());
}
console.log(await response.json());
```

Delete acts once: a repeat is `404`. An instance holds at most 50 crons.

### List crons

```bash curl wrap theme={null}
curl -X GET \
  https://api.agent37.com/v1/instances/ab12cd34ef/crons \
  -H "Authorization: Bearer sk_live_..."
```

```python Python wrap theme={null}
import requests

response = requests.get(
    "https://api.agent37.com/v1/instances/ab12cd34ef/crons",
    headers={
        "Authorization": "Bearer sk_live_..."
    },
)
response.raise_for_status()
print(response.json())
```

```javascript Node wrap theme={null}
const response = await fetch(
  "https://api.agent37.com/v1/instances/ab12cd34ef/crons",
  {
    method: "GET",
    headers: {
      "Authorization": "Bearer sk_live_..."
    },
  },
);
if (!response.ok) {
  throw new Error(await response.text());
}
console.log(await response.json());
```

### Read a cron

```bash curl wrap theme={null}
curl -X GET \
  https://api.agent37.com/v1/instances/ab12cd34ef/crons/9903c325ee3c \
  -H "Authorization: Bearer sk_live_..."
```

```python Python wrap theme={null}
import requests

response = requests.get(
    "https://api.agent37.com/v1/instances/ab12cd34ef/crons/9903c325ee3c",
    headers={
        "Authorization": "Bearer sk_live_..."
    },
)
response.raise_for_status()
print(response.json())
```

```javascript Node wrap theme={null}
const response = await fetch(
  "https://api.agent37.com/v1/instances/ab12cd34ef/crons/9903c325ee3c",
  {
    method: "GET",
    headers: {
      "Authorization": "Bearer sk_live_..."
    },
  },
);
if (!response.ok) {
  throw new Error(await response.text());
}
console.log(await response.json());
```

### Delete a cron

```bash curl wrap theme={null}
curl -X DELETE \
  https://api.agent37.com/v1/instances/ab12cd34ef/crons/9903c325ee3c \
  -H "Authorization: Bearer sk_live_..."
```

```python Python wrap theme={null}
import requests

response = requests.delete(
    "https://api.agent37.com/v1/instances/ab12cd34ef/crons/9903c325ee3c",
    headers={
        "Authorization": "Bearer sk_live_..."
    },
)
response.raise_for_status()
print(response.json())
```

```javascript Node wrap theme={null}
const response = await fetch(
  "https://api.agent37.com/v1/instances/ab12cd34ef/crons/9903c325ee3c",
  {
    method: "DELETE",
    headers: {
      "Authorization": "Bearer sk_live_..."
    },
  },
);
if (!response.ok) {
  throw new Error(await response.text());
}
console.log(await response.json());
```

## Run one now

`POST /v1/instances/{id}/crons/{cronId}/run` fires the cron immediately, whether or not it is enabled, without touching its schedule. It answers `202` with the run record as soon as the run is recorded, before the turn is sent, so a run that reads `triggered` here can still end up `skipped` with `wake_failed`.

```bash curl wrap theme={null}
curl -X POST \
  https://api.agent37.com/v1/instances/ab12cd34ef/crons/9903c325ee3c/run \
  -H "Authorization: Bearer sk_live_..."
```

```python Python wrap theme={null}
import requests

response = requests.post(
    "https://api.agent37.com/v1/instances/ab12cd34ef/crons/9903c325ee3c/run",
    headers={
        "Authorization": "Bearer sk_live_..."
    },
)
response.raise_for_status()
print(response.json())
```

```javascript Node wrap theme={null}
const response = await fetch(
  "https://api.agent37.com/v1/instances/ab12cd34ef/crons/9903c325ee3c/run",
  {
    method: "POST",
    headers: {
      "Authorization": "Bearer sk_live_..."
    },
  },
);
if (!response.ok) {
  throw new Error(await response.text());
}
console.log(await response.json());
```

## Run history

`GET /v1/instances/{id}/crons/{cronId}/runs` returns the latest 50 firings, newest first.

```bash curl wrap theme={null}
curl -X GET \
  https://api.agent37.com/v1/instances/ab12cd34ef/crons/9903c325ee3c/runs \
  -H "Authorization: Bearer sk_live_..."
```

```python Python wrap theme={null}
import requests

response = requests.get(
    "https://api.agent37.com/v1/instances/ab12cd34ef/crons/9903c325ee3c/runs",
    headers={
        "Authorization": "Bearer sk_live_..."
    },
)
response.raise_for_status()
print(response.json())
```

```javascript Node wrap theme={null}
const response = await fetch(
  "https://api.agent37.com/v1/instances/ab12cd34ef/crons/9903c325ee3c/runs",
  {
    method: "GET",
    headers: {
      "Authorization": "Bearer sk_live_..."
    },
  },
);
if (!response.ok) {
  throw new Error(await response.text());
}
console.log(await response.json());
```

```json wrap theme={null}
{
  "data": [
    {
      "id": "0f3a9c21",
      "ran_at": 1790067720,
      "session_id": "7f3e0b6c52a949d2b1c4a8e9d0f31726",
      "status": "triggered",
      "reason": null
    },
    {
      "id": "b71e40aa",
      "ran_at": 1789981320,
      "session_id": null,
      "status": "skipped",
      "reason": "instance_stopped"
    }
  ]
}
```

**status** `string`

`triggered` (the turn was started) or `skipped` (nothing was sent).

**session\_id** `string | null`

The session the firing ran on. Read what the agent actually did with [`GET /v1/sessions/{session_id}`](https://www.agent37.com/docs/agents-api/sessions#retrieve-a-session-with-history) on the instance URL, adding `?profile=` when the cron names one. When the firing goes to `hermes`, `openclaw` or `claude-code` (the cron's `agent`, or else the template's own), it is set when the run is recorded, so the `202` from [running it now](#run-one-now) already carries it. For `codex`, `grok`, `opencode` and `pi`, whose harnesses issue their own session ids, and on a workspace template when the cron sets no `agent`, it is `null` at first and filled in once the turn finishes. It stays `null` on a turn still running about 13 minutes after the firing (the turn itself carries on). On a skip it is `null`, except a `wake_failed` run that was already given an id: that session never started.

**reason** `string | null`

Why it was skipped: `instance_stopped`, `past_due`, `free_hours_exhausted`, or `wake_failed`.

> [!NOTE]
>
> A cron is fire and forget. `triggered` means the turn was started, not that it succeeded. The agent's answer, its tool calls, and any error live in the session, which is where you read them.

## What fires, and what doesn't

A sleeping instance is woken and the turn runs. An instance you [stopped](https://www.agent37.com/docs/agents-api/instance-lifecycle.md) stays stopped: a schedule never undoes an explicit stop, and the firing is recorded as `skipped` with `instance_stopped`. The same goes for an instance suspended for [non-payment](https://www.agent37.com/docs/agents-api/billing.md) (`past_due`).

Each firing opens its own session, so a cron never interleaves with your chat thread and 15 crons never turn into 15 conversations in the same transcript. If a firing is still running when the next one is due, the next one starts its own session as usual.

A window the platform misses (a schedule that came due while the instance was stopped, or a cron paused for a week and then re-enabled) is skipped, never backfilled.

## Your agent can schedule itself

The agent running on the instance can create its own crons, with the `agent37 cron` CLI baked
into every Agent37 agent image:

```bash wrap theme={null}
agent37 cron add --schedule "0 9 * * 1-5" --prompt "Check my inbox and summarise anything urgent." --timezone America/New_York
```

Also `agent37 cron list`, `agent37 cron update <id> [--pause|--resume]`, `agent37 cron remove <id>`
and `agent37 cron runs <id>`. The images tell the agent this exists, so "check my email every
weekday at 9" is usually enough; no key is involved, since the CLI uses the credential the
instance already holds.

Anything it creates is an ordinary cron: it appears in `GET /v1/instances/{id}/crons`, and you
can edit or delete it there like any other.

## Cost

A cron costs nothing to hold. What it costs is what the turn costs: the compute minutes the instance is awake for, and the [managed services](https://www.agent37.com/docs/agents-api/managed-services.md) the turn uses, exactly as if you had sent the message yourself. An instance with auto-sleep on, fired once an hour, is billed for the minutes it is actually working plus disk for the rest of the day.


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