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

# Build an image from a Dockerfile

POST https%3A%2F%2Fapi.usemeadow.ai/v1/images
Content-Type: application/json

Builds an image on each sandbox vendor from Dockerfile text, so that sandboxes
can start from it with `image_id`. The call returns at once. Each vendor's build
has its own status in `builds`. Poll `GET /v1/images/{image_id}`, or pass
`?wait=true` to hold the request until every build is `ready` or `failed`.

The same Dockerfile text and build context always give the same image `id`
within a project. Calling this again for an image that exists returns it with
200 and builds nothing, so a caller that starts the same environment many times
builds once. `name` is a label and is not part of the identity.

If the Dockerfile copies local files (`COPY`, `ADD`), upload them first with
`POST /v1/build-contexts` and pass the returned id as `build_context_id`.

Rules:

* `dockerfile` is required and at most 512 KiB.
* `build_on` picks the vendors to build on now. Left out, Meadow builds on every
  vendor in the project's sandbox order that the account has a key for. A vendor
  that is not built here builds on first use by a sandbox, which counts toward
  that sandbox's create timeout.
* On a project with `routing.lock`, sending `build_on` returns 403.
* `rebuild: true` builds again and keeps the same `id`. The previous build's
  vendor image is removed, unless a sandbox created from this image is still
  `creating`, `running`, or `terminating`.
* Daytona does not support `registry_auth`. A build that sends it fails on
  Daytona.
* A sandbox from `image_id` gets the size it asks for on both vendors. Daytona
  fixes resources on a snapshot, so Meadow keeps one Daytona snapshot per image
  and size, and the first sandbox of a new size waits for that snapshot to be
  made. See `image_id` on `POST /v1/sandboxes`.
* Unknown fields return 400.

Scope: `sandboxes`.

```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-example","dockerfile":"FROM python:3.12-slim\nRUN pip install --no-cache-dir httpx==0.27.2\n"}'
```

Reference: https://docs.usemeadow.ai/api-endpoints/images/create-image

## Authentication

- `Authorization` header (bearer token, required) — A Meadow API key, sent as `Authorization: Bearer mdw_...`. The header `x-api-key: mdw_...` is accepted in its place.

## Request

### Query parameters

- `wait` (boolean, optional, default: false) — When `true`, hold the request until every build started by this call is `ready` or `failed`, or until `wait_timeout_seconds` passes.
- `wait_timeout_seconds` (integer, optional, default: 600) — Longest time to hold the request when `wait` is true, in seconds, from 1 to 1800. A value outside that range returns 400. The builds continue after the wait ends.

### Headers

- `Idempotency-Key` (string, optional) — Makes a retry safe. A repeat with the same key and the same body returns the result of the first call instead of starting again. The same key with a different body returns 409. On `POST /v1/keys`, `POST /v1/projects` and `POST /v1/images` a value is scoped to the API key that sent it: another key that sends the same value starts its own request. The sandbox and exec routes scope it to the API key too. On the exec route the header only has an effect with `background: true`. See Idempotency in the introduction for how long a value is kept. The key is 1 to 255 bytes of printable ASCII. A blank, longer, or non-ASCII key, or the header sent twice, returns 400. A UUID works well.

### Body (application/json)

This endpoint expects an ImageCreate.

- `dockerfile` (string, required) — The Dockerfile text, at most 512 KiB. Not a path.
- `name` (string, optional) — A label for people. Not part of the image identity. Must not be empty when sent.
- `build_context_id` (string, optional) — Local files for the build, from `POST /v1/build-contexts`. Without it, `COPY` of local files fails.
- `registry_auth` (ImageCreateRegistryAuth, optional) — Login for a private base image. Both fields are required when it is sent. Not supported on Daytona.
- `rebuild` (boolean, optional, default: false) — Build again even when an image with these inputs exists. The `id` stays the same. The previous build's vendor image is removed, unless a sandbox created with this `image_id` is still live.
- `build_on` (list of enum, optional) — Providers to build on now. Default is every provider in the project's sandbox order that the account has a key for. Returns 403 on a locked project.
  - Allowed values: `daytona`, `modal`

## Response

### 200

An image with this Dockerfile and build context already exists. Nothing was built.

