> ## 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.

# app.yaml

> An app's root file: the app, what an install asks for, the accounts it acts as, migration and upgrade.

An app is a set of blobs, of several types, that work together. Its definition is `app.yaml` at the root of a git
repository and one folder per blob under `blobs/`, each holding that blob's [`blob.yaml`](https://docs.blobhub.io/blob-types/app/blob-yaml).
`blobhub app build` compiles the repository into `build/`, `blobhub app push` makes the app blob's draft equal
`build/`, and `blobhub app commit` makes the draft a version. The platform reads `app.yaml` from the app blob and
refuses a commit while the definition has a problem.

The example on these pages is Field Reports, `acme-corp/field-reports`: an app that turns field technicians' notes
into reports, with a workflow blob `flows` and a scheduler blob `schedules`.

## The repository

```mermaid theme={null}
flowchart LR
  src["The repository, in git<br/>app.yaml, schemas/<br/>blobs/flows: blob.yaml,<br/>definitions, src, widgets"]
  out["build/, git-ignored<br/>app.yaml, schemas/<br/>blobs/flows: blob.yaml,<br/>definitions"]
  blob["The app blob's draft<br/>the same files<br/>as build/"]
  ver["Version 0.2.0<br/>a committed revision"]
  src -->|"blobhub app build<br/>compiles code, packs widgets"| out
  out -->|"blobhub app push<br/>uploads what changed"| blob
  blob -->|"blobhub app commit"| ver
```

```text theme={null}
field-reports/                          the repository
  app.yaml                              the app
  README.md  LICENSE                    the app blob's Readme and License
  blobs/
    flows/                              one folder per blob, named by its alias
      blob.yaml                         its manifest
      definitions/                      graphs and layouts: compile.json, migrate.json, desk.json, …
      seeds/                            files objects read their value from: report_templates.yaml
      src/                              Python, compiled into the graphs' code components
      widgets/viewer/                   a widget project, packed into a widget definition
    schedules/
      blob.yaml
  schemas/config.json                   what an input is checked against
  build/                                git-ignored: written by build, uploaded by push
  tests/  tools/  docs/                 the repository's own; never uploaded
```

* **The app is three things at the root:** `app.yaml`, `blobs/` and `schemas/`, with `README.md` and `LICENSE`.
  Everything else in the repository is the repository's own.
* **Blobs are found by folder, never listed.** Every folder under `blobs/` is one blob of the app, and its name, 1 to
  31 of `a-z`, `0-9`, `_` and `-` starting with a letter or a digit, is the blob's alias in the app, so the list cannot
  drift from the tree. Any other path at the root is a problem. An install names the blob it makes
  `<installation>-<alias>`, within the alias grammar of 6 to 42 of `a-z`, `0-9`, `_` and `-`: installed as
  `reports`, Field Reports makes `reports-flows` and `reports-schedules`.
* **`build/` has the same paths.** Two things differ from the sources: code and widgets are compiled into the
  definitions, so `src/` and `widgets/` are not copied, and each manifest loses its `build` keys. Nothing else moves
  or is renamed.
* **The app blob holds `build/`, file for file.** `blobhub app push` uploads what changed and deletes what is gone,
  and writes `README.md` and `LICENSE` as the revision's Readme and License. Git holds sources only; `build/` is
  disposable.

## The file

```yaml theme={null}
type: app
version: "1.0"                     # this format's version
app:
  alias: field-reports             # the app blob that push fills, in the home organization
  label: Field Reports
  version: 0.2.0
  description: Notes from field technicians, turned into reports.
inputs:                            # what an install asks for
  - {name: config, kind: document, label: Report settings, schema: schemas/config.json}
  - {name: weather_key, kind: secret, label: Weather API key, required: false}
accounts:                          # service accounts the app acts as, and the secrets they hold
  - alias: runner
    label: Field Reports runner
    credentials:
      - {alias: weather, type: api_key, body: {api_key: "{{ inputs.weather_key }}"}}
      - {alias: blobhub, account_key: true}            # a key of this account, minted by the platform
      - {alias: sync_token, writable: true}            # created empty; the app fills it
# Optional: the workflow an install runs after it applies content.
migration: {blob: flows, session: reports, workflow: reports-migrate, as: runner}
# Optional: the oldest installed version this one moves from, and the object that says "not now".
# upgrade: {from: 0.2.0, busy: {blob: flows, session: reports, object: install/busy}}
```

