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

# Plan

Say what an install would do, without doing it: the version it would read, the inputs it asks for, the lines it would
act on, the limits it needs, and every problem that would stop it, with a digest of all of it when nothing does.
`plan` writes nothing. It is the dry run, the web's source of install fields and the command line's printout, and
[`install`](https://docs.blobhub.io/blob-types/installer/operations/install) runs it again before it acts.

## **POST** `/revisions/:id/data/query` (Command: `plan`)

### Request Body

| Parameter | Type | Required | Description |
| :- | :- | :- | :- |
| `command` | string | Yes | Must be `plan`. |
| `installation` | string | Yes | The installation's alias. A new alias plans an install; an existing one plans an upgrade, or an install again. See [Installations](https://docs.blobhub.io/blob-types/installer/overview.md#installations) for its rule. |
| `app` | object | Yes | The app: `org` and `blob`, the app blob's organization and alias, and `version`. |
| `app.version` | string | No | A committed version, such as `0.3.0`. Left out, the newest committed one: the highest by semantic-version precedence. `draft` is the app blob's draft, only when it is in the installer blob's own organization ([Development installations](https://docs.blobhub.io/blob-types/installer/overview.md#development-installations)). |
| `inputs` | object | No | Values by input name: a document as JSON, a secret as a string. On an existing installation, only what changes. |

### Response

| Parameter | Type | Description |
| :- | :- | :- |
| `app` | object | `label`, `version` and `revision_id`: the app, and the revision of the app blob the install would read. Set whenever the version was read, problems or not; `null` only when the plan stops before it reads the version. |
| `from_version` | string | The version the installation last reached `ready` at. `null` on a first install, and on a record that is `uninstalled`. |
| `inputs` | array | Every input of the version, each with `name`, `kind`, `label`, `required` and `given`. |
| `lines` | array | What the install would do, as sentences ([Lines](#lines)). |
| `limits` | array | Every requirement the version has where the install would leave it, met or not ([Limits](#limits)). |
| `deletes` | array | The names of the blobs the install would delete with their data, such as `["reports-schedules"]`. Empty when it deletes none. A client reads this, never the lines, to learn it. |
| `problems` | array | What would stop it, as sentences that start with their refusal code ([Problems](#problems)). Empty when it can install. |
| `digest` | string | The plan's digest, `sha256:` and 64 hex digits ([Digest](#digest)). `install` sends it back as `confirmed`. `null` whenever `problems` is not empty: a plan with a problem has nothing to confirm. |

`given` is true for an input given in this request, a document the record remembers, or a secret given to an earlier
install whose credentials exist. A required input that is not given is the problem `input_missing`.

### Lines

Each line is a sentence the command line and the web print as it is, and the install's log repeats:

| Line | When |
| :- | :- |
| `creates blob reports-flows (blobhub.compute.workflow)` | A folder of the version whose blob does not exist yet. |
| `updates blob reports-flows` | A folder whose blob exists. |
| `deletes blob reports-schedules and its data` | A blob of the installation that the version no longer has. |
| `creates service account reports-runner, a member of both blobs with WRITE` | An account not made yet; `its blob` for an app of one blob, `its blobs` for more than two. |
| `stores credentials weather, blobhub and sync_token on reports-runner` | The credentials the install writes now; `stores credential` for one. |
| `skips credential weather: weather_key was not given` | An optional input left out. Another item it skips is `skips <list item> <alias> in blob <blob>: <input> was not given`, as `skips schedule nightly in blob reports-schedules: weather_key was not given`, the name of its list without a final `s` and its `alias`; a `limits` entry is `skips limit <id> in blob <blob>: <input> was not given`, and one module of an entry's `includes` is `skips a module of limit <id> in blob <blob>: <input> was not given`. An item with no alias of its own is named by the nearest aliased item around it, as `skips an item of schedule nightly in blob reports-schedules: weather_key was not given`, or, with none, by its path, as `skips an item of options.groups[2].tags in blob reports-flows: weather_key was not given`. An item inside another skipped item prints once, as the outer one. `<blob>` is the blob's name, `<installation>-<folder>`, as `reports-flows`. |
| `widget report-viewer asks to: read session objects, read threads` | A blob type's notice, such as the permissions a widget asks for. |
| `runs reports-migrate in session reports` | The [migration workflow](https://docs.blobhub.io/blob-types/installer/overview.md#the-migration-workflow); `, from 0.2.0 to 0.3.0` follows on an upgrade. |

### Limits

One row per [requirement](https://docs.blobhub.io/blob-types/installer/overview.md#requirements), declared or derived, after requirements that
name the same limit at the same place are merged. A requirement with nothing to count answers no row: no `room` row
when the install makes nothing new, no row for a category the manifest leaves empty, such as
`blobhub.compute.workflow.listeners_per_revision` for Field Reports, and no `<type id>.enabled` row when every blob
exists. Rows come unmet first, then by `where` and `id`. `need` and `value` are ready to print, so a client prints
them as they are.

| Field | Type | Description |
| :- | :- | :- |
| `where` | string | The place: the organization, `acme-corp`, or a blob as the install will leave it, `acme-corp/reports-flows`. |
| `id` | string | The limit's id, as the [catalog](https://docs.blobhub.io/general/limits.md#the-catalog) names it. |
| `need` | string | What the version needs: `at least 400`, `at most 86400`, `room for 2 more`, `includes requests, yaml` or `on`. |
| `value` | string | What the place has, with the level the value comes from: `1000 (default)`; `forever (org)` for a retention kept forever; `requests (org)`, or `none (default)` for no modules; `on (default)` or `off (org)`. For `room`, what is left, then what is allowed and held: `30 (30 allowed, 0 held, default)`. The level is `default`, `platform` for a fixed limit, or `user`, `org` or `blob` for an override. |
| `met` | boolean | Whether `value` meets `need`. |
| `declared` | boolean | `true` when a `blob.yaml` declares the requirement, `false` when only the platform derives it. |
| `fix` | object | When the row is not met, what would meet it: `target`, where the limit is set, `org:<org>` or `blob:<org>/<blob>`, and `value`, the JSON it is set to, as `{"target": "org:acme-corp", "value": 25}` or `{"target": "blob:acme-corp/reports-flows", "value": ["requests", "yaml"]}`; its `limit_unmet` problem asks [support@blobhub.io](mailto:support@blobhub.io) to set it ([When a requirement is not met](https://docs.blobhub.io/blob-types/installer/overview.md#when-a-requirement-is-not-met)). The digest covers it. `null` when the row is met, and on an unmet row whose value would be past the limit's most permissive value: no override can meet it, and its problem ends `<id> cannot be set above <bound>` instead (`below` for a limit whose bound is a minimum), which for `room` goes on `, so only removing what is held makes room`. |

### Digest

`digest` is `sha256:` and the SHA-256, in hex, of the canonical JSON of what the plan is for and what it says:

* the installer revision and the installation's alias;
* the record's current operation, by an id no response carries, or `null` when the record has none;
* the app revision;
* the document inputs;
* the names of the secret inputs given, never their values;
* `lines`, `limits` and `deletes`.

Another operation, version, input, line or limit value changes it; a secret counts by its name, never by its value. A
client never computes it: it sends back, as `confirmed`, the digest of the plan it showed, and `install` refuses with
`plan_changed` when the plan it makes then has another
([The checks, in order](https://docs.blobhub.io/blob-types/installer/overview.md#the-checks-in-order)).

`digest` is `null` whenever `problems` is not empty: a plan with a problem has nothing to confirm. `install` refuses
such a plan with its first problem's code before it reads `confirmed` ([Examples](#examples)).

### Problems

`plan` answers a problem with status 200 instead of refusing it; [`install`](https://docs.blobhub.io/blob-types/installer/operations/install)
refuses with the first problem's code. The checks run in
[one order](https://docs.blobhub.io/blob-types/installer/overview.md#the-checks-in-order), whose numbers the table keeps. A problem at checks 1
to 8 stops the plan, and `problems` holds only that check's problems: at 1 to 4, one; at 5, every problem of the
version's definition; at 6 to 8, the first of the three. Those are the only stops: past check 8, checks 9 to 14 all
run, and each adds its problems, so one answer lists every problem they find. Each sentence is ready to print; below,
each is Field Reports'.

| # | Refusal | Problem, ready to print |
| :- | :- | :- |
| 1 | `invalid_installation` | `invalid_installation: the installation alias must match ^[a-z0-9][a-z0-9_-]{0,30}$` |
| 2 | `installation_busy` | `installation_busy: reports is installing` |
| 3 | `migration_running` | `migration_running: the migration to 0.3.0 still runs as execution 3c9e1f42-7b05-4d8a-a6e2-91f0d4b7c358 in acme-corp/reports-flows; let it end or stop it` |
| 4 | `version_not_found` | `version_not_found: acme-corp/field-reports has no committed version 0.9.0` |
| 4 | `version_not_found` | `version_not_found: acme-corp/field-reports has no draft` |
| 4 | `version_not_found` | `version_not_found: the draft of acme-corp/field-reports installs only into its own organization` |
| 5 | `invalid_app` | `invalid_app: blobs/flows/blob.yaml: limits[0]: no limit is named blobhub.compute.workflow.executions_per_day`, or any other problem of the version's own ([When it is checked](https://docs.blobhub.io/blob-types/app/blob-yaml.md#when-it-is-checked)) |
| 6 | `development_mismatch` | `development_mismatch: reports-dev is a development installation and installs only the draft` |
| 6 | `development_mismatch` | `development_mismatch: reports installs committed versions; install the draft as another installation` |
| 7 | `version_downgrade` | `version_downgrade: reports is at 0.3.0, and 0.2.0 is older; an installation only moves forward` |
| 8 | `upgrade_unsupported` | `upgrade_unsupported: 0.4.0 moves from 0.3.0 or newer, and reports was last ready at 0.2.0; install a version in between first` |
| 9 | `input_invalid` | `input_invalid: config: <schema error>` |
| 9 | `input_missing` | `input_missing: config` |
| 10 | `invalid_installation` | `invalid_installation: the blob name <name> must follow the blob alias rule: 6-42 of a-z, 0-9, _ and -, not shaped like an id` |
| 10 | `alias_in_use` | `alias_in_use: a blob named reports-flows exists` |
| 10 | `blob_not_ready` | `blob_not_ready: blob reports-flows is being deleted; try again shortly` |
| 10 | `invalid_app` | `invalid_app: blobs/flows/blob.yaml: blob reports-flows is a blobhub.compute.scheduler, not a blobhub.compute.workflow` |
| 11 | `invalid_app` | Any problem a blob type finds in a rendered manifest |
| 12 | `invalid_app` | `invalid_app: blobs/flows/blob.yaml: limits[1].includes renders to "requests", not a list of module names` |
| 12 | `limit_unmet` | `limit_unmet: acme-corp/reports-flows needs blobhub.compute.workflow.executions_per_session at least 400; it would be 300 (org). Ask support@blobhub.io to set it` |
| 13 | `person_required` | `person_required: this install makes service account reports-runner and its credentials, which only a person may do; this request comes from a service account's key` |
| 13 | `person_required` | `person_required: this install stores credentials weather and blobhub on reports-runner, which only a person may do; this request comes from a service account's key` |
| 13 | `person_required` | `person_required: this install makes service account reports-runner and its credentials, which only a person may do; this request does not come from a person` |
| 14 | `app_busy` | `app_busy: reports is busy until 2026-12-03T03:00:00Z: the nightly reports run (acme-corp/reports-flows, session reports, object install/busy)` |
| 14 | `app_busy` | `app_busy: reports is busy: the busy object is not {busy, until, reason} (acme-corp/reports-flows, session reports, object install/busy)` |

* **10, `blob_not_ready`.** A blob of the installation is still being deleted, after an uninstall. Try again shortly.
* **12, `limit_unmet`.** One sentence per unmet requirement, each with its row in `limits`; the other needs, `room`,
  `at_most`, `includes` and on, and the forms past a limit's most permissive value, are under
  [When a requirement is not met](https://docs.blobhub.io/blob-types/installer/overview.md#when-a-requirement-is-not-met).
* **13, `person_required`.** The first form makes the account. The second writes credentials on an account that
  exists: an upgrade given `weather_key` again, after the `blobhub` credential was deleted, rewrites `weather` and
  mints `blobhub` anew; for one credential it reads `stores credential weather on reports-runner`. The third answers a
  caller that is neither a person nor a service account. An account that stores no credential reads
  `makes service account reports-runner`, without ` and its credentials`.
* **14, `app_busy`.** The second form is an object that is not `{busy, until, reason}`, which reads as busy
  ([The busy object](https://docs.blobhub.io/blob-types/app/app-yaml.md#the-busy-object)).

### Errors

| Status | Error | Cause |
| :- | :- | :- |
| 400 | `invalid_request_body` | A parameter is missing or has the wrong type. Or a string anywhere in the body, a key included, holds a lone surrogate, which is refused before any check: `<dotted.path>: a lone surrogate is not valid UTF-8`, as `inputs.config.city: a lone surrogate is not valid UTF-8`. A key that holds one is written escaped in the path, as `inputs.config.city.\udc00: a lone surrogate is not valid UTF-8`, where `\udc00` is six ASCII characters, `\\udc00` on the wire. |
| 403 | `forbidden` | The caller does not have ADMIN on the installer blob and on its organization, or the caller's user may not read the app blob: it does not exist, or it is not public and they are not a member of it or of its organization. |
| 409 | `blob_not_ready` | The app blob is not ready: it is still being made or deleted. |
| 503 | `renderer_unavailable` | The platform's template renderer could not be reached. Nothing was decided; ask again. |

### Examples

The first install of `reports`, at 0.2.0, with its report settings and a weather key. Nothing is installed yet, so
`from_version` is `null`, and the installer's own requirements join the version's: both blob types enabled, room for
two blobs in `acme-corp` and for one record in `acme-corp/installed-apps`. A secret is never echoed: the answer says
only that `weather_key` is given.

```json Request theme={null}
{
  "command": "plan",
  "installation": "reports",
  "app": {"org": "acme-corp", "blob": "field-reports", "version": "0.2.0"},
  "inputs": {
    "config": {"timezone": "Europe/Oslo", "sites": ["north-yard"]},
    "weather_key": "wk_example_…"
  }
}
```

```json Response theme={null}
{
  "status": "success",
  "app": {
    "label": "Field Reports",
    "version": "0.2.0",
    "revision_id": "5d2a7c90-3b1e-4f6a-9c08-7e4b2d1f6a35"
  },
  "from_version": null,
  "inputs": [
    {"name": "config", "kind": "document", "label": "Report settings", "required": true, "given": true},
    {"name": "weather_key", "kind": "secret", "label": "Weather API key", "required": false, "given": true}
  ],
  "lines": [
    "creates blob reports-flows (blobhub.compute.workflow)",
    "creates blob reports-schedules (blobhub.compute.scheduler)",
    "creates service account reports-runner, a member of both blobs with WRITE",
    "stores credentials weather, blobhub and sync_token on reports-runner",
    "widget report-viewer asks to: read session objects, read threads",
    "runs reports-migrate in session reports"
  ],
  "limits": [
    {"where": "acme-corp", "id": "blobhub.compute.scheduler.enabled", "need": "on", "value": "on (default)",
     "met": true, "declared": false, "fix": null},
    {"where": "acme-corp", "id": "blobhub.compute.workflow.enabled", "need": "on", "value": "on (default)",
     "met": true, "declared": false, "fix": null},
    {"where": "acme-corp", "id": "platform.blobs_per_org", "need": "room for 2 more",
     "value": "4 (24 allowed, 20 held, org)", "met": true, "declared": false, "fix": null},
    {"where": "acme-corp/installed-apps", "id": "blobhub.package.installer.installations_per_revision",
     "need": "room for 1 more", "value": "19 (20 allowed, 1 held, default)", "met": true, "declared": false,
     "fix": null},
    {"where": "acme-corp/reports-flows", "id": "blobhub.compute.workflow.definitions_per_revision",
     "need": "at least 2", "value": "10 (default)", "met": true, "declared": false, "fix": null},
    {"where": "acme-corp/reports-flows", "id": "blobhub.compute.workflow.executions_per_session",
     "need": "at least 400", "value": "27000 (org)", "met": true, "declared": true, "fix": null},
    {"where": "acme-corp/reports-flows", "id": "blobhub.compute.workflow.playgrounds_per_revision",
     "need": "at least 1", "value": "10 (default)", "met": true, "declared": false, "fix": null},
    {"where": "acme-corp/reports-flows", "id": "blobhub.compute.workflow.session_objects_per_session",
     "need": "at least 2", "value": "1000 (default)", "met": true, "declared": false, "fix": null},
    {"where": "acme-corp/reports-flows", "id": "blobhub.compute.workflow.sessions_per_revision",
     "need": "room for 1 more", "value": "30 (30 allowed, 0 held, default)", "met": true, "declared": false,
     "fix": null},
    {"where": "acme-corp/reports-flows", "id": "blobhub.compute.workflow.widgets_per_revision",
     "need": "at least 1", "value": "10 (default)", "met": true, "declared": false, "fix": null},
    {"where": "acme-corp/reports-schedules", "id": "blobhub.compute.scheduler.min_interval_seconds",
     "need": "at most 86400", "value": "60 (default)", "met": true, "declared": false, "fix": null},
    {"where": "acme-corp/reports-schedules", "id": "blobhub.compute.scheduler.schedules_per_revision",
     "need": "at least 1", "value": "10 (default)", "met": true, "declared": false, "fix": null}
  ],
  "deletes": [],
  "problems": [],
  "digest": "sha256:9d7905e6b56fe7c0a7b8219120b7bc66b664474d0b9c10733c406b05b1a6b76e"
}
```

An upgrade of `reports` from 0.2.0 to 0.3.0, with new report settings. The record remembers the first install's
document, and the `weather` credential exists, so `weather_key` counts as given. Both blobs, the session `reports` and
the record exist, so only the rows at the two blobs remain, and nothing is in the way.

```json Request theme={null}
{
  "command": "plan",
  "installation": "reports",
  "app": {"org": "acme-corp", "blob": "field-reports", "version": "0.3.0"},
  "inputs": {
    "config": {"timezone": "Europe/Oslo", "sites": ["north-yard", "east-depot"]}
  }
}
```

```json Response theme={null}
{
  "status": "success",
  "app": {
    "label": "Field Reports",
    "version": "0.3.0",
    "revision_id": "8e41c3b7-0d92-4a5f-b6e1-2c7f9a03d58e"
  },
  "from_version": "0.2.0",
  "inputs": [
    {"name": "config", "kind": "document", "label": "Report settings", "required": true, "given": true},
    {"name": "weather_key", "kind": "secret", "label": "Weather API key", "required": false, "given": true}
  ],
  "lines": [
    "updates blob reports-flows",
    "updates blob reports-schedules",
    "widget report-viewer asks to: read session objects, read threads",
    "runs reports-migrate in session reports, from 0.2.0 to 0.3.0"
  ],
  "limits": [
    {"where": "acme-corp/reports-flows", "id": "blobhub.compute.workflow.definitions_per_revision",
     "need": "at least 2", "value": "10 (default)", "met": true, "declared": false, "fix": null},
    {"where": "acme-corp/reports-flows", "id": "blobhub.compute.workflow.executions_per_session",
     "need": "at least 400", "value": "27000 (org)", "met": true, "declared": true, "fix": null},
    {"where": "acme-corp/reports-flows", "id": "blobhub.compute.workflow.playgrounds_per_revision",
     "need": "at least 1", "value": "10 (default)", "met": true, "declared": false, "fix": null},
    {"where": "acme-corp/reports-flows", "id": "blobhub.compute.workflow.session_objects_per_session",
     "need": "at least 2", "value": "1000 (default)", "met": true, "declared": false, "fix": null},
    {"where": "acme-corp/reports-flows", "id": "blobhub.compute.workflow.widgets_per_revision",
     "need": "at least 1", "value": "10 (default)", "met": true, "declared": false, "fix": null},
    {"where": "acme-corp/reports-schedules", "id": "blobhub.compute.scheduler.min_interval_seconds",
     "need": "at most 86400", "value": "60 (default)", "met": true, "declared": false, "fix": null},
    {"where": "acme-corp/reports-schedules", "id": "blobhub.compute.scheduler.schedules_per_revision",
     "need": "at least 1", "value": "10 (default)", "met": true, "declared": false, "fix": null}
  ],
  "deletes": [],
  "problems": [],
  "digest": "sha256:8140a9ff21b018e7786571e175bbd718488dd616886c4dec4b92304e53111acd"
}
```

The same upgrade, had `blobhub.compute.workflow.executions_per_session` been lowered to 300 for `acme-corp` since the
first install. The row `flows` declares is not met, so it comes first, with its `fix`; the plan answers the problem
with status 200 and no `digest`, and `install` would refuse with `limit_unmet` until the limit is set.

```json Response theme={null}
{
  "status": "success",
  "app": {
    "label": "Field Reports",
    "version": "0.3.0",
    "revision_id": "8e41c3b7-0d92-4a5f-b6e1-2c7f9a03d58e"
  },
  "from_version": "0.2.0",
  "inputs": [
    {"name": "config", "kind": "document", "label": "Report settings", "required": true, "given": true},
    {"name": "weather_key", "kind": "secret", "label": "Weather API key", "required": false, "given": true}
  ],
  "lines": [
    "updates blob reports-flows",
    "updates blob reports-schedules",
    "widget report-viewer asks to: read session objects, read threads",
    "runs reports-migrate in session reports, from 0.2.0 to 0.3.0"
  ],
  "limits": [
    {"where": "acme-corp/reports-flows", "id": "blobhub.compute.workflow.executions_per_session",
     "need": "at least 400", "value": "300 (org)", "met": false, "declared": true,
     "fix": {"target": "blob:acme-corp/reports-flows", "value": 400}},
    {"where": "acme-corp/reports-flows", "id": "blobhub.compute.workflow.definitions_per_revision",
     "need": "at least 2", "value": "10 (default)", "met": true, "declared": false, "fix": null},
    {"where": "acme-corp/reports-flows", "id": "blobhub.compute.workflow.playgrounds_per_revision",
     "need": "at least 1", "value": "10 (default)", "met": true, "declared": false, "fix": null},
    {"where": "acme-corp/reports-flows", "id": "blobhub.compute.workflow.session_objects_per_session",
     "need": "at least 2", "value": "1000 (default)", "met": true, "declared": false, "fix": null},
    {"where": "acme-corp/reports-flows", "id": "blobhub.compute.workflow.widgets_per_revision",
     "need": "at least 1", "value": "10 (default)", "met": true, "declared": false, "fix": null},
    {"where": "acme-corp/reports-schedules", "id": "blobhub.compute.scheduler.min_interval_seconds",
     "need": "at most 86400", "value": "60 (default)", "met": true, "declared": false, "fix": null},
    {"where": "acme-corp/reports-schedules", "id": "blobhub.compute.scheduler.schedules_per_revision",
     "need": "at least 1", "value": "10 (default)", "met": true, "declared": false, "fix": null}
  ],
  "deletes": [],
  "problems": [
    "limit_unmet: acme-corp/reports-flows needs blobhub.compute.workflow.executions_per_session at least 400; it would be 300 (org). Ask support@blobhub.io to set it"
  ],
  "digest": null
}
```

A first install of `reports` that names `0.9.0`, a version `acme-corp/field-reports` never committed, stops at
check 4: without a version there is nothing to plan. The answer holds only the problem, `app` is `null`, and so is
`digest`, as on any plan with a problem. `install` with the same `app` refuses with `version_not_found` before it
reads `confirmed`.

```json Request theme={null}
{
  "command": "plan",
  "installation": "reports",
  "app": {"org": "acme-corp", "blob": "field-reports", "version": "0.9.0"}
}
```

```json Response theme={null}
{
  "status": "success",
  "app": null,
  "from_version": null,
  "inputs": [],
  "lines": [],
  "limits": [],
  "deletes": [],
  "problems": ["version_not_found: acme-corp/field-reports has no committed version 0.9.0"],
  "digest": null
}
```


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