- `id` (string, required) — Pass as `image_id` on `POST /v1/sandboxes`.
- `builds` (list of ImageBuild, required) — One entry per provider the image has been built on, or is building on.
- `created_at` (datetime, required) — When the image was first created.
- `project_id` (string, optional) — The project the image belongs to.
- `status` (enum, optional) — * `active`: the image can be used. * `deleting`: `DELETE /v1/images/{image_id}` was called and a vendor image is still being removed. A `deleting` image cannot start a sandbox. Posting the same Dockerfile again builds a new image with a new `id`. * `deleted`: shown only on an image with `vendor_copies_may_remain`, which stays readable. Any other deleted image returns 404.
  - Allowed values: `active`, `deleting`, `deleted`
- `vendor_copies_may_remain` (list of enum, optional) — Vendors where Meadow stopped trying to delete its copy of this image, so a copy may still exist there. Absent when there are none. See `DELETE /v1/images/{image_id}`. An `active` image can carry it too: a rebuild removes the previous build's vendor image under the same rule. Deleting such an image later returns 200, not 204, and it stays readable as `deleted`.
  - Allowed values: `daytona`, `modal`
- `name` (string, optional, nullable) — The label given at create. Null when none was given.
- `sha256` (string, optional) — Hash of the Dockerfile text and build context. Two images with the same hash in one project are the same image.

### 202

Builds started. Poll the image until each build is `ready` or `failed`.

- `id` (string, required) — Pass as `image_id` on `POST /v1/sandboxes`.
- `builds` (list of ImageBuild, required) — One entry per provider the image has been built on, or is building on.
- `created_at` (datetime, required) — When the image was first created.
- `project_id` (string, optional) — The project the image belongs to.
- `status` (enum, optional) — * `active`: the image can be used. * `deleting`: `DELETE /v1/images/{image_id}` was called and a vendor image is still being removed. A `deleting` image cannot start a sandbox. Posting the same Dockerfile again builds a new image with a new `id`. * `deleted`: shown only on an image with `vendor_copies_may_remain`, which stays readable. Any other deleted image returns 404.
  - Allowed values: `active`, `deleting`, `deleted`
- `vendor_copies_may_remain` (list of enum, optional) — Vendors where Meadow stopped trying to delete its copy of this image, so a copy may still exist there. Absent when there are none. See `DELETE /v1/images/{image_id}`. An `active` image can carry it too: a rebuild removes the previous build's vendor image under the same rule. Deleting such an image later returns 200, not 204, and it stays readable as `deleted`.
  - Allowed values: `daytona`, `modal`
- `name` (string, optional, nullable) — The label given at create. Null when none was given.
- `sha256` (string, optional) — Hash of the Dockerfile text and build context. Two images with the same hash in one project are the same image.

## Errors

### 400 Bad Request Error

The request breaks a rule. The message names the field.

- `error` (ErrorError, required)
- `request_id` (string, optional) — The same id as the `x-request-id` response header. Quote it when you report a problem.

### 401 Unauthorized Error

The key is missing, malformed, unknown, revoked, or expired, or a key it was minted from no longer exists. Check the key and the header.

- `error` (ErrorError, required)
- `request_id` (string, optional) — The same id as the `x-request-id` response header. Quote it when you report a problem.

### 403 Forbidden Error

The key lacks the `sandboxes` scope, or the project is locked and the request sent `build_on`.

- `error` (ErrorError, required)
- `request_id` (string, optional) — The same id as the `x-request-id` response header. Quote it when you report a problem.

### 404 Not Found Error

The `build_context_id` does not exist in this project, or it has expired. Upload it again.

- `error` (ErrorError, required)
- `request_id` (string, optional) — The same id as the `x-request-id` response header. Quote it when you report a problem.

### 409 Conflict Error

The `Idempotency-Key` cannot be used for this request. With `idempotency_key_reused` it was already used with a different body or on a different route: use a new key for a new request. With `idempotency_request_in_progress` the first request with this key is still running: retry after a short wait.

- `error` (ErrorError, required)
- `request_id` (string, optional) — The same id as the `x-request-id` response header. Quote it when you report a problem.

### 413 Content Too Large Error

The request body is larger than this route allows: 1 MiB for JSON bodies, 16 MiB on the model routes, 100 MiB for a file upload, and 100 MB for a build context.

- `error` (ErrorError, required)
- `request_id` (string, optional) — The same id as the `x-request-id` response header. Quote it when you report a problem.

### 422 Unprocessable Entity Error

The account has no usable provider key for a vendor named in `build_on`. Store one first.

