# convoy run

> Validate the folder, send it to convoyd as a bundle, start a new run of the swarm, and exit. The swarm keeps running on the server.

```text
convoy run [--dir <path>] [--name <swarm>] [--server <url>]
```

`run` never waits for the swarm. Its last line is `watch with: convoy watch <name>`.

## What it does

1. Runs the same checks as [`convoy validate`](/docs/cli/validate/). Errors exit 3.
2. Builds the bundle: every `.cvy` file, every file named in a `file()` call, and the value of every `env()` argument read from your shell. A missing `env()` variable is an error before any network call. Provider API keys are not read or sent. convoyd reads them from its own environment.
3. Sends `PUT /v1/swarms/{name}` with the bundle as JSON. The name is the swarm block's label, or `--name` if given.
4. convoyd resolves each provider's type, fetching one it does not hold, and starts every [driver plugin](/docs/providers/) once in check mode before it creates the run. The run records the type version and digest each provider block resolved to.
5. Handles the response, below.

## Flags

| Flag | Meaning |
| --- | --- |
| `--name` | Override the swarm name taken from the `swarm` block |

## Responses

**201, accepted.** The server created a run. A new swarm name starts at run 1. If the swarm exists and its latest run has ended (Done, Stopped, or Failed), this is the next run number. Earlier runs are kept and stay readable with `--run`. For each provider whose type is not built in, `run` prints the version and digest the run uses, so you can see what will execute.

```console
$ convoy run
swarm "edge_chips" run 3 accepted: 7 agents pending
provider fast: acme/acme 1.4.2 sha256:9f2c3a71b0d4…

AGENT                    STATUS   PROVIDER   MODEL
critic                   pending  anthropic  claude-opus-5
overseer                 pending  anthropic  claude-sonnet-5
researcher[cerebras]     pending  anthropic  claude-sonnet-5
researcher[groq]         pending  anthropic  claude-sonnet-5
researcher[nvidia]       pending  anthropic  claude-sonnet-5
researcher[tenstorrent]  pending  anthropic  claude-sonnet-5
writer                   pending  openai     gpt-6.1-sol

watch with: convoy watch edge_chips
```

The count includes the [overseer](/docs/concepts/overseer/), which every run gets.

**409 `swarm_active`.** The latest run is still Pending or Running. Nothing changes. There is no flag to replace a running swarm. Stop it first.

```console
$ convoy run
swarm "edge_chips" is running (run 3, started 12:04:02). Wait for it to finish, or stop it with: convoy stop edge_chips
$ echo $?
1
```

**422, rejected.** The body carries diagnostics. Exit 3. Besides the errors `validate` reports, the server makes checks it alone can:

| Code | Meaning |
| --- | --- |
| `overseer_missing` | The swarm block has no `overseer` and convoyd has no `--overseer-provider` and `--overseer-model` |
| `missing_env` | A variable a provider reads, such as its `api_key`, is not set in convoyd's environment. The message names the variable, never a value |
| `provider_check_failed` | A [driver plugin](/docs/providers/) failed its check: its command did not exit 0 or did not report a runner contract convoyd speaks. The message carries the end of its output |
| `unpriced_model` | `max_cost_usd` is set and an agent model, or the overseer model, has no price |
| `bundle_version_unsupported` | The bundle format is newer than the server understands |

A provider type the server cannot resolve is [TS016](/docs/dsl/validation/#ts016) among the diagnostics. A fetch that takes longer than convoyd's `--provider-timeout` answers 504 `provider_timeout` and exit 1; the fetch continues, so running again shortly succeeds.

```console
$ convoy run
error[overseer_missing]: declare overseer = { provider, model } on the swarm block, or start convoyd with --overseer-provider and --overseer-model
$ echo $?
3
```

**400 `name_mismatch`.** The URL name and the swarm block's name differ. Exit 1.

## Exit codes

| Code | Cause |
| --- | --- |
| `0` | Run accepted |
| `1` | Server unreachable, `swarm_active`, or another server error |
| `2` | Usage error |
| `3` | Validation errors locally, a missing `env()` variable, or a 422 from the server |

## API endpoint

`PUT /v1/swarms/{name}`. See [The convoyd API](/docs/architecture/) for the server's side: the transaction that creates the run, agents, topics, and overseer row.

## Related

- [convoy watch](/docs/cli/watch/) to follow the run.
- [convoy stop](/docs/cli/stop/) to free a swarm name.
- [Swarms and runs](/docs/concepts/swarms/)
- [Budgets and limits](/docs/concepts/budgets/)
- [Provider types](/docs/providers/)
