# The manifest

Source: https://docs.apphaven.eu/manifest

`apphaven.yaml`, in the root of your repository, describes your application to
AppHaven. It declares three things:

- **[Services](https://docs.apphaven.eu/services.md)**: the containers and managed databases your app
  runs.
- **[Volumes](https://docs.apphaven.eu/volumes.md)**: the storage those services keep.
- **[Environment variables](https://docs.apphaven.eu/environment-variables.md)**: the configuration they
  run with.

AppHaven validates the manifest and uses it to run your app. To change your
app's shape, edit `apphaven.yaml` and push; the next deploy picks it up.

## A complete example

A web service built from the repository's Dockerfile, a managed database, and
a persistent volume for uploads:

```yaml
version: 1

services:
  web:
    type: container
    build:
      dockerfile: Dockerfile       # built from your repository on every deploy
    ports:
      - 3000                       # served on its own address over HTTPS
    env:
      NODE_ENV: production
      DATABASE_URL: ${service.db.url}   # a ready-to-use connection URL
    volumes:
      - name: uploads
        mount_path: /app/uploads
    depends_on:
      - service: db
        condition: healthy         # wait until the database accepts connections

  db:
    type: postgres                 # managed database, provisioned by AppHaven
    version: "17"

volumes:
  uploads:
    type: persistent               # kept across deploys
```

With this manifest, AppHaven builds `web` from the `Dockerfile` in your
repository, provisions the `db` database with generated credentials, creates
the `uploads` volume, starts `web` once the database is ready (with
`DATABASE_URL` set to a real connection URL), and serves port `3000` on its
own address over HTTPS.

## Ports and addresses

Every port you declare on a service is an **entry point** of your app: a
service and port that AppHaven serves on its own address, with its own
[access setting](https://docs.apphaven.eu/access.md). A website with a CMS in the same repository gets
two addresses, one for each:

```yaml
services:
  web:
    type: container
    build: { context: web }
    ports: [3000]          # entry point "web"
  cms:
    type: container
    build: { context: cms }
    ports: [1337]          # entry point "cms"
  db:
    type: postgres         # no ports: reachable only inside the app, as db:5432
```

- Each entry point gets a generated address on the deploy where it first
  appears, and that address then never changes, also when you rename the app
  or add and remove other entry points. When that deploy has a single entry
  point, the address is the short form, such as `shop-p12.ams1.apphaven.app`;
  otherwise it carries the entry point's name, such as
  `shop-web-p12.ams1.apphaven.app` and `shop-cms-p12.ams1.apphaven.app`. A
  new entry point whose address is still held by a removed one gets a short
  code instead, such as `shop-x7k2qa-p12.ams1.apphaven.app`.
- A new entry point starts **private**. You decide in the console which ones
  are public, so a commit never opens anything to the internet by itself. The
  one exception is an app's first deploy: if it has a single entry point, that
  entry point takes the access setting chosen before the deploy. With several,
  every one starts private and you set each one.
- A [chosen address or custom domain](https://docs.apphaven.eu/custom-domains.md) belongs to one entry
  point.
- A service without `ports` gets no address. Other services of the app still
  reach it by its name.
- There is no order and no main entry point: the order of services and ports
  in the file does not matter.

Up to **4 ports per service** and **4 in the whole manifest**.

:::caution[Changing a port or renaming a service creates a new entry point]

AppHaven recognises an entry point by its service name and port. Change
`ports: [3000]` to `ports: [8080]`, or rename `web` to `site`, and the next
deploy sees one entry point gone and a new one added. The new one has **a new
address, starts private, and has no chosen address or custom domain
attached**. The old one stops being served.

`apphaven validate --app <app>` warns before you push: it names the entry
point that would disappear and any address that would no longer be attached.
The deploy result in the console shows the same warning after the deploy. Its settings are kept for 30 days, so putting the
port or name back restores the entry point as it was. A chosen address or
custom domain stays with your app until you attach it to another entry point
in **Settings > Domains** or release it.

After 30 days the same service and port come back as a new entry point: private,
without public paths, and with its chosen addresses and custom domains held on
the app. `apphaven validate --app` and the deploy result warn when it loses
public access, public paths or an address that way.

:::

## Top-level fields

| Field      | Type                       | Required | Description                                                                  |
| ---------- | -------------------------- | -------- | ----------------------------------------------------------------------------- |
| `version`  | int                        | no       | The manifest schema version. Currently `1`, which is also the default.        |
| `services` | map of name → service spec | yes      | Your app's [services](https://docs.apphaven.eu/services.md). At least one is required.                   |
| `volumes`  | map of name → volume spec  | no       | [Volumes](https://docs.apphaven.eu/volumes.md) your services mount. Required only if a service references a volume. |
| `auth`     | object                     | no       | [Public-path suggestions](#suggesting-a-public-path) for the app's access settings. |

## Naming rule

Every name you choose in the manifest (each service name and each volume
name) must match:

```
^[a-zA-Z0-9][a-zA-Z0-9_\-]{0,62}$
```

- Starts with a letter or digit.
- 1–63 characters long.
- Contains only letters, digits, underscores (`_`), and dashes (`-`).

:::tip

Use lowercase service and volume names so they're accepted as written.

:::

## Suggesting a public path

If part of your app has to answer without a login (a webhook, a health probe, an
API with its own keys), the manifest can ask for it:

```yaml
auth:
  public_paths:
    - path: /webhooks/stripe
      reason: Stripe webhook receiver, verified by signature
    - path: /healthz
      reason: Uptime probe
```

Each entry needs a `path` and a `reason`, and there can be at most 10 of them.
A `path` is either an exact path (`/healthz`) or a prefix ending in `/*`
(`/api/*`, which covers everything under `/api/`).

In an app with several [entry points](#ports-and-addresses), an entry can say
which one it is for with `service` and, optionally, `port`:

```yaml
auth:
  public_paths:
    - path: /api/*
      service: cms
      port: 1337
      reason: Content API, read by the mobile app with its own API keys
```

| Fields given | Offered on |
| ------------ | ---------- |
| neither | every entry point of the app |
| `service` | every entry point of that service |
| `service` and `port` | that one entry point |

`service` must name a service that declares `ports`, and `port` needs
`service` and must be one of its ports. An accepted suggestion applies to the
entry point it was accepted on.

This legacy block is imported into **Proposals** from the production branch. A project
administrator reviews each recommendation there. New manifests should use the explicit
[`proposals`](https://docs.apphaven.eu/proposals.md) section with stable IDs. Adding a recommendation changes no settings;
removing one never revokes an accepted public path.

## Validation

AppHaven validates the manifest before anything is deployed. Validation is
strict for workload settings: unknown fields are rejected with a clear error.
Proposal metadata is validated by `apphaven validate` and the recommendation importer.
Invalid recommendations never block deployment of an otherwise valid workload.

When a manifest is rejected, the message describes the problem. Common causes:

| Cause                                                 | Example message                                                  |
| ----------------------------------------------------- | ----------------------------------------------------------------- |
| An unknown field (often a typo)                       | `service web: unknown field "prots"`                              |
| A name doesn't match the naming rule                  | `service name "my app!" is invalid`                               |
| Unknown service `type`                                | `service web: type "vm" not supported`                            |
| Container with neither `image` nor `build`            | `service web: image or build is required`                         |
| A field that isn't valid for the service type         | `service db: "ports" is not allowed on a postgres service`        |
| Port out of range                                     | `service web: port 99999 out of range`                            |
| Too many ports                                        | `service web: declares 5 ports but at most 4 are allowed`         |
| A public path names a service without ports          | `auth.public_paths: /x: service "db" declares no ports`           |
| `depends_on` cycle                                    | `depends_on cycle: web -> db -> web`                              |
| `condition: healthy` on a target with no healthcheck  | `service web depends_on db (healthy) but db has no healthcheck`   |
| Reference to an unknown service or field              | `service web: ${service.cache.url} references unknown service "cache"` |
| Reference to an undeclared volume                     | `service web: references undeclared volume "missing"`             |
| Non-canonical mount path                              | `service web: mount_path "/a/../b" must be canonical`             |
| Unknown volume type                                   | `volume cache: type "weird" not supported`                        |

## Where to go next

- [Services](https://docs.apphaven.eu/services.md): containers and managed databases.
- [Volumes](https://docs.apphaven.eu/volumes.md): durable and scratch storage.
- [Environment variables](https://docs.apphaven.eu/environment-variables.md): configuration and secrets.
- [Manifest reference](https://docs.apphaven.eu/reference/manifest.md): every valid field, on one page.
- [Getting started](https://docs.apphaven.eu/getting-started.md): deploy an app built from this manifest.

## Configuration proposals

Use [`proposals`](https://docs.apphaven.eu/proposals.md) for configuration recommendations that travel with the repository. Only the production branch is imported; a human reviews each change.