- `error` (ErrorError, required)
- `request_id` (string, optional) — The same id as the `x-request-id` response header. Quote it when you report a problem.

### 429 Too Many Requests Error

More than 20 failed authentications came from your address in one minute, and this request also failed to authenticate: fix the key, wait for `retry-after` seconds, then retry. Or the server instance was full and no slot came free for the account within 3 seconds (`error.code` `account_in_flight_limit_exceeded`): wait for `retry-after` seconds, then retry.

- `error` (ErrorError, required)
- `request_id` (string, optional) — The same id as the `x-request-id` response header. Quote it when you report a problem.

### 500 Internal Server Error

Meadow failed. Retry with backoff, and tell us if it persists.

- `error` (ErrorError, required)
- `request_id` (string, optional) — The same id as the `x-request-id` response header. Quote it when you report a problem.

## Types

### ImageCreateRegistryAuth

Login for a private base image. Both fields are required when it is sent. Not supported on Daytona.

- `username` (string, optional) — The registry user name.
- `password` (string, optional) — The registry password or token. Never returned.

### ImageBuild

The build of one image on one provider.

- `provider` (enum, required) — The provider this build is for.
  - Allowed values: `daytona`, `modal`
- `status` (enum, required) — `building` until the provider finishes. `ready` means sandboxes can start from it on this provider. `failed` carries the reason in `error`.
  - Allowed values: `building`, `ready`, `failed`
- `provider_image_ref` (string, optional, nullable) — The provider's own id for the built image (a Daytona snapshot or a Modal image). Null until the provider assigns one.
- `error` (string, optional, nullable) — Why the build failed. Null otherwise.
- `started_at` (datetime, optional) — When the build started.
- `finished_at` (datetime, optional, nullable) — When the build became `ready` or `failed`. Null while building.

### ErrorError

- `type` (enum, required) — The class of the failure. - `invalid_request`: the request is malformed or breaks a rule (400), or is too large (413). - `conflict`: the request is valid and the current state refuses it (409). Before 2026-11-24 a 409 used `invalid_request`. - `unauthorized`: the key is missing, unknown, revoked, or expired (401). - `forbidden`: the key's scope or limit does not allow this, or the project's routing is locked (403). - `not_found`: no such resource or route (404). - `no_provider_key`: no stored credential can serve this request (422). - `all_providers_failed`: every vendor in the route was tried (502). - `provider_error`: a vendor failed and no fallback was possible (502). - `rate_limited`: too many requests (429). - `insufficient_quota`: a dollar `limit` on the key, or on a key above it, is spent (402). The name is OpenAI's. - `unavailable`: a dependency Meadow needs is not set up (503). - `internal`: Meadow failed (500), or the feature is not set up (501).
  - Allowed values: `invalid_request`, `unauthorized`, `forbidden`, `not_found`, `conflict`, `no_provider_key`, `all_providers_failed`, `provider_error`, `rate_limited`, `insufficient_quota`, `unavailable`, `internal`
- `message` (string, required) — A sentence for people. It can change, so do not match on it.
- `code` (string, optional) — A stable name for the specific failure. Every Meadow error carries one. `type` stays the general class, and several codes share a type. Branch on `code` when you need to tell two failures of one type apart, for example `api_key_expired` from `api_key_revoked`. The full list is in the Errors guide. A new code can be added at any time, so treat a code you do not know as its `type`. A spent limit (`key_request_limit_exceeded`, `key_token_limit_exceeded`) stays a 403 and not a 429, so a client that retries a 429 does not resend a call a spent key can never make. A spent dollar `limit` (`key_spend_limit_exceeded`) is a 402 for the same reason.
- `param` (string, optional) — The request field, query parameter or header the error is about, when there is one. A nested field is written with dots, such as `credentials.api_key`. Set on most validation errors (400).
- `attempts` (list of Attempt, optional) — The vendors Meadow tried for this request, in order. Present only when it tried at least one.
- `retry` (enum, optional) — Whether to send the same request again. Set on routes under `/v1/sandboxes` only. The values are BoxRouter's (https://boxrouter.ai/docs/error-codes). - `safe`: send the same request again, after `retry-after` seconds when the response has that header. A 429, a 409 `exec_start_in_progress` or `idempotency_request_in_progress`, a 502 `sandbox_unreachable`, and a 5xx on a `GET`, `PUT` or `DELETE`, on `POST /v1/sandboxes/route`, or on a sandbox create or background command start sent with `Idempotency-Key`. - `after_fix`: change the request, the key or the account first. Any other 4xx. - `check_outcome`: read the sandbox or the command before you send it again, because the work may have happened. A 5xx on any other `POST`, which includes a blocking command. - `never`: do not send it again. A 501. When the response has `x-should-retry`, `retry` is `safe` exactly when the header is `true`.
  - Allowed values: `safe`, `after_fix`, `check_outcome`, `never`