| Key | Required | Meaning |
| - | - | - |
| `type` | yes | `app` |
| `version` | yes | `"1.0"`, this format's version. Quote it: unquoted, YAML reads `1.0` as a number |
| `app` | yes | The app itself ([App](#app)) |
| `inputs` | no | What an install asks for ([Inputs](#inputs)) |
| `accounts` | no | The service accounts the app acts as, and their credentials ([Accounts](#accounts)) |
| `migration` | no | The workflow an install runs after it applies content ([Migration](#migration)) |
| `upgrade` | no | When an installation may move to this version ([Upgrade](#upgrade)) |

The only template in `app.yaml` is a credential's `body`. Every other value is read as written, so `migration.as`
names an account by its alias, `runner`, where a manifest writes `"{{ accounts.runner.id }}"`
([Templates](https://docs.blobhub.io/blob-types/app/templates.md)).

## App

| Key | Required | Meaning |
| - | - | - |
| `alias` | yes | The app blob `blobhub app push` fills, in the home organization: `field-reports` is `acme-corp/field-reports` |
| `label` | yes | The app's name, as people read it |
| `version` | yes | The version a commit makes of the draft: `0.2.0`. A semantic version, `MAJOR.MINOR.PATCH` with an optional `-prerelease`, such as `0.2.0` or `1.0.0-rc.1`, of at most 32 characters. Anything else is a problem [`describe`](https://docs.blobhub.io/blob-types/app/operations/describe) reports: `app.yaml: app.version: must be a semantic version, MAJOR.MINOR.PATCH with an optional -prerelease; found '0.5'`, or for a semantic version longer than 32, `app.yaml: app.version: must be at most 32 characters`. Versions compare by semantic-version precedence. A commit is refused when the app blob already holds that version, and a version is never reopened: a fix is the next version |
| `description` | no | One line on what the app does |

## Inputs

What differs per installation is an input: an install asks for each one, and a manifest reads it as
`{{ inputs.<name> }}`.

| Key | Required | Meaning |
| - | - | - |
| `name` | yes | The name a template reads: `config` is `{{ inputs.config }}`. 1 to 64 of `a-z`, `0-9` and `_`, starting with a letter, unique in the file |
| `kind` | yes | `document`, a JSON value such as a settings object; or `secret`, a string such as an API key |
| `label` | yes | What an install shows when it asks for the input |
| `schema` | no | For a `document`, the file under `schemas/` it is checked against: `schemas/config.json`. A document that fails it is refused with `input_invalid` |
| `required` | no | `true` by default. A required input left out is refused with `input_missing` |

* **A secret is read only by a credential's `body`.** `{{ inputs.weather_key }}` works there and nowhere else. A
  manifest that reads a secret input is a problem: [`describe`](https://docs.blobhub.io/blob-types/app/operations/describe) reports `the
  secret input weather_key is read only by a credential body` after the file and the key it found it in, and a version
  with that problem cannot be committed. What an app needs from a secret at run time it reads from the credential,
  which the account's runs find by alias.
* **A secret is never kept in the record.** The install request writes each credential that reads one, as it writes
  any credential. The record keeps only the names of the secret inputs given and never shows them, and the worker that
  renders the manifests never holds a secret.
* **An optional input left out** skips the nearest list item whose template reads it: a credential, an object, a
  definition, a `limits` entry, or one module of an entry's `includes`. Without `weather_key`, Field Reports installs
  with no `weather` credential. An item is named in the plan by its string `alias`, else by the nearest aliased item
  around it, else by its path. An item inside another skipped item goes with it, and the plan names only the outer
  one ([Lines](https://docs.blobhub.io/blob-types/installer/operations/plan.md#lines)).

## Accounts

An app acts as service accounts of its own. An install creates each entry as a
[service account](https://docs.blobhub.io/general/service-accounts.md) of the installation's organization, named like a blob as
`<installation>-<alias>` (`reports-runner`), and makes it a member of the installation's blobs with WRITE and of
nothing else. It has no key unless a credential asks for one or an admin mints it. Uninstall retires it, revoking its
keys and credentials.

| Key | Required | Meaning |
| - | - | - |
| `alias` | yes | The name the app gives it: a manifest reads `{{ accounts.runner.id }}`, and `migration.as` names `runner`. 1 to 32 of `a-z`, `0-9` and `-`, starting with a letter, unique in the file |
| `label` | yes | The account's name, as people read it |
| `credentials` | no | The credentials an install stores on the account ([Credentials](#credentials)) |

A schedule or listener that names the account with `as` acts as it
([`blob.yaml`](https://docs.blobhub.io/blob-types/app/blob-yaml#workflow)).

### Credentials

Each credential is stored on the account, so a run the account starts finds it by alias, as
[How a run uses one](https://docs.blobhub.io/general/credentials.md#how-a-run-uses-one) describes.

| Key | Required | Meaning |
| - | - | - |
| `alias` | yes | The credential's alias on the account: `weather` |
| `type` | no | The credential's [type](https://docs.blobhub.io/general/credentials.md#where-a-credential-lives) for a `body`: `api_key`, or `generic` by default. An `account_key` credential is `api_key` |
| `body` | one of three | The credential's secret, a template rendered at install: `{api_key: "{{ inputs.weather_key }}"}`. The rendered body must fit its type |
| `account_key` | one of three | `true`: the platform mints a key of this account and stores it as the credential |
| `writable` | one of three | `true`: the credential is created [writable](https://docs.blobhub.io/general/credentials.md#writable-credentials), holding its `body` if it has one and else `{}`, and the app fills it |

A credential takes exactly one of the three forms:

* **`body`** holds a secret an install was given. A body whose template reads an optional input that was left out is
  skipped, and the credential is not stored.
* **`account_key: true`** gives the app a key of its own account, such as for a workflow that calls the BlobHub API.
  No one copies a key into an input.
* **`writable: true`** is for a secret the app keeps current itself, such as a token it refreshes: the account's own
  key may replace the body. A `body` beside it is only the starting value.

## Migration

`migration` names the workflow an install runs after it applies every manifest, on the first install and on every
upgrade, before the installation turns `ready`. It is an ordinary workflow the app ships in one of its workflow blobs,
and it moves the app's data from the shape one version left to the shape the next one reads. Its contract, input and
outcomes are under [The migration workflow](https://docs.blobhub.io/blob-types/installer/overview.md#the-migration-workflow).

| Key | Required | Meaning |
| - | - | - |
| `blob` | yes | A workflow blob of the app, by its folder: `flows` |
| `session` | yes | A session that blob's manifest declares under `sessions`, where the workflow runs: `reports` |
| `workflow` | yes | The alias of a `workflow` definition that blob's manifest lists: `reports-migrate` |
| `as` | yes | The alias of an account in `accounts`, which the workflow runs as: `runner` |

The new version's workflows may run before its migration ends, so they must accept the data of any version
[`upgrade.from`](#upgrade) admits. A migration may run again over data it already moved, as an install after a
`failed` one does, so it must be idempotent.

## Upgrade

`from` says which installed versions may move to this version; `busy` says, while this version is installed, which
object asks an upgrade or an uninstall to wait. Both keys are optional.

| Key | Required | Read from | Meaning |
| - | - | - | - |
| `from` | no | The target version | The oldest version this one moves from, `0.2.0`: an installation last ready at an older version cannot upgrade to it. At most this version's own. Left out, the version moves from any |
| `busy` | no | The installed version, and, after a failed upgrade, the last ready version too | The object that says an upgrade or an uninstall must wait ([The busy object](#the-busy-object)): `{blob: flows, session: reports, object: install/busy}` |

* **`from` is read from the version being installed**, which knows the data it can read.
* **`busy` is read from the version installed now**, because its workflows are the ones that write the object: the
  installation's `version`, the one it last asked for. After a failed upgrade, when the version it was last ready at
  differs, that version's `busy` is read too, found by version in the app blob as an install finds one, and the first
  object that says busy refuses; a version whose app revision is gone is not read. A development installation reads
  only its own version's, because a draft cannot be found by version.

`busy` names the object by three keys:

| Key | Required | Meaning |
| - | - | - |
| `blob` | yes | A workflow blob of the app, by its folder: `flows` |
| `session` | yes | A session that folder's manifest declares under `sessions`: `reports` |
| `object` | yes | The object's [alias](https://docs.blobhub.io/blob-types/workflow/session-objects/introduction.md#alias-grammar-the-namespace): `install/busy` |

An app without `upgrade` upgrades from any version and is never busy. An installation moves forward only: a target
older than the version the installation last asked for is refused. A development installation is exempt from
that rule and from `from`. What the platform does with each key, the checks a plan runs, is the
installer's ([The checks, in order](https://docs.blobhub.io/blob-types/installer/overview.md#the-checks-in-order)).

[`describe`](https://docs.blobhub.io/blob-types/app/operations/describe) checks `upgrade` with the rest of the definition, and a commit is
refused while it has a problem. Below, each is Field Reports' 0.3.0 given an `upgrade` gone wrong:

| `upgrade` | Problem, ready to print |
| - | - |
| not a mapping | `app.yaml: upgrade: must be a mapping` |
| a key it does not have | `app.yaml: upgrade.since: unknown key; the keys here are from, busy` |
| `from` that is not a semantic version | `app.yaml: upgrade.from: must be a semantic version, MAJOR.MINOR.PATCH with an optional -prerelease; found '0.2'` |
| `from` newer than the version's own | `app.yaml: upgrade.from: 0.4.0 is newer than this version, 0.3.0` |
| `busy` not a mapping | `app.yaml: upgrade.busy: must be a mapping` |
| a key `busy` does not have | `app.yaml: upgrade.busy.alias: unknown key; the keys here are blob, session, object` |
| `busy.blob` not a workflow folder | `app.yaml: upgrade.busy.blob: schedules must be a folder of type blobhub.compute.workflow` |
| `busy.session` not declared | `app.yaml: upgrade.busy.session: nightly is not a session of blobs/flows` |

A `busy.object` that breaks the
[alias grammar](https://docs.blobhub.io/blob-types/workflow/session-objects/introduction.md#alias-grammar-the-namespace) is a problem under
`app.yaml: upgrade.busy.object: `, followed by the grammar's own message:

| `busy.object` | Problem, ready to print |
| - | - |
| missing, or not a string | `app.yaml: upgrade.busy.object: Session object alias must be a string.` |
| not 1 to 256 characters | `app.yaml: upgrade.busy.object: Session object alias length must be 1-256 characters.` |
| a character outside the grammar | `app.yaml: upgrade.busy.object: Session object alias "install busy" contains characters outside [A-Za-z0-9._@-] or /.` |
| a `.` or `..` segment | `app.yaml: upgrade.busy.object: Session object alias "install/../busy" may not contain "." or ".." segments.` |

### The busy object

The app's own workflows write one session object, the one `upgrade.busy` names, to say an upgrade or an uninstall
must wait. The platform reads it and knows nothing of why:

```json theme={null}
{"busy": true, "until": "2026-12-03T03:00:00Z", "reason": "the nightly reports run"}
```

An app writes exactly these three keys, with no `type`. The platform reads only `busy`, `until` and `reason`, and
ignores any other key, `type` among them.

| Key | Value | Meaning |
| - | - | - |
| `busy` | `true` or `false` | Whether an upgrade or an uninstall must wait |
| `until` | A UTC time: ISO 8601 with `Z` or a zero offset, `2026-12-03T03:00:00Z` or `2026-12-03T03:00:00+00:00` | When busy ends on its own. Required while `busy` is `true` |
| `reason` | A string | Why, ready to print: a plan refused for busy shows it |

| The object | Read as |
| - | - |
| absent, or `busy` false | not busy |
| `busy` true, `until` in the future, `reason` text | busy, with `reason` |
| `busy` true, `until` past, `reason` text | not busy: a crashed app never holds its installation for good |
| `busy` not true or false; or `busy` true with `until` not a UTC time (ISO 8601 with `Z` or a zero offset) or `reason` not text | busy, with the reason `the busy object is not {busy, until, reason}`: it fails closed |

Under a malformed object, an upgrade or an uninstall is refused as under a busy one, with the object named:
`app_busy: reports is busy: the busy object is not {busy, until, reason} (acme-corp/reports-flows, session reports,
object install/busy)`.

A plan reads the object for an upgrade, a repeat install over a `ready` or `failed` record and an uninstall; a first
install, an install over an `uninstalled` record and `remove` read none
([the installer's side](https://docs.blobhub.io/blob-types/installer/overview.md#the-busy-object)).

```mermaid theme={null}
stateDiagram-v2
  direction LR
  free: not busy
  taken: busy until T
  [*] --> free
  free --> taken: app writes
  taken --> free: app clears
  taken --> free: T passes
```

* **Who writes it:** the app's workflows, as runtime data, which an install leaves alone
  ([Content and runtime](https://docs.blobhub.io/blob-types/app/blob-yaml.md#content-and-runtime)). A person with WRITE on the blob can write it
  too, which is the escape when the app is broken.
* **The app's duty:** write `busy` before its work starts, ahead of it by at least the longest upgrade the app expects
  (the apply and a migration of up to 15 minutes), with `until` past the work's end by a margin, and clear it when the
  work ends.
* **Write on change, not on every tick.** Each write is an object write and a session event, so an app that rewrites
  the object every few minutes pays for hundreds of writes a day where a few would do.

## How the format grows

* **A new blob type** is a folder whose `blob.yaml` names it. Nothing in `app.yaml` changes. An app holds workflow,
  scheduler and ONNX model blobs today.
* **A new input kind, credential form or template context** is one name each.
* **A new key:** optional keys arrive under `1.x`; a breaking change is `2.0`. The platform refuses a format version
  or a key it does not know, naming it, so an old platform never half-reads a new definition.


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