# Workflows

Workflows (also known as Flows) trigger actions based on events and conditions. They power welcome series, abandoned cart recovery, re-engagement campaigns, and complex multi-branch journeys. Use the Workflows API to list workflows, fetch one workflow's structure, and read per-step stats. To change a workflow, [propose a change](#workflow-proposals) that a person accepts in the Flow Builder. The API never edits a workflow directly.

## Available Endpoints


## The Workflow Model


  
    The workflow model represents an automation flow with its associated email templates and performance statistics. Get Workflow also returns the flow structure.
  
  
    ### Properties

    
      - **id** (`string`): 
        The unique identifier for the workflow
      
      - **name** (`string`): 
        The name of the workflow
      
      - **status** (`string`): 
        `live`, `draft`, or `deleted`. Returned only by Get Workflow.
      
      - **created_at** (`datetime`): 
        When the workflow was created
      
      - **updated_at** (`datetime`): 
        When the workflow was last updated. Returned only by Get Workflow.
      
      - **diagram_revision** (`string`): 
        A 16-character hash of the saved workflow. Changes every time the workflow is saved. Pass it as `base_revision` when you create a proposal. Returned only by Get Workflow.
      
      - **email_templates** (`array`): 
        Array of email templates used in this workflow, each with id, subject, and stats
      
      - **triggers** (`array`): 
        Entry points for the workflow. Returned only by Get Workflow.
      
      - **nodes** (`array`): 
        Every step in the workflow. Returned only by Get Workflow.
      
    

  


---

## Get Workflows {{ tag: 'GET', label: '/v1/fetch/workflows' }}


  
    Returns a list of all workflows in your account, including their associated email templates and performance statistics.

    ### Query Parameters
    
      - **site_uuid** (`string`): 
        Your site's unique identifier
      
      - **page** (`integer`): 
        Page number for pagination (optional)
      
    

  
  
    
  


  
    ### Response
    Returns a list of workflows with their email templates and stats.

    
      - **data** (`array`): 
        Workflow records.
      
      - **data[].id** (`string`): 
        Workflow identifier.
      
      - **data[].name** (`string`): 
        Workflow name.
      
      - **data[].email_templates** (`array`): 
        Email templates used in the workflow.
      
    

  
  
    
  


---

## Get Workflow {{ tag: 'GET', label: '/v1/fetch/workflows/:id' }}


  
    Returns one workflow with its full structure. Use the workflow id from Get Workflows, such as `flow_abc123`.

    
> A workflow that is not in your site returns 404.

    
> Canvas annotations such as notes and boxes are not returned.


    ### Path Parameters
    
      - **id** (`string`): 
        The workflow id from Get Workflows
      
    

    ### Query Parameters
    
      - **site_uuid** (`string`): 
        Your site's unique identifier
      
    

  
  
    
  


  
    ### Response
    Returns one workflow with its triggers, nodes, and email templates.

    
      - **data.id** (`string`): 
        Workflow identifier.
      
      - **data.type** (`string`): 
        Resource type, typically `workflow`.
      
      - **data.attributes.name** (`string`): 
        Workflow name.
      
      - **data.attributes.status** (`string`): 
        `live`, `draft`, or `deleted`.
      
      - **data.attributes.created_at** (`datetime`): 
        When the workflow was created.
      
      - **data.attributes.updated_at** (`datetime`): 
        When the workflow was last updated.
      
      - **data.attributes.diagram_revision** (`string`): 
        Revision of the saved workflow. Changes on every save. Pass it as `proposal.base_revision`.
      
      - **data.attributes.email_templates** (`array`): 
        Email templates used in the workflow, each with id, subject, and stats.
      
      - **data.attributes.triggers** (`array`): 
        Entry points for the workflow.
      
      - **data.attributes.triggers[].id** (`string`): 
        Trigger identifier.
      
      - **data.attributes.triggers[].type** (`string`): 
        Trigger type, such as `simpleEventTrigger`.
      
      - **data.attributes.triggers[].name** (`string`): 
        Trigger name.
      
      - **data.attributes.triggers[].transitions** (`array`): 
        Next node ids. Linear steps use `{ "to": id }`.
      
      - **data.attributes.triggers[].config** (`object`): 
        Trigger settings. Webhook URLs, headers, payloads, and API keys are never returned.
      
      - **data.attributes.nodes** (`array`): 
        Every step in the workflow.
      
      - **data.attributes.nodes[].id** (`string`): 
        Node identifier. This is the Flow Builder's canvas id. Use it with Get Workflow Stats and in proposal patches.
      
      - **data.attributes.nodes[].type** (`string`): 
        Step type, such as `email_template`, `delay`, `true_falseV2`, `tag`, or `sequence`.
      
      - **data.attributes.nodes[].name** (`string`): 
        Step name.
      
      - **data.attributes.nodes[].transitions** (`array`): 
        Next node ids. Linear steps use `{ "to": id }`. Branch steps use `{ "true": id }` and `{ "false": id }`. Other split types use their branch labels as keys.
      
      - **data.attributes.nodes[].config** (`object`): 
        Step settings. Webhook URLs, headers, payloads, and API keys are never returned.
      
      - **data.attributes.nodes[].email_template** (`object`): 
        Present on email nodes. Includes `id` and `subject`. Fetch the body with the Email Templates API.
      
      - **data.attributes.nodes[].sequence** (`object`): 
        Present on sequence nodes. Includes `id` and `name`.
      
    

  
  
    
  