- `outcome` (enum, optional) — What happened to the work. Set on routes under `/v1/sandboxes` only. The values are BoxRouter's (https://boxrouter.ai/docs/error-codes). - `not_started`: nothing was changed. Every 4xx, a 501, and a 502 `sandbox_unreachable`. - `unknown`: the work may have happened. Any other 5xx. - `completed` and `partial`: the work happened, in whole or in part. Meadow does not send them today. Handle them as `unknown`. A sandbox create that fails after Meadow accepted it is not an error response: the create returns 202, and the sandbox later has `status` `failed` and a `failure_reason`.
  - Allowed values: `not_started`, `completed`, `partial`, `unknown`

### Attempt

One try at one vendor, for a model call or a sandbox create.

- `provider` (enum, required) — The name of a vendor. Model providers and sandbox providers share one list. Model providers: `anthropic`, `openai`, `google`, `xai`, `azure`, `bedrock`, `vertex`, `openrouter`, `fireworks`, `deepseek`. Sandbox providers: `daytona`, `modal`.
  - Allowed values: `anthropic`, `openai`, `google`, `xai`, `azure`, `bedrock`, `vertex`, `openrouter`, `fireworks`, `deepseek`, `daytona`, `modal`
- `outcome` (enum, required) — How the try ended. - `served`: this vendor served the request. - `unsupported`: the vendor cannot do what was asked, such as a resource size, a network rule, or a model it does not offer. - `refused`: the vendor rejected the request or the stored credential. - `no_capacity`: the vendor had no capacity. - `timeout`: the vendor did not answer in time. - `rate_limited`: the vendor answered 429. - `error`: any other failure.
  - Allowed values: `served`, `unsupported`, `refused`, `no_capacity`, `timeout`, `rate_limited`, `error`
- `reason` (enum, optional) — A stable code for why the try ended as it did. It is narrower than `outcome`, and it is the code to branch on or to count. More values can be added: treat one you do not know like `vendor_error`. - `served`: this vendor served the request. - `no_capacity`: the vendor had no capacity. - `quota_exceeded`: the vendor account is out of quota or credit. - `rate_limited`: the vendor answered 429. - `timeout`: the vendor did not answer in time. - `auth_failed`: the vendor rejected the stored vendor key. - `invalid_request`: the vendor rejected the request itself. - `refused`: the vendor refused for another reason. - `unsupported`: the vendor cannot do what was asked, such as a model, a GPU type, a size or a network rule. - `no_provider_key`: skipped, because no usable vendor key was stored. - `image_pull_failed`, `build_failed`: the vendor could not pull or build the image (sandboxes). - `provider_lost`: the vendor lost the sandbox while it was starting. - `vendor_error`: any other failure.
  - Allowed values: `served`, `no_capacity`, `quota_exceeded`, `rate_limited`, `timeout`, `auth_failed`, `invalid_request`, `refused`, `unsupported`, `no_provider_key`, `image_pull_failed`, `build_failed`, `provider_lost`, `vendor_error`
- `started_at` (datetime, optional) — When Meadow started this try. Absent on attempts recorded before 2026-11-24.
- `finished_at` (datetime, optional) — When this try ended.
- `detail` (string, optional) — A short description of what happened, written by Meadow, such as `provider returned HTTP 404`. On a `served` sandbox attempt it reports resources the vendor granted that differ from the request, such as `provider granted cpu 2 instead of 1.5` or `gpu type H200 instead of H100`. It says `provider built a copy of the image for this size` when this create made a new Daytona snapshot for an `image_id`. On an `unsupported` attempt it carries the vendor's size limit, such as `daytona cannot serve this size: CPU request 8 exceeds maximum allowed per sandbox (4)`. Absent when there is nothing to say.
- `duration_ms` (integer, optional) — How long the try took, in milliseconds.

## Examples

