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

# Workflow Import & Export

> Share workflows as portable JSON files and restore previous versions.

Workflows can be exported as self-contained JSON files and imported on any MIRA installation. Exports capture all steps, routing rules, and metadata — no credentials or session data are included.

## Exporting a workflow

<Steps>
  <Step title="Open Workflows">Press ⌘3 to open the Workflows view.</Step>
  <Step title="Select the workflow">Click the workflow card, then click **⋮ → Export**.</Step>
  <Step title="Save the file">Choose a location and save as `[workflow-name].json`.</Step>
</Steps>

## Importing a workflow

<Steps>
  <Step title="Open Workflows">Press ⌘3.</Step>
  <Step title="Click Import">Click the **Import** button at the top of the workflow list.</Step>

  <Step title="Select the JSON file">
    Pick the `.json` file. The workflow appears in your list immediately and is ready to run.
  </Step>
</Steps>

## Workflow JSON format

The exported JSON mirrors the internal workflow schema exactly. All fields are required unless marked optional.

```json theme={null}
{
  "name": "My Custom Pipeline",
  "description": "What this workflow does — shown in the workflow card.",
  "trigger": "manual",
  "isEnabled": true,
  "skillId": null,
  "tags": [],
  "steps": [
    {
      "stepOrder": 0,
      "name": "Clarify Scope",
      "description": "Restate the user request clearly before proceeding.",
      "stepType": "prompt",
      "conditionExpr": "",
      "promptTemplate": "Restate the following request in precise, unambiguous terms:\n\n{{input}}",
      "outputFormat": "markdown",
      "onSuccess": "continue",
      "onFailure": "retry:2"
    },
    {
      "stepOrder": 1,
      "name": "Human Review",
      "description": "Pause for the user to review and approve before continuing.",
      "stepType": "human_review",
      "conditionExpr": "",
      "promptTemplate": "",
      "outputFormat": "text",
      "onSuccess": "continue",
      "onFailure": "abort"
    },
    {
      "stepOrder": 2,
      "name": "Format Output",
      "description": "Transform the previous step's output into a final Markdown report.",
      "stepType": "transform",
      "conditionExpr": "",
      "promptTemplate": "Format the following as a structured Markdown report:\n\n{{prev_output}}",
      "outputFormat": "markdown",
      "onSuccess": "continue",
      "onFailure": "skip"
    }
  ]
}
```

### Workflow root fields

| Field         | Type           | Required | Notes                                                                      |
| ------------- | -------------- | -------- | -------------------------------------------------------------------------- |
| `name`        | string         | ✅        | Displayed on the workflow card                                             |
| `description` | string         | ✅        | One-line summary                                                           |
| `trigger`     | string         | ✅        | `"manual"` (user starts it) or `"auto"` (starts with session)              |
| `isEnabled`   | boolean        | ✅        | `true` to make the workflow selectable                                     |
| `skillId`     | string \| null | ✅        | ID of a skill to activate automatically when this workflow runs, or `null` |
| `tags`        | string\[]      | ✅        | User-defined labels for filtering. Use `[]` for none.                      |
| `steps`       | Step\[]        | ✅        | Ordered array of steps — executed top to bottom by `stepOrder`             |

### Step fields

| Field            | Type   | Required | Notes                                                                                          |
| ---------------- | ------ | -------- | ---------------------------------------------------------------------------------------------- |
| `stepOrder`      | number | ✅        | Zero-based execution order. Must be sequential: 0, 1, 2, …                                     |
| `name`           | string | ✅        | Short label shown in the workflow progress bar                                                 |
| `description`    | string | ✅        | Longer explanation of what this step does                                                      |
| `stepType`       | string | ✅        | See valid values below                                                                         |
| `conditionExpr`  | string | ✅        | Natural-language condition for `condition` steps. Leave `""` for other types.                  |
| `promptTemplate` | string | ✅        | The prompt sent to the LLM. Use template variables (see below). Leave `""` for `human_review`. |
| `outputFormat`   | string | ✅        | See valid values below                                                                         |
| `onSuccess`      | string | ✅        | What to do when the step succeeds                                                              |
| `onFailure`      | string | ✅        | What to do when the step fails                                                                 |

**`stepType` valid values:**

* `"prompt"` — send `promptTemplate` to the LLM and collect output
* `"transform"` — reshape or reformat the previous step's output
* `"condition"` — evaluate `conditionExpr`; routes based on result
* `"human_review"` — pause execution and wait for the user to approve before continuing

**`outputFormat` valid values:** `"text"` · `"markdown"` · `"json"` · `"code"` · `"table"`

**`onSuccess` valid values:** `"continue"` · `"pause"`

**`onFailure` valid values:** `"retry:1"` · `"retry:2"` · `"retry:3"` · `"skip"` · `"abort"`

### Template variables

| Variable          | Resolves to                                         |
| ----------------- | --------------------------------------------------- |
| `{{input}}`       | The original user message that started the workflow |
| `{{prev_output}}` | The full output of the immediately preceding step   |
| `{{document}}`    | The content of any document attached to the session |

## Version history

MIRA saves a new version each time you save a workflow. To access version history:

1. Open the workflow editor.
2. Click **⋮ → Version History**.
3. Browse versions by timestamp.
4. Click **Restore** to roll back — this creates a new version entry rather than overwriting the history.

## Distributing workflows to your team

1. Export the workflow JSON.
2. Commit the file to your team's shared repository.
3. Each team member imports the file into their MIRA installation.

Because workflows reference only template variables (not local paths or credentials), the same JSON runs identically on any machine.

<Note>
  Edit this page — [Open a pull
  request](https://github.com/satyendra2013/mira-app/edit/main/docs/features/workflows/import-export.mdx)
</Note>
