# Run platform

URL: https://docs.hanzo.ai/docs/openapi/platform/post-platform-run

> Runs a container image and gives back a URL.

`POST /v1/platform/run`

> [Platform →](https://docs.hanzo.ai/docs/openapi/platform) · [All API references →](https://docs.hanzo.ai/docs/openapi) · [Get started →](https://docs.hanzo.ai/docs/guides)

|               |                                        |
| ------------- | -------------------------------------- |
| **Address**   | `https://api.hanzo.ai/v1/platform/run` |
| **Method**    | `POST`                                 |
| **Operation** | `post_platform_run`                    |
| **Auth**      | `Authorization: Bearer $HANZO_API_KEY` |

Runs a container image and gives back a URL.

The one-call shortcut over project → app → deploy: give it a `name` and an
`image` and it creates or updates an image-source application in your org's
DEFAULT project, deploys it through the same operator Service-CR writer
everything else uses, and answers its id, name, live URL, status and shape.
Re-running the same name UPDATES it in place, so the call is idempotent by name.

What it produces is a first-class application, not a special object: it is
listable, stoppable and redeployable through the /v1/platform routes like any
other app.

`minScale` is the replica floor. `maxScale` above it declares an autoscaling
ceiling; `maxScale: 0` means no autoscaler at all — a fixed run at the floor.
Both are clamped to the deployment's limits. `runtime` and `shape` are accepted
for the client contract and echoed back: the image is the runtime unit and sizing
is the operator's default.

It is BILLING-GATED before it touches the cluster: a flat per-run fee is
authorized against the org's own prepaid balance first, so an org that cannot pay
is refused without anything being created. An unreachable cluster is 503 — a run
never reports a URL it did not create. Secret env is sealed into KMS and fails
closed without it.

Requires a validated principal; 401 without one. The org is resolved from that
validated identity and is what both pays and owns the namespace — it is never
read from the body.

## Request

12 fields, body `application/json` (required).

| Field          | In   | Type                   | Required | Description                                                                                                                                                              |
| -------------- | ---- | ---------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `env`          | body | platform.EnvVarJSON\[] | —        | Env is the run's environment.                                                                                                                                            |
| `env[].key`    | body | string                 | —        | Key is the variable's name in the container, which must match `^[A-Za-z_][A-Za-z0-9_]*$`.                                                                                |
| `env[].secret` | body | boolean                | —        | Secret says the value lives in KMS and never in the database.                                                                                                            |
| `env[].value`  | body | string                 | —        | Value is the plaintext, and it is WRITE-ONLY once the entry is secret: a sealed value reads back as "", and sending "" again KEEPS what is sealed rather than wiping it. |
| `gpu`          | body | integer (int64)        | —        | GPU is how many GPUs the run asks for; a negative value is 400.                                                                                                          |
| `image`        | body | string                 | —        | Image is the container image to run.                                                                                                                                     |
| `maxScale`     | body | integer (int64)        | —        | MaxScale above the floor declares an autoscaling ceiling; 0 means no autoscaler at all — a fixed run at the floor.                                                       |
| `minScale`     | body | integer (int64)        | —        | MinScale is the replica floor, clamped to the deployment's limit.                                                                                                        |
| `name`         | body | string                 | —        | Name is the run's name, and the slug is derived from it.                                                                                                                 |
| `port`         | body | integer (int64)        | —        | Port is the container port the run listens on.                                                                                                                           |
| `runtime`      | body | string                 | —        | Runtime is accepted for the client contract and echoed nowhere: the image IS the runtime unit.                                                                           |
| `shape`        | body | string                 | —        | Shape is a compute size label, echoed back; sizing is the operator's default.                                                                                            |

## Response

| Status    | Body             | Meaning  |
| --------- | ---------------- | -------- |
| `202`     | platform.runView | accepted |
| `default` | problem-details  | refused  |

`202` body — 5 fields.

| Field    | In   | Type   | Always | Description                                                        |
| -------- | ---- | ------ | ------ | ------------------------------------------------------------------ |
| `id`     | body | string | —      | ID is the application id the run created or converged.             |
| `name`   | body | string | —      | Name is the run's name, as stored.                                 |
| `shape`  | body | string | —      | Shape is the compute size label the request asked for, or "auto".  |
| `status` | body | string | —      | Status is the application's state — `deploying` on a fresh accept. |
| `url`    | body | string | —      | URL is the run's live HTTPS address.                               |

Failure carries the platform error shape — see [Errors](https://docs.hanzo.ai/docs/errors).

## Examples

**CLI**

```bash
hanzo platform run
```

**SDK**

**.ts**

```ts
import { Configuration, PlatformApi } from 'hanzoai';

const api = new PlatformApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.postPlatformRun({ env: [{"key":"<key>","secret":false,"value":"<value>"}], gpu: 0 });
```

**.py**

```python
from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import PlatformApi

client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = PlatformApi(client).post_platform_run(env=[{"key":"<key>","secret":false,"value":"<value>"}], gpu=0)
```

**.go**

```go
cfg := hanzoai.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := hanzoai.NewAPIClient(cfg)

resp, _, err := client.PlatformAPI.PostPlatformRun(context.Background()).Execute()
if err != nil {
	return err
}
```

**.rs**

```rust
use hanzo_client::apis::{configuration::Configuration, platform_api};

let mut cfg = Configuration::new();
cfg.bearer_access_token = std::env::var("HANZO_API_KEY").ok();

let result = platform_api::post_platform_run(&cfg, Default::default()).await?;
```

**.java**

```java
import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.PlatformApi;

ApiClient client = new ApiClient();
client.setBearerToken(System.getenv("HANZO_API_KEY"));

var result = new PlatformApi(client).postPlatformRun();
```

**HTTP**

```bash
curl -X POST https://api.hanzo.ai/v1/platform/run \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "env": [
         {
           "key": "<key>",
           "secret": false,
           "value": "<value>"
         }
       ],
       "gpu": 0
     }'
```

**MCP**

MCP reaches **platform** through the `platform` tool, which names its 38 operations with its own verbs — this one among them, under a name only MCP declares. `describe` explains any of them:

```bash
curl -X POST https://api.hanzo.ai/v1/mcp \
  -H "Content-Type: application/json" \
  -d '{
       "jsonrpc": "2.0",
       "id": 1,
       "method": "tools/call",
       "params": {
         "name": "describe",
         "arguments": {
           "op": "get_build"
         }
       }
     }'
```

---

[Platform API](https://docs.hanzo.ai/docs/openapi/platform) · [All Hanzo APIs](https://docs.hanzo.ai/docs/openapi) · [Interactive reference](https://docs.hanzo.ai/docs/openapi/reference)