### The same request sent again after both builds finished. The status field was added by hand and not captured live.

**Response**

```json
{
  "id": "img_0000a8c8",
  "builds": [
    {
      "provider": "daytona",
      "status": "ready",
      "provider_image_ref": "00000000-48ab",
      "error": null,
      "started_at": "2026-11-23T22:19:59.098Z",
      "finished_at": "2026-11-23T22:20:29.942Z"
    },
    {
      "provider": "modal",
      "status": "ready",
      "provider_image_ref": "im-000000EB0D",
      "error": null,
      "started_at": "2026-11-23T22:19:59.098Z",
      "finished_at": "2026-11-23T22:20:24.952Z"
    }
  ],
  "created_at": "2026-11-23T22:19:59.098Z",
  "status": "active",
  "name": "tools-example",
  "sha256": "00000000000000000000000000000000000000000000000000000000000045f7"
}
```

**SDK Code**

```python The same request sent again after both builds finished. The status field was added by hand and not captured live.
import requests

url = "https://api.example.com/v1/images"

querystring = {"wait":"true","wait_timeout_seconds":"600"}

headers = {
    "Idempotency-Key": "00000000-0000-0000-0000-000000007779",
    "Authorization": "Bearer <token>"
}

response = requests.post(url, headers=headers, params=querystring)

print(response.json())
```

```javascript The same request sent again after both builds finished. The status field was added by hand and not captured live.
const url = 'https://api.example.com/v1/images?wait=true&wait_timeout_seconds=600';
const options = {
  method: 'POST',
  headers: {
    'Idempotency-Key': '00000000-0000-0000-0000-000000007779',
    Authorization: 'Bearer <token>'
  }
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go The same request sent again after both builds finished. The status field was added by hand and not captured live.
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.example.com/v1/images?wait=true&wait_timeout_seconds=600"

	req, _ := http.NewRequest("POST", url, nil)

	req.Header.Add("Idempotency-Key", "00000000-0000-0000-0000-000000007779")
	req.Header.Add("Authorization", "Bearer <token>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby The same request sent again after both builds finished. The status field was added by hand and not captured live.
require 'uri'
require 'net/http'

url = URI("https://api.example.com/v1/images?wait=true&wait_timeout_seconds=600")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Idempotency-Key"] = '00000000-0000-0000-0000-000000007779'
request["Authorization"] = 'Bearer <token>'

response = http.request(request)
puts response.read_body
```

```java The same request sent again after both builds finished. The status field was added by hand and not captured live.
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.example.com/v1/images?wait=true&wait_timeout_seconds=600")
  .header("Idempotency-Key", "00000000-0000-0000-0000-000000007779")
  .header("Authorization", "Bearer <token>")
  .asString();
```

```php The same request sent again after both builds finished. The status field was added by hand and not captured live.
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.example.com/v1/images?wait=true&wait_timeout_seconds=600', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Idempotency-Key' => '00000000-0000-0000-0000-000000007779',
  ],
]);

echo $response->getBody();
```

```csharp The same request sent again after both builds finished. The status field was added by hand and not captured live.
using RestSharp;

var client = new RestClient("https://api.example.com/v1/images?wait=true&wait_timeout_seconds=600");
var request = new RestRequest(Method.POST);
request.AddHeader("Idempotency-Key", "00000000-0000-0000-0000-000000007779");
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift The same request sent again after both builds finished. The status field was added by hand and not captured live.
import Foundation

let headers = [
  "Idempotency-Key": "00000000-0000-0000-0000-000000007779",
  "Authorization": "Bearer <token>"
]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.example.com/v1/images?wait=true&wait_timeout_seconds=600")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Two builds just started. The status field was added by hand and not captured live.

**Response**

```json
{
  "id": "img_0000a8c8",
  "builds": [
    {
      "provider": "daytona",
      "status": "building",
      "provider_image_ref": null,
      "error": null,
      "started_at": "2026-11-23T22:19:59.098Z",
      "finished_at": null
    },
    {
      "provider": "modal",
      "status": "building",
      "provider_image_ref": null,
      "error": null,
      "started_at": "2026-11-23T22:19:59.098Z",
      "finished_at": null
    }
  ],
  "created_at": "2026-11-23T22:19:59.098Z",
  "status": "active",
  "name": "tools-example",
  "sha256": "00000000000000000000000000000000000000000000000000000000000045f7"
}
```

**SDK Code**

```python Two builds just started. The status field was added by hand and not captured live.
import requests

