# Workflow

URL: /business/nouns/workflow · Id: `noun:workflow`

> A Workflow is the durable, executable body of one Action: its steps, the Functions that run them, retries, and waits.

A Workflow is the durable, executable body of one [Action](/business/nouns/action): its steps, the [Functions](/business/nouns/function) that run them, retries, and waits. [Triggers](/business/nouns/trigger) start it, and a [Process](/business/nouns/process) groups it with others.

## Properties
| Property | Type | Required | Description |
| --- | --- | --- | --- |
| `steps` | `json` | Yes | The ordered steps, each run by a Function. |
| `retries` | `integer` | No | How many times a failed step retries. |
| `body` | `string` | No | The Verb whose Action it is the durable body of, such as `Order.refund`; a Workflow with a body has no Trigger. |

## Object
```json
{
  "$id": "https://api.sb/patentpad.com/workflows/workflow_1",
  "$type": "Workflow",
  "steps": {},
  "retries": 1,
  "body": "Example body"
}
```

## Relationships
- <a id="rel-executes"></a>A Workflow **executes** one [Action](/business/nouns/action): a Workflow is the durable body of one [Action](/business/nouns/action): its steps, retries and waits. `executes`, inverse [`executedBy`](/business/nouns/action#rel-executed-by).
- <a id="rel-started-by"></a>A Workflow **is started by** many [Triggers](/business/nouns/trigger): when a [Trigger](/business/nouns/trigger) fires, each Workflow it starts runs as a new [Action](/business/nouns/action). `startedBy`, inverse [`starts`](/business/nouns/trigger#rel-starts).
- <a id="rel-used-in"></a>A Workflow **is used in** one [Process](/business/nouns/process): a [Process](/business/nouns/process) does its work through Workflows, each the durable, executable part of the Process. `usedIn`, inverse [`uses`](/business/nouns/process#rel-uses).

## Verbs
| Verb | Description | Subject | Event | Class |
| --- | --- | --- | --- | --- |
| <a id="create"></a>[Workflow.create](/business/nouns/workflow/create) | Creates a Workflow. Inherited from [Noun](/business/nouns/noun). | None. | `Workflow.created` | Two-way: `try`, `send`, `do` |
| <a id="get"></a>[Workflow.get](/business/nouns/workflow/get) | Returns one Workflow by id. Inherited from [Noun](/business/nouns/noun). | None. | None. | Read: `try`, `do` |
| <a id="list"></a>[Workflow.list](/business/nouns/workflow/list) | Returns Workflows, newest first, one page at a time. Inherited from [Noun](/business/nouns/noun). | None. | None. | Read: `try`, `do` |
| <a id="update"></a>[Workflow.update](/business/nouns/workflow/update) | Changes the given properties of a Workflow. Inherited from [Noun](/business/nouns/noun). | None. | `Workflow.updated` | Two-way: `try`, `send`, `do` |
| <a id="delete"></a>[Workflow.delete](/business/nouns/workflow/delete) | Deletes a Workflow; its history is kept. Inherited from [Noun](/business/nouns/noun). | None. | `Workflow.deleted` | One-way: `send`, `do` |

## Permissions
Which Access level may call each Verb. One-way Verbs wait their delay window.

| Operation | `owner` | `admin` | `member` | `viewer` |
| --- | --- | --- | --- | --- |
| `Workflow.create` | Yes | Yes | Yes | No |
| `Workflow.get` | Yes | Yes | Yes | Yes |
| `Workflow.list` | Yes | Yes | Yes | Yes |
| `Workflow.update` | Yes | Yes | Yes | No |
| `Workflow.delete` | Yes | Yes | Yes | No |

## Call it

**Ask**

```text
Add a workflow to ShiftNote.
```

**API**

```bash
curl -X POST https://api.sb/shiftnote.app/workflows \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"steps":{}}'
```

```json
{
  "api": "https://api.sb/shiftnote.app",
  "workflow": {
    "$id": "https://api.sb/shiftnote.app/workflows/workflow_1",
    "$type": "Workflow",
    "steps": {}
  },
  "action": {
    "$id": "https://api.sb/shiftnote.app/actions/action_1",
    "operation": "Workflow.create",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/shiftnote.app/actions/action_1"
  }
}
```

**SDK**

```ts
import { $ } from 'startup-builder'

const workflow = await $.Workflow.create({ steps: {} })
```

**CLI**

```bash
npx startup-builder do Workflow.create --json '{"steps":{}}'
```

**MCP**

```json
{
  "name": "do",
  "arguments": {
    "code": "return await $.Workflow.create({ steps: {} })"
  }
}
```

## Example
At a translation marketplace, the Workflow behind `Order.fulfill` drafts the translation, then waits up to 48 hours for the translator’s certification. With `retries: 3`, a failed upload runs three more times before the Workflow stops.