---

## Get Workflow Stats {{ tag: 'GET', label: '/v1/fetch/workflows/:id/stats' }}


  
    Returns per-step entry counts and email stats for one workflow.

    
> Call Get Workflow first to map node ids to step names and order. Then call Get Workflow Stats to read the funnel.

    
> Results are cached for about 10 minutes.

    
> Invalid dates return 422 with `{ "error": "Invalid date range" }`.


    ### Path Parameters
    
      - **id** (`string`): 
        The workflow id from Get Workflows
      
    

    ### Query Parameters
    
      - **site_uuid** (`string`): 
        Your site's unique identifier
      
      - **days** (`integer`): 
        Rolling window in days, ending now. Default 30. Max 366.
      
      - **start_date** (`string`): 
        Window start as `YYYY-MM-DD`. Must be sent with `end_date`. Takes precedence over `days`.
      
      - **end_date** (`string`): 
        Window end as `YYYY-MM-DD`. Must be sent with `start_date`. The range can be at most 366 days.
      
    

  
  
    
  


  
    ### Response
    Returns plain JSON, not JSON API. `nodes` is keyed by node id. Those ids match `nodes[].id` from Get Workflow.

    
      - **workflow_id** (`string`): 
        Workflow identifier.
      
      - **window.start** (`datetime`): 
        Start of the reporting window.
      
      - **window.end** (`datetime`): 
        End of the reporting window.
      
      - **totals.node_entries** (`integer`): 
        Sum of entries across all steps.
      
      - **nodes** (`object`): 
        Per-step stats keyed by node id.
      
      - **nodes.*.type** (`string`): 
        Step type, such as `email_template`, `delay`, or `sequence`.
      
      - **nodes.*.entered** (`integer`): 
        How many times subscribers reached that step in the window.
      
      - **nodes.*.email** (`object`): 
        Present on email nodes. Includes sent, opened, clicked, rates, unsubscribes, and unique events.
      
      - **nodes.*.email.template_id** (`integer`): 
        Email template id.
      
      - **nodes.*.email.sent** (`integer`): 
        Emails sent from this step.
      
      - **nodes.*.email.opened** (`integer`): 
        Emails opened from this step.
      
      - **nodes.*.email.clicked** (`integer`): 
        Emails clicked from this step.
      
      - **nodes.*.email.open_rate** (`number`): 
        Open rate as a percentage, two decimals.
      
      - **nodes.*.email.click_rate** (`number`): 
        Click rate as a percentage, two decimals.
      
      - **nodes.*.email.unsubscribes** (`integer`): 
        Unsubscribes attributed to that email.
      
      - **nodes.*.email.unique_events** (`integer`): 
        Conversions attributed to that email. This is the same number Email Viewer shows as Sales.
      
      - **nodes.*.sequence** (`object`): 
        Present on sequence nodes. Same counts, summed across the sequence's emails.
      
      - **nodes.*.sequence.sequence_id** (`integer`): 
        Sequence id.
      
      - **nodes.*.sequence.template_count** (`integer`): 
        Number of emails in the sequence.
      
      - **nodes.*.sequence.skipped** (`boolean`): 
        `true` when the sequence has more than 20 emails. In that case only `sequence_id` and `template_count` are returned.
      
    

  
  
    
  