url = "https://api.example.com/v1/images"

querystring = {"wait":"true","wait_timeout_seconds":"600"}

headers = {
    "Idempotency-Key": "00000000-0000-0000-0000-000000007779",
    "Authorization": "Bearer <token>"
}

response = requests.post(url, headers=headers, params=querystring)

print(response.json())
```

```javascript Two builds just started. The status field was added by hand and not captured live.
const url = 'https://api.example.com/v1/images?wait=true&wait_timeout_seconds=600';
const options = {
  method: 'POST',
  headers: {
    'Idempotency-Key': '00000000-0000-0000-0000-000000007779',
    Authorization: 'Bearer <token>'
  }
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Two builds just started. The status field was added by hand and not captured live.
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.example.com/v1/images?wait=true&wait_timeout_seconds=600"

	req, _ := http.NewRequest("POST", url, nil)

	req.Header.Add("Idempotency-Key", "00000000-0000-0000-0000-000000007779")
	req.Header.Add("Authorization", "Bearer <token>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Two builds just started. The status field was added by hand and not captured live.
require 'uri'
require 'net/http'

url = URI("https://api.example.com/v1/images?wait=true&wait_timeout_seconds=600")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Idempotency-Key"] = '00000000-0000-0000-0000-000000007779'
request["Authorization"] = 'Bearer <token>'

response = http.request(request)
puts response.read_body
```

```java Two builds just started. The status field was added by hand and not captured live.
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.example.com/v1/images?wait=true&wait_timeout_seconds=600")
  .header("Idempotency-Key", "00000000-0000-0000-0000-000000007779")
  .header("Authorization", "Bearer <token>")
  .asString();
```

```php Two builds just started. The status field was added by hand and not captured live.
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.example.com/v1/images?wait=true&wait_timeout_seconds=600', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Idempotency-Key' => '00000000-0000-0000-0000-000000007779',
  ],
]);

echo $response->getBody();
```

```csharp Two builds just started. The status field was added by hand and not captured live.
using RestSharp;

var client = new RestClient("https://api.example.com/v1/images?wait=true&wait_timeout_seconds=600");
var request = new RestRequest(Method.POST);
request.AddHeader("Idempotency-Key", "00000000-0000-0000-0000-000000007779");
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift Two builds just started. The status field was added by hand and not captured live.
import Foundation

let headers = [
  "Idempotency-Key": "00000000-0000-0000-0000-000000007779",
  "Authorization": "Bearer <token>"
]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.example.com/v1/images?wait=true&wait_timeout_seconds=600")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### A Dockerfile that copies a file from a build context

**Request**

```json
{
  "dockerfile": "FROM python:3.12-slim\nCOPY hello.txt /opt/hello.txt\nRUN pip install --no-cache-dir httpx==0.27.2\n",
  "name": "tools-example",
  "build_context_id": "ctx_0000f39e",
  "build_on": [
    "daytona",
    "modal"
  ]
}
```

**Response**

```json
{
  "id": "img_0000a8c8",
  "builds": [
    {
      "provider": "daytona",
      "status": "ready",
      "provider_image_ref": "00000000-48ab",
      "error": null,
      "started_at": "2026-11-23T22:19:59.098Z",
      "finished_at": "2026-11-23T22:20:29.942Z"
    },
    {
      "provider": "modal",
      "status": "ready",
      "provider_image_ref": "im-000000EB0D",
      "error": null,
      "started_at": "2026-11-23T22:19:59.098Z",
      "finished_at": "2026-11-23T22:20:24.952Z"
    }
  ],
  "created_at": "2026-11-23T22:19:59.098Z",
  "status": "active",
  "name": "tools-example",
  "sha256": "00000000000000000000000000000000000000000000000000000000000045f7"
}
```

**SDK Code**

```python A Dockerfile that copies a file from a build context
import requests

url = "https://api.example.com/v1/images"

querystring = {"wait":"true","wait_timeout_seconds":"600"}

payload = {
    "dockerfile": "FROM python:3.12-slim
COPY hello.txt /opt/hello.txt
RUN pip install --no-cache-dir httpx==0.27.2
",
    "name": "tools-example",
    "build_context_id": "ctx_0000f39e",
    "build_on": ["daytona", "modal"]
}
headers = {
    "Idempotency-Key": "00000000-0000-0000-0000-000000007779",
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers, params=querystring)

print(response.json())
```

