> For the list of every page, fetch /llms.txt. The API contract is the OpenAPI file linked from the API reference.

# Images and build contexts

A sandbox starts from an image. You have two choices:

- A registry image: name it in `image` on the sandbox create. Nothing to set up.
- A built image: send Meadow a Dockerfile once, get an `image_id`, and use it for every sandbox.

Next step: if a public image has what you need, use `image` and skip this page. Build an image when you need your own packages or files in every sandbox.

## Registry images

```json
{"image": "python:3.12-slim"}
```

The provider pulls the image, so it must be one the provider can reach. Both providers pulled Docker Hub images in our runs.

A name the provider cannot pull fails the create with a general message. See [Attempts and failure reasons](/run-sandboxes/sandboxes#attempts-and-failure-reasons).

On Modal the sandbox ends if the image's default command exits. See [Fields](/run-sandboxes/sandboxes#fields).

## Private registries

Add `registry_auth` with a user name and a password or token for the registry:

```json
{
  "image": "registry.example.com/team/app:1.4",
  "registry_auth": {"username": "<user>", "password": "<token>"},
  "provider": {"only": ["modal"]}
}
```

Only Modal supports this. Daytona is skipped, and with Daytona alone the create fails:

```json
{
  "status": "failed",
  "failure_reason": "all_providers_failed",
  "attempts": [
    {"detail": "daytona does not support inline registry_auth", "outcome": "unsupported", "provider": "daytona"}
  ]
}
```

`registry_auth` also works on an image build, for a private base image, with the same Daytona limit. It cannot be combined with `image_id` on a sandbox create.

We have not pulled a private image through Meadow on the hosted beta. The Daytona rejection above is from a real run. The Modal path is not.

## Build an image from a Dockerfile

```bash
curl -sS -X POST "$MEADOW_BASE_URL/v1/images?wait=true" \
  -H "Authorization: Bearer $MEADOW_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "tools",
    "dockerfile": "FROM python:3.12-slim\nRUN apt-get update && apt-get install -y --no-install-recommends curl openssh-server && rm -rf /var/lib/apt/lists/*\nCMD [\"sleep\", \"infinity\"]\n",
    "build_on": ["modal"]
  }'
```

```json
{
  "builds": [
    {
      "error": null,
      "finished_at": "2026-11-24T21:04:32.593Z",
      "provider": "modal",
      "provider_image_ref": "im-bxxhjZgn",
      "started_at": "2026-11-24T21:04:11.879Z",
      "status": "ready"
    }
  ],
  "created_at": "2026-11-24T21:04:11.879Z",
  "id": "img_0000ac68",
  "name": "tools",
  "sha256": "00000000000000000000000000000000000000000000000000000000000048c9",
  "status": "active"
}
```

`dockerfile` is the Dockerfile text, at most 512 KiB. An image is built once on each provider, and each build has its own `status`: `building`, `ready`, or `failed`.

| Field or parameter | Meaning |
| --- | --- |
| `build_on` | Providers to build on now. Default is every provider in your sandbox route that you have a key for. |
| `?wait=true` | Hold the request until every build in `build_on` is `ready` or `failed`. |
| `wait_timeout_seconds` | Default 600, at most 1800. The builds continue after the wait ends. |
| `name` | Any text. |

Without `wait`, the response comes back at once with builds in `building`. Poll `GET /v1/images/{image_id}`.

The status code is 202 when a build started and 200 when the image already existed. A waited call returns 202 even when every build has finished or failed. Read each build's `status`.

The builds on this page took 15 to 25 seconds on each provider.

### Use the image

```bash
curl -sS -X POST "$MEADOW_BASE_URL/v1/sandboxes?wait=true" \
  -H "Authorization: Bearer $MEADOW_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"image_id": "img_0000ac68", "timeout_seconds": 600}'
```

- A provider whose build is `ready` starts the sandbox at once.
- A provider with no build yet builds first. That time counts toward `create_timeout_seconds`. The image above was built on Modal only, and a first sandbox on Daytona took 30 seconds while Daytona built it.
- A provider whose build `failed` is skipped.

A sandbox from a built image gets the size it asks for on both providers. On Daytona the first sandbox of a new size waits while a snapshot of that size is made. See [Resources](/run-sandboxes/sandboxes#resources).

### The same input gives the same image

The image `id` comes from the Dockerfile text and the build context. Sending the same two again returns the existing image with 200 and builds nothing. An `Idempotency-Key` header works here too: a retry with the same value and body returned the first answer with `Idempotent-Replayed: true`, and the same value with another body returned 409 `idempotency_key_reused`.

```json
{
  "id": "img_00007482",
  "builds": [{"provider": "daytona", "status": "ready"}, {"provider": "modal", "status": "ready"}]
}
```

So a script can call `POST /v1/images` before every run and pay for the build once.

## Build with local files

A Dockerfile that uses `COPY` or `ADD` on local files needs a build context: a gzipped tar of the directory those lines read from.

```bash
COPYFILE_DISABLE=1 tar -czf context.tar.gz -C environment .

curl -sS -X POST "$MEADOW_BASE_URL/v1/build-contexts" \
  -H "Authorization: Bearer $MEADOW_API_KEY" \
  -H "Content-Type: application/gzip" \
  --data-binary @context.tar.gz
```

```json
{
  "expires_at": "2026-11-24T22:25:23.863Z",
  "id": "ctx_0000a6ac",
  "sha256": "000000000000000000000000000000000000000000000000000000000000f2b4",
  "size_bytes": 413
}
```

Pass the `id` as `build_context_id`:

```bash
curl -sS -X POST "$MEADOW_BASE_URL/v1/images" \
  -H "Authorization: Bearer $MEADOW_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "docs-demo",
    "dockerfile": "FROM python:3.12-slim\nRUN pip install --no-cache-dir requests==2.32.3\nCOPY app/ /app/\nWORKDIR /app\nCMD [\"sleep\", \"infinity\"]\n",
    "build_context_id": "ctx_0000a6ac"
  }'
```

The response is 202 with both builds in `building`. About 25 seconds later:

```json
{
  "builds": [
    {"provider": "daytona", "provider_image_ref": "00001f81", "status": "ready"},
    {"provider": "modal", "provider_image_ref": "im-GXj47QBv", "status": "ready"}
  ],
  "id": "img_00007482",
  "name": "docs-demo"
}
```

A sandbox from this image, on either provider, starts in `/app` with the file in place:

```json
{"exit_code": 0, "stderr": "", "stdout": "/app\nrequests 2.32.3\n", "timed_out": false}
```

Build context rules:

| Rule | Value |
| --- | --- |
| Content type | `application/gzip`. Anything else returns 400 with `content-type must be application/gzip`. |
| Size | 100 MB compressed, 512 MiB unpacked, 10,000 entries |
| Entries | Regular files and directories only. No symlinks. |
| Kept for | 24 hours after its last use. Each image create that names it starts the 24 hours again. |
| Same bytes | Uploading the same bytes again returns the same `id`. |

There is no call to delete a build context. It expires by itself. A project cannot be deleted while it holds one that has not expired.

Large inputs such as datasets and model weights do not belong in a build context. Download them in a `RUN` line.

## When a build fails

```json
{
  "id": "img_000097ac",
  "name": "broken",
  "builds": [
    {"provider": "daytona", "status": "failed", "error": "provider image build failed", "provider_image_ref": "00003ab2"},
    {"provider": "modal", "status": "failed", "error": "provider failed to build image", "provider_image_ref": "im-Wjvt2JDs"}
  ]
}
```

Meadow does not return the build log. `error` is a general message. To find the cause:

1. Check for a `COPY` of local files without a `build_context_id`. It fails with exactly these messages.
2. Build the Dockerfile locally with `docker build`.
3. Look up `provider_image_ref` in the provider's own console, which has the build log.

Fix the Dockerfile and create again. A different Dockerfile is a different image, so the failed one stays until you delete it.

Other errors:

| Status | Message | Cause |
| --- | --- | --- |
| 400 | `dockerfile is required` | |
| 404 | `build context not found` | The ID is wrong or the context expired. Upload it again. |
| 400 | `build context must be a valid gzipped tar archive` | The body is not a `.tar.gz`. |
| 400 | `build context gzip stream is corrupt` | The gzip stream is damaged, or other data follows it. Zero bytes after the stream are accepted: `tar` on macOS adds them when it writes to a pipe, and a context piped that way (`tar -czf - -C environment . \| curl --data-binary @- ...`) returned 201 on the hosted beta. |
| 403 | `project routing is locked` | The project is locked and the request sent `build_on`. |

## Rebuild

Send the same request with `"rebuild": true` to build again, for example to pick up a newer base image. The `id` stays the same and each provider gets a new `provider_image_ref`.

```json
{
  "id": "img_00007482",
  "builds": [
    {"provider": "daytona", "status": "ready", "provider_image_ref": "00002d0b"},
    {"provider": "modal", "status": "ready", "provider_image_ref": "im-rLmt3YTv"}
  ]
}
```

The previous provider image is removed, unless a sandbox created from this `image_id` is still live. In that case it is removed when you delete the image.

## List, get, and delete

```bash
curl -sS "$MEADOW_BASE_URL/v1/images?limit=50" -H "Authorization: Bearer $MEADOW_API_KEY"
curl -sS "$MEADOW_BASE_URL/v1/images/img_00007482" -H "Authorization: Bearer $MEADOW_API_KEY"
curl -sS -X DELETE "$MEADOW_BASE_URL/v1/images/img_00007482" -H "Authorization: Bearer $MEADOW_API_KEY"
```

### Delete an image

Delete removes the image at every provider. Running sandboxes are not affected. It took up to 10 seconds in our runs. The call has three answers, by the same rule as a sandbox delete:

| Status | Meaning | What to do |
| --- | --- | --- |
| 204 | Every provider image is gone. | Nothing. |
| 202 | A provider delete is still under way. The body is the image with `"status": "deleting"`. Meadow finishes in the background. | Poll `GET /v1/images/{image_id}` until it returns 404, or call delete again. A `deleting` image cannot start a sandbox. |
| 200 | The image is deleted in Meadow and a copy may remain at a provider. `vendor_copies_may_remain` names the provider. | Remove the copy in your provider account by hand. |

In our runs on the hosted beta every delete returned 204, after 9 to 12 seconds. The 202 and 200 answers have not been seen there.

Meadow deletes the provider image with your current provider key for that provider, whatever key built the image. If that key is gone, or the provider keeps refusing, Meadow tries at most 10 times over at most 24 hours, then finishes the delete on its side and stops. From then on the image reads `deleted` with `vendor_copies_may_remain`, and both delete and get return it with 200. The same happens at once when you changed the provider key and the provider reports no such image under the new key.

Once an image is gone, a second delete returns 404, and so does a get. This differs from sandboxes, where the record stays.

<a id="what-each-vendor-keeps"></a>

## What each provider keeps

Meadow builds in your own provider account, so the results are yours and count against your provider plan.

| | Daytona | Modal |
| --- | --- | --- |
| A built image is | A snapshot | An image in the Meadow app of your environment |
| After `DELETE /v1/images/{id}` | The snapshot is deleted. | The image is deleted, and so is the registry login stored for the build. |
| Build context bytes | Stay in your Daytona object storage. | Stay in your Modal storage. |

Neither provider has a call to delete uploaded build context bytes, so Meadow cannot remove them. Keep secrets out of build contexts. Pass them at run time in `env`.

Meadow's own copy of a build context is deleted when it expires.

More in [Known limits](/reference/known-limits#running-sandboxes).

## API reference

Operations on this page: [`createImage`](/reference/api-reference#createimage), [`getImage`](/reference/api-reference#getimage), [`listImages`](/reference/api-reference#listimages), [`deleteImage`](/reference/api-reference#deleteimage), [`createBuildContext`](/reference/api-reference#createbuildcontext), [`createSandbox`](/reference/api-reference#createsandbox).