---

## Workflow Proposals {{ id: 'workflow-proposals' }}

The API never edits a live workflow directly. Instead, you **propose** a change. A person reviews it in the Flow Builder and clicks **Accept** to apply it, or rejects it. This keeps a human in charge of what runs while letting scripts and AI agents do the drafting.

### How review works

1. Call [Get Workflow](#get-workflow) and note `diagram_revision` and the node ids. Node ids are the Flow Builder's canvas ids.
2. [Create a proposal](#create-proposal) with a summary and a patch. Bento validates the patch against the saved workflow and returns a `review_url`.
3. Open `review_url`, or open the workflow in the Flow Builder. Pending proposals show in a banner with a preview of the change. Editors that are already open pick up new proposals automatically.
4. Click **Accept** to apply the change and save the workflow, or **Reject** to discard it.


> Accept and reject happen in the Flow Builder only. There is no API to accept a proposal.


### Proposal status

- `pending` is waiting for review.
- `accepted` was applied by a person in the Flow Builder.
- `rejected` was dismissed by a person, or removed to make room (see below).
- `stale` means the workflow was saved after the proposal was made. The Flow Builder shows it as outdated. Fetch the workflow again and create a new proposal.

Proposals expire 7 days after they are created, whatever their status. Proposals made by Tanuki, Bento's AI assistant, show up in the same list with `source: "tanuki"`.

A workflow can have up to 20 pending proposals. When a new proposal would go over that, Bento first rejects the workflow's stale proposals to make room. If 20 are still pending, the request returns `422`.

---

## Create Proposal {{ tag: 'POST', label: '/v1/fetch/workflows/:id/proposals' }}


  
    Proposes a change to one workflow. Nothing changes until someone accepts it in the Flow Builder.

    ### Path Parameters
    
      - **id** (`string`): 
        The workflow id from Get Workflows.
      
    

    ### Request Body
    
      - **site_uuid** (`string`): 
        Your site UUID.
      
      - **proposal.summary** (`string`): 
        What the change does, for the reviewer. Up to 500 characters.
      
      - **proposal.patch** (`object`): 
        The change to make, in the [patch format](#the-patch-format) below.
      
      - **proposal.base_revision** (`string`): 
        The 16-character `diagram_revision` from Get Workflow. If the workflow has been saved since, Bento returns `409` instead of creating a proposal against a flow it didn't see. If omitted, the proposal is made against the current revision. Recommended.
      
    

    ### Errors
    
      - **404** (`error`): 
        The workflow is not in your site.
      
      - **409** (`error`): 
        `base_revision` is not the workflow's current revision. The body includes the current `revision`. Fetch the workflow again and rebuild the patch.
      
      - **422** (`error`): 
        The summary is missing or too long, the patch is invalid, or the workflow already has 20 pending proposals after stale ones were cleared.
      
    

    Errors return `{ "error": "…", "errors": [ … ] }`.
  
  
    
  


  
    ### Response
    Returns `201` with the proposal.

    
      - **data.id** (`string`): 
        Proposal id, such as `prop_` followed by 20 letters and numbers.
      
      - **data.attributes.workflow_id** (`string`): 
        Workflow the proposal is for.
      
      - **data.attributes.summary** (`string`): 
        The summary you sent.
      
      - **data.attributes.status** (`string`): 
        `pending`, `accepted`, `rejected`, or `stale`.
      
      - **data.attributes.source** (`string`): 
        `api` for proposals made with this endpoint, `tanuki` for proposals from Bento's AI assistant.
      
      - **data.attributes.created_by** (`object`): 
        Who made the proposal, as `type`, `id`, and `label`. The Flow Builder shows the label.
      
      - **data.attributes.base_revision** (`string`): 
        The revision the proposal was made against.
      
      - **data.attributes.created_at** (`datetime`): 
        When the proposal was created.
      
      - **data.attributes.expires_at** (`datetime`): 
        When the proposal expires, 7 days after creation.
      
      - **data.attributes.review_url** (`string`): 
        Opens the workflow in the Flow Builder with this proposal ready to review, as `/account/workflows/:id/edit?proposal=…`. Share it with whoever should approve the change.
      
      - **data.attributes.patch** (`object`): 
        The validated patch. Bento may correct small mistakes, so this can differ from what you sent.
      
      - **data.attributes.warnings** (`array`): 
        Notes from validation that did not block the proposal. Only returned by Create Proposal.
      
    
  
  
    
  


---

## Get Proposals {{ tag: 'GET', label: '/v1/fetch/workflows/:id/proposals' }}


  
    Lists a workflow's `pending` and `stale` proposals, oldest first. Accepted, rejected, and expired proposals are not returned.

    To fetch one proposal, call `GET /v1/fetch/workflows/:id/proposals/:proposal_id`. It returns any proposal in any status until it expires, 7 days after creation. Use it to check whether a person has accepted your change.

    ### Path Parameters
    
      - **id** (`string`): 
        The workflow id.
      
      - **proposal_id** (`string`): 
        A proposal id. Only for the single-proposal endpoint.
      
    

    ### Query Parameters
    
      - **site_uuid** (`string`): 
        Your site UUID.
      
    

    
> ⚠️ **Warning**
> An unknown or expired `proposal_id` returns `404`.

  
  
    
  


  
    ### Response
    Returns `data` as an array of proposals, each in the Create Proposal shape without `warnings`.
  
  
    
  


---

## The Patch Format {{ id: 'the-patch-format' }}


  
    A patch lists only what changes. Every key is optional, but a patch must contain at least one change. Node ids are the `nodes[].id` and `triggers[].id` values from Get Workflow. Keys can also be sent in camelCase, such as `addNodes`.

    ### Limits

    - Up to 64 KB of JSON.
    - Up to 200 changes across all keys.
    - Ids, ports, and other names up to 100 characters.

    
      - **add_nodes** (`array`): 
        New steps, as `{ "id", "type", "config", "insert_after", "insert_after_port", "insert_before" }`. `id` is a new unique id you choose, and must not already be on the canvas. `type` is a step type such as `email_template`, `delay`, or `tag`. Every new step except a trigger must connect to the flow with `insert_after` or `insert_before`. The first step in a new chain must point at an id already on the canvas. Later steps can point at earlier new ids.
      
      - **add_nodes[].insert_after_port** (`string`): 
        For split steps, which branch to attach to: `bottom_0` for the true branch, `bottom_1` for the false branch.
      
      - **update_nodes** (`array`): 
        Change existing steps in place, as `{ "id", "config" }`. Send only the config keys you are changing.
      
      - **remove_nodes** (`array`): 
        Ids of steps to remove. Bento reconnects the steps around them. Don't use a removed id in `insert_after`.
      
      - **move_nodes** (`array`): 
        Reorder steps, as `{ "id", "move_after" }` or `{ "id", "move_before" }`. Accepted, but the Flow Builder does not apply moves yet, so avoid it for now. Remove the step and add it again instead.
      
      - **add_links** (`array`): 
        New connections, as `{ "from", "to", "fromPort" }`. `fromPort` is only needed for split steps.
      
      - **remove_links** (`array`): 
        Connections to remove, as `{ "from", "fromPort" }`. Bento removes whatever is connected to that output. `to` is optional and only for readability.
      
      - **update_links** (`array`): 
        Repoint connections, as `{ "from", "to", "fromPort" }`.
      
    

    
> A `delay` step's `config` must include both `delay_interval_count` and `delay_interval`, such as `"2"` and `"days"`.


    Invalid patches return `422` with one message per problem, for example `add_nodes[0].type must be a non-empty string` or `add_nodes ids already exist on the flow: node-email-2`.
  
  
    
```json
{
  "add_nodes": [
    {
      "id": "new-delay-1",
      "type": "delay",
      "config": { "delay_interval_count": "2", "delay_interval": "days" },
      "insert_after": "node-email-2"
    },
    {
      "id": "new-tag-1",
      "type": "tag",
      "config": { "tag_name": "onboarded" },
      "insert_after": "new-delay-1"
    }
  ],
  "update_nodes": [
    { "id": "node-delay-1", "config": { "delay_interval_count": "3" } }
  ]
}
```
    
    
> This patch changes the first wait to 3 days, then adds a 2-day wait and an `onboarded` tag after the nudge email in the [Get Workflow example](#get-workflow).