```javascript A Dockerfile that copies a file from a build context
const url = 'https://api.example.com/v1/images?wait=true&wait_timeout_seconds=600';
const options = {
  method: 'POST',
  headers: {
    'Idempotency-Key': '00000000-0000-0000-0000-000000007779',
    Authorization: 'Bearer <token>',
    'Content-Type': 'application/json'
  },
  body: '{"dockerfile":"FROM python:3.12-slim\nCOPY hello.txt /opt/hello.txt\nRUN pip install --no-cache-dir httpx==0.27.2\n","name":"tools-example","build_context_id":"ctx_0000f39e","build_on":["daytona","modal"]}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go A Dockerfile that copies a file from a build context
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.example.com/v1/images?wait=true&wait_timeout_seconds=600"

	payload := strings.NewReader("{\n  \"dockerfile\": \"FROM python:3.12-slim\\nCOPY hello.txt /opt/hello.txt\\nRUN pip install --no-cache-dir httpx==0.27.2\\n\",\n  \"name\": \"tools-example\",\n  \"build_context_id\": \"ctx_0000f39e\",\n  \"build_on\": [\n    \"daytona\",\n    \"modal\"\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Idempotency-Key", "00000000-0000-0000-0000-000000007779")
	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby A Dockerfile that copies a file from a build context
require 'uri'
require 'net/http'

url = URI("https://api.example.com/v1/images?wait=true&wait_timeout_seconds=600")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Idempotency-Key"] = '00000000-0000-0000-0000-000000007779'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"dockerfile\": \"FROM python:3.12-slim\\nCOPY hello.txt /opt/hello.txt\\nRUN pip install --no-cache-dir httpx==0.27.2\\n\",\n  \"name\": \"tools-example\",\n  \"build_context_id\": \"ctx_0000f39e\",\n  \"build_on\": [\n    \"daytona\",\n    \"modal\"\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```java A Dockerfile that copies a file from a build context
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.example.com/v1/images?wait=true&wait_timeout_seconds=600")
  .header("Idempotency-Key", "00000000-0000-0000-0000-000000007779")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"dockerfile\": \"FROM python:3.12-slim\\nCOPY hello.txt /opt/hello.txt\\nRUN pip install --no-cache-dir httpx==0.27.2\\n\",\n  \"name\": \"tools-example\",\n  \"build_context_id\": \"ctx_0000f39e\",\n  \"build_on\": [\n    \"daytona\",\n    \"modal\"\n  ]\n}")
  .asString();
```

```php A Dockerfile that copies a file from a build context
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.example.com/v1/images?wait=true&wait_timeout_seconds=600', [
  'body' => '{
  "dockerfile": "FROM python:3.12-slim\\nCOPY hello.txt /opt/hello.txt\\nRUN pip install --no-cache-dir httpx==0.27.2\\n",
  "name": "tools-example",
  "build_context_id": "ctx_0000f39e",
  "build_on": [
    "daytona",
    "modal"
  ]
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
    'Idempotency-Key' => '00000000-0000-0000-0000-000000007779',
  ],
]);

echo $response->getBody();
```

```csharp A Dockerfile that copies a file from a build context
using RestSharp;

var client = new RestClient("https://api.example.com/v1/images?wait=true&wait_timeout_seconds=600");
var request = new RestRequest(Method.POST);
request.AddHeader("Idempotency-Key", "00000000-0000-0000-0000-000000007779");
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"dockerfile\": \"FROM python:3.12-slim\\nCOPY hello.txt /opt/hello.txt\\nRUN pip install --no-cache-dir httpx==0.27.2\\n\",\n  \"name\": \"tools-example\",\n  \"build_context_id\": \"ctx_0000f39e\",\n  \"build_on\": [\n    \"daytona\",\n    \"modal\"\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift A Dockerfile that copies a file from a build context
import Foundation

let headers = [
  "Idempotency-Key": "00000000-0000-0000-0000-000000007779",
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "dockerfile": "FROM python:3.12-slim
COPY hello.txt /opt/hello.txt
RUN pip install --no-cache-dir httpx==0.27.2
",
  "name": "tools-example",
  "build_context_id": "ctx_0000f39e",
  "build_on": ["daytona", "modal"]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.example.com/v1/images?wait=true&wait_timeout_seconds=600")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```