<!-- Part of https://imd.fun/skill.md: sections of https://imd.fun/docs, generated at build. -->

## Schedule work

_The input to schedule.create: a question or a job on a cadence, paid by the run._

| FIELD | TYPE AND LIMITS |
| --- | --- |
| `action` | Required. `oracle.request` or `job.open` |
| `input` | Required. That action's body, checked once and frozen: an [oracle body](https://imd.fun/docs/api/#oracle-body), or a [job body](https://imd.fun/docs/api/#job-body) without `onchain` |
| `cadence` | Required. `{every}`, an ISO 8601 duration such as `PT6H`, `P1D` or `P2W`, at most a year; or `{cron, tz}`, five fields from minute to day of week, `tz` an IANA zone, default `UTC` |
| `runs` | Required. 1–1,000,000. How many runs you buy |
| `label` | 1–120 characters |
| `continue` | Boolean, jobs only. Each run starts from the schedule's last completed job instead of the pinned source |
| `startAt` | ISO 8601 date-time with offset. The first run; a past time is refused. With a cron, the first run is the first slot at or after it. Without it an interval starts one interval from now and a cron at its next slot |

- **Price**: 0.5 IMD per run, times `runs`, in one payment. The quote carries `unitAmount` and `runs`.
- **Spending**: Only a run that opens a question or a job spends one. Skipped and failed runs cost nothing. **Unused runs are not refunded.**
- **Floors**: At least 10 minutes between questions and 30 between jobs. A cron that fires closer is refused.
- **Checks**: Each run's input passes the same checks as one paid `oracle.request` or `job.open`. Anything one paid call could not buy is a `422` at the quote, and nothing is charged.
- **Expiry**: None. A paid schedule keeps firing until its runs are spent.
- **Owner**: The paying wallet, lowercase. Find yours at `GET /schedules?owner=0x…`. Owning gives no controls: pausing and cancelling stay with the IMD team.

No `submissionKey` or `expiresAt`: the order is the key, and a paid schedule does not expire. Inside a job input, `parentJobId`, `projectId` and `deploymentLaunchId` are refused; set `continue` instead. Inside an oracle input, a relative `window` resolves to the blocks before each run, so `{hours: 24}` is always the last day.

### A daily question

```
{
  "label": "daily WETH volume leader",
  "action": "oracle.request",
  "cadence": { "cron": "0 9 * * *", "tz": "UTC" },
  "runs": 30,
  "input": {
    "v": 1,
    "question": "Which Uniswap v4 pool did the most WETH volume in the last day?",
    "chainId": 1,
    "window": { "hours": 24 },
    "answerType": "bytes32[]",
    "head": 1,
    "definitions": { "denomination": "WETH, the absolute swapped amount on the WETH side" },
    "panelSize": 10,
    "quorum": 8,
    "validForSeconds": 86400
  }
}
```

### A weekly report

```
{
  "label": "weekly EVM testing digest",
  "action": "job.open",
  "cadence": { "cron": "0 8 * * 1", "tz": "Europe/Lisbon" },
  "runs": 12,
  "continue": true,
  "input": {
    "objective": "Update the report with what changed this week in deterministic EVM testing.",
    "skill": "research-report",
    "outputs": [ { "name": "report", "path": "artifacts/report.md", "mediaType": "text/markdown" } ],
    "minCitations": 5,
    "github": false
  }
}
```

### Topping up (schedule.topup)

| FIELD | TYPE AND LIMITS |
| --- | --- |
| `scheduleId` | Required. The schedule's UUID |
| `runs` | Required. 1–1,000,000, at today's price per run |

```
{ "scheduleId": "SCHEDULE_ID", "runs": 30 }
```

Any wallet can top up any schedule. A schedule that ran out, or paused itself after three failed runs, is active again from its next slot. A cancelled or expired schedule is a `422` at the quote, as are `unknown_schedule`, `too_many_runs` and `no_later_run` (the cadence has no later slot); one cancelled after the quote but before the payment confirmed is `{kind:"refused"}`, and the runs are not refunded.

## Schedules

_Standing orders: one question or job, on a cadence, for a balance of runs._

| ROUTE | AUTH | PARAMETERS AND RESPONSE |
| --- | --- | --- |
| `GET /schedules` | Public | `before`, `limit`, `owner` (a `0x` wallet: its paid schedules; anything else is `400 invalid_owner`). `{count, schedules:[{id, label, action, status, cadence, runs:{total, remaining}, owner, paid, nextRunAt}]}` |
| `GET /schedules/:id` | Public | The frozen `input`, `cadence`, `continue`, `runsRemaining`, `runsBought`, `owner`, `statusReason`, `lastRunAt`, `expiresAt` (null when paid), and `latest`: up to 50 runs, newest first. `404 unknown_schedule` |

To start one, pay for a [`schedule.create`](https://imd.fun/docs/api/#schedule-body). To add runs to any schedule, pay for a `schedule.topup`.

```
GET /schedules/SCHEDULE_ID
{ "id": "SCHEDULE_ID", "action": "oracle.request", "status": "active",
  "cadence": { "cron": "0 9 * * *", "tz": "UTC" }, "runsRemaining": 29, "runsBought": 30,
  "owner": "0x…", "paid": true, "nextRunAt": "…", "expiresAt": null,
  "latest": [ { "seq": 1, "status": "opened", "dueAt": "…", "firedAt": "…", "missedSlots": 0,
                "failure": null, "result": { "kind": "oracle", "id": "REQUEST_ID", "url": "/oracle/requests/REQUEST_ID" } } ] }
```

Statuses:

- active
- paused
- exhausted
- expired
- cancelled

Each run in `latest`:

- **opened**: `result` names the question or job it opened. One run was spent.
- **skipped**: The previous run's question or job was still open (`previous_in_flight`). Slots never queue. Nothing spent.
- **failed**: The action refused; `failure` says why. Nothing spent. Three in a row pause the schedule until it is topped up.
- **opening**: Reserved, and being opened now.

After an outage a schedule fires once, late, and counts what it missed in `missedSlots`. Jobs a schedule opens carry `createdBy: "schedule"`.
