---
title: DispatchOutput
description: The output of a `dispatch` Effect.
---

# `DispatchOutput`

Type, in `@jr2/orchestrator/src/effect.ts`. It is an export of `@jr2/orchestrator`, on the [Authoring surface](../authoring-surface.md) page, in Effects.

```ts
type DispatchOutput =
  | { outcome: "started"; run: string }
  | {
      outcome: "settled";
      run: string;
      status: "done" | "failed" | "error" | "cancelled" | "lost" | "drifted" | "live";
      output?: unknown;
    }
  | { outcome: "refused"; status: number; report: string[] }
  | { outcome: "unreachable"; reason: string }
  | Unknown;
```

The output of a `dispatch` Effect. Route on `outcome`:

- `started`: the Orchestrator accepted the new run. `run` is its id.
- `settled`: with `wait`, the new run ended. `status` is `done`, `failed`, `error`, `cancelled`,
  `lost` or `drifted`, and `output` is the output of its Machine. For `failed`, `output` is the
  Failure, `{ reason, detail? }`. `status` is `live` when the timeout came first, and the run
  continues.
- `refused`: the Orchestrator started no run. `status` is the HTTP status: 400 for an input that
  the Workflow does not take, 404 for a Workflow that it does not have, 409 for a named Chart that
  cannot run now, 422 for a Chart that it refuses. `report` holds the lines of the refusal.
- `unreachable`: the Orchestrator of the target did not answer. No run started.
- `unknown`: jr2 cannot tell if a run started.

**Forms**: it is one of these objects.

- Form 1: `outcome`, `reason`

  - `outcome`: `"unknown"`
  - `reason`: `string`
- Form 2: `outcome`, `run`

  - `outcome`: `"started"`
  - `run`: `string`
- Form 3: `outcome`, `run`, `status`, `output`

  - `outcome`: `"settled"`
  - `run`: `string`
  - `status`: `"done" | "failed" | "error" | "cancelled" | "lost" | "drifted" | "live"`
  - `output` (optional): `unknown`
- Form 4: `outcome`, `status`, `report`

  - `outcome`: `"refused"`
  - `status`: `number`
  - `report`: `string[]`
- Form 5: `outcome`, `reason`

  - `outcome`: `"unreachable"`
  - `reason`: `string`

**See also**

- [Effects](../../concepts/effects.md)
