> ## Documentation Index
> Fetch the complete documentation index at: https://docs.run.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# Availability Zones

> See run.cloud's availability zones and pin a simulator session to one, so an Xcode build installs over the local network.

An **availability zone** is one local network of simulator hosts and Xcode builders.
Inside a zone, a builder can hand its `.app` straight to a simulator over the local
network instead of through durable storage, so installs are much faster.

Zone ids are `<site>-<letter>`, such as `sto-hq-a`. An id always refers to the same network.

## List zones

```bash Bash theme={null}
runcloud zones --json
```

```typescript TypeScript theme={null}
import { Client } from "@run-cloud/sdk";

const cloud = new Client();
console.log(await cloud.zones.list());
```

```json theme={null}
[
  {
    "id": "sto-hq-a",
    "site": "sto-hq",
    "capacity": { "ios": { "hosts": 33 }, "android": { "hosts": 0 } },
    "capabilities": {
      "iosSimulator": true,
      "androidEmulator": false,
      "xcodeBuild": true,
      "lanStagingCache": true,
      "lanInstall": true
    }
  }
]
```

`capacity` counts the hosts in the zone that your organization can use. It is not a
count of idle simulators. `lanInstall` is `true` only when the zone has an Xcode
builder with a local artifact cache and simulators that can receive from it. A zone
without both still runs sessions, but installs come from durable storage.

## Pick a zone for a session

Pass `zone` when you create a session.

| `zone` | Placement |
| - | - |
| omitted or `"any"` | Default. A session created for an Xcode build's Asset (`installAssets` or `placementAssetId`) prefers hosts that can receive that build over the LAN, when the build qualifies for LAN transfer. It is not a guarantee: the session can land anywhere with capacity. Pin a zone id when it must stay local. |
| a zone id | Strict. The session runs in that zone or the create fails. It never moves to another zone. |

```bash Bash theme={null}
runcloud ios create --zone sto-hq-a --install-asset <build-asset-id> --json
```

```typescript TypeScript theme={null}
const simulator = await cloud.ios.create({
  zone: "sto-hq-a",
  placementAssetId: build.artifact.assetId,
});
console.log(simulator.zone); // "sto-hq-a"
```

Every session reports the `zone` of the host it runs on. A host that is not in any
zone has no `zone` field.

### Errors for a pinned zone

| Status | `code` | Meaning |
| - | - | - |
| 400 | `invalid_zone` | `zone` is not a zone id or `"any"`. |
| 400 | `unknown_zone` | No zone with that id exists here. The message lists the zones that do. |
| 409 | `zone_conflict` | The Asset comes from an Xcode build in a different zone. Pin the build's zone or omit `zone`. |
| 409 | `zone_unavailable` | The zone has no hosts for this platform that your organization can use. |
| 503 | `zone_capacity_unavailable` | Every host in the zone is busy. Retry later (`retryable: true`), or omit `zone` to allow other zones. |

All of these are returned before or instead of placing a session in another zone.

## Pick a zone for an Xcode build

Pass `zone` to an Xcode build to run it only on that zone's builders. Builds
report the `zone` they are pinned to, or the zone of the builder that staged
their artifact.

```bash Bash theme={null}
runcloud xcode build . --scheme MyApp --zone sto-hq-a
```

```typescript TypeScript theme={null}
const build = await cloud.xcode.build(".", { scheme: "MyApp", zone: "sto-hq-a" });
console.log(build.zone); // "sto-hq-a"
```

| `zone` | Placement |
| - | - |
| omitted or `"any"` | Any available builder. |
| a zone id | Strict. Only that zone's builders. The build waits in the queue while they are busy, and fails if none of them is online. |

Pinning a build is the surest way to get local-network installs: simulators
created for its Asset are placed in the same zone, and pinning such a session to
a different zone fails with `zone_conflict`. A build pinned to an unknown zone
fails with `400 unknown_zone`, and to a zone without builders with
`409 zone_unavailable`.


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