> For the complete documentation index, see [llms.txt](https://dnotifier.gitbook.io/product-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dnotifier.gitbook.io/product-docs/workflows-and-agents/run-workflow.md). Agents can also search and read this documentation through its [MCP server](https://dnotifier.gitbook.io/product-docs/~gitbook/mcp).

# Run a workflow

Execute a registered workflow with **`runWorkflow`** after **`connect()`** on an HTTP-configured `DNotifier` instance.

## Method

```
runWorkflow({
  workflow: Workflow,
  input: *,
  senderId?: string,   // defaults to notifier.userId
  sessionId?: string,  // continue workflow state / memory
  mode?: "run" | "resume" | "retry" | "replay",
  fromCheckpointId?: string,
})
```

## Return value

| Field          | Description                                                   |
| -------------- | ------------------------------------------------------------- |
| `result`       | Return value of the workflow `entry` function                 |
| `state`        | Final `ctx.state` object after execution                      |
| `executionId`  | Present when `observability: true` — dashboard correlation id |
| `sessionId`    | Present when a session was passed or minted                   |
| `checkpointId` | Latest checkpoint when session/checkpointing is on            |

→ [Checkpoints, sessions & resume](https://dnotifier.gitbook.io/product-docs/workflows-and-agents/checkpoints.md)

## Minimal run

```js
await notifier.connect();

const run = await notifier.runWorkflow({
  workflow: myWorkflow,
  input: "How does messaging work?",
});

console.log(run.result);
console.log(run.executionId);
```

{% hint style="info" %}
Use **`transport: "http"`**. The runner uses the authenticated notifier for all `ctx.sendAI` and `ctx.search` calls inside the workflow.
{% endhint %}

## Input types

`input` can be any JSON-serializable value:

| Type     | Example use                                |
| -------- | ------------------------------------------ |
| `string` | User question for intent router            |
| `object` | Blog brief `{ topic, keywords, audience }` |
| `array`  | Batch items (process in `entry`)           |

## Error handling

Uncaught errors in `entry` or agent `run` propagate from `runWorkflow`. Use try/catch at the call site:

```js
try {
  const run = await notifier.runWorkflow({ workflow, input });
} catch (err) {
  if (err.name === "WorkflowError") {
    console.error("Workflow validation:", err.message);
  }
  throw err;
}
```

## Language guides

| Language                | Guide                                                                                                                            |
| ----------------------- | -------------------------------------------------------------------------------------------------------------------------------- |
| JavaScript / TypeScript | [javascript-typescript.md](https://dnotifier.gitbook.io/product-docs/workflows-and-agents/run-workflow/javascript-typescript.md) |
| Dart / Flutter          | [dart-flutter.md](https://dnotifier.gitbook.io/product-docs/workflows-and-agents/run-workflow/dart-flutter.md)                   |

## Next steps

* [**Workflow observability**](https://dnotifier.gitbook.io/product-docs/workflows-and-agents/observability.md)
* [**Example: Intent router**](https://dnotifier.gitbook.io/product-docs/workflows-and-agents/example-intent-router.md)
