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

# Flows

> List, read, create, change and switch on your FlowIQ flows from your own code.

A **flow** is an automation: a trigger (an order is paid, a tag is added, an event from your system…) followed by steps (wait, check, split, send a WhatsApp message or an email, tag, make a discount code…). Everything you can build in **Automation → Flows** you can read and write here.

All endpoints live on `https://api.flowiq.live` and take an organisation API key (**Settings → API Keys**) as `Authorization: Bearer fiq_…`. Reads need the **read** scope, changes need **write**.

> [!NOTE]
>
> A flow you create is always **switched off**. Switching it on is its own call, so a script can never start messaging customers by accident.

## Endpoints

| Method | Path | What it does |
| - | - | - |
| `GET` | [`/v1/flows`](https://docs.flowapt.com/flowiq-api-reference/endpoint/list-flows) | List flows. `?status=live` or `off`, `?trigger=orders/paid`, `?limit=` (1-100, default 50), `?cursor=` from `next_cursor` |
| `POST` | [`/v1/flows`](https://docs.flowapt.com/flowiq-api-reference/endpoint/create-flow) | Create a flow (switched off). Send an `Idempotency-Key` header to make retries safe |
| `GET` | [`/v1/flows/{id}`](https://docs.flowapt.com/flowiq-api-reference/endpoint/get-flow) | One flow with its full `definition` and its `etag` |
| `PATCH` | [`/v1/flows/{id}`](https://docs.flowapt.com/flowiq-api-reference/endpoint/update-flow) | Change `name`, `description`, `repeat` or `definition`. Needs `If-Match: <etag>` |
| `POST` | [`/v1/flows/{id}/status`](https://docs.flowapt.com/flowiq-api-reference/endpoint/set-flow-status) | `{"status": "live"}` or `{"status": "off"}` |
| `DELETE` | [`/v1/flows/{id}`](https://docs.flowapt.com/flowiq-api-reference/endpoint/delete-flow) | Delete a flow that is off, with its run history |
| `GET` | [`/v1/flows/{id}/report`](https://docs.flowapt.com/flowiq-api-reference/endpoint/flow-report) | Results per step and per split path: sent, delivered, read / opened, clicked, orders, revenue. `?days=30` |
| `GET` | [`/v1/flows/{id}/runs`](https://docs.flowapt.com/flowiq-api-reference/endpoint/flow-runs) | Recent runs with their status. `?status=`, `?limit=` |

## The flow object

```json theme={null}
{
  "id": "b8ce9c3f-d028-4da8-9fb2-9573cf413856",
  "name": "Abandoned checkout",
  "description": null,
  "status": "off",
  "repeat": "reenter_after",
  "trigger": { "type": "event", "event": "checkouts/create", "source": "shopify" },
  "definition": { "trigger": { … }, "steps": [ … ] },
  "etag": "3f9a1c0d7e2b4a61",
  "stats": { "total_sent": 0, "total_triggered": 0 },
  "created_at": "2026-12-01T19:39:02Z",
  "updated_at": "2026-12-01T19:39:02Z"
}
```

`repeat` is one of `off` (every time it triggers), `once_per_contact`, `once_per_order`, `once_per_order_per_day`, `once_per_subscription`, `reenter_after` (then `definition.reenter_after_days`).

## Changing a flow safely

1. `GET /v1/flows/{id}` and keep its `etag`.
2. Change the `definition` you got back.
3. `PATCH /v1/flows/{id}` with `If-Match: <etag>`.

If someone changed the flow in the app since you read it, you get **412 precondition\_failed** with the new `etag`, and nothing is overwritten. Every change is kept as a version in the app (**Versions**).

## Example: an abandoned checkout that re-sends to people who did not open

```bash theme={null}
curl -X POST https://api.flowiq.live/v1/flows \
  -H "Authorization: Bearer $FLOWIQ_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: abandoned-v1" \
  -d '{
    "name": "Abandoned checkout",
    "repeat": "reenter_after",
    "definition": {
      "trigger": { "type": "event", "event": "checkouts/create", "source": "shopify" },
      "reenter_after_days": 7,
      "exit_rules": { "logic": "any", "conditions": [
        { "type": "event", "field": "contact", "action": "placed_order", "operator": "has", "timeframe": { "type": "since_trigger" } }
      ] },
      "steps": [
        { "id": "w1", "type": "delay", "value": 1, "unit": "hours" },
        { "id": "m1", "type": "action", "action_type": "send_message",
          "config": { "template_name": "cart_reminder_v1", "body_parameters": { "param1": "{{contact.first_name}}" } } },
        { "id": "w2", "type": "delay", "value": 1, "unit": "days", "until_time": "09:00", "weekdays": [1, 2, 3, 4, 5] },
        { "id": "s1", "type": "split", "config": {
          "paths": [ { "id": "p1", "name": "Did not read it",
            "conditions": [ { "type": "message_engagement", "signal": "opened", "operator": "did_not", "step_id": "m1" } ],
            "steps": [ { "id": "m2", "type": "action", "action_type": "send_message", "config": { "template_name": "cart_reminder_2" } } ] } ],
          "otherwise": { "id": "o1", "name": "Everyone else", "steps": [] } } }
      ]
    }
  }'
```

Then switch it on:

```bash theme={null}
curl -X POST https://api.flowiq.live/v1/flows/$FLOW_ID/status \
  -H "Authorization: Bearer $FLOWIQ_KEY" -H "Content-Type: application/json" \
  -d '{"status": "live"}'
```

A flow cannot go live while a WhatsApp message in it has no approved template: you get **409 not\_ready** with the steps to fix in `problems`.

## Building blocks

**Triggers** (`definition.trigger`): Shopify `orders/paid`, `orders/fulfilled`, `orders/create`, `checkouts/create`; WooCommerce `wc/order.paid` and friends; `contact.tag_added` (with `tag`), `contact.created`, `message.first`, `message.keyword`; `date.attribute`, `date.after_last_order`, `date.before_renewal`, `date.unengaged`; `store.browse_abandoned`, `store.active`; `product.price_drop`, `product.low_stock`; `api.event` (with `event_name`, started by [Send an event](https://docs.flowapt.com/flowiq-api-reference/send-event.md)).

**Steps** (`definition.steps`): `delay` (`value`, `unit`, optional `until_time` and `weekdays`), `condition` (checks that must pass), `split` (paths with their own steps; random paths make an A/B test), `action` with `send_message` (a WhatsApp template), `email` (plain text, or `content: "design"` with an email designed in Broadcast → Email), `update_contact` (tags and fields), `discount_code`, `alert`, `webhook`, `agent_brief`.

**Checks** (in `condition` steps, split paths and `exit_rules`): what they ordered, a detail of the order, their subscription, the items or collection in the order, `message_engagement` (did they open or click a message of this flow), `engagement` (engaged lately), `store_activity` (on the store lately), `replied`, and more.

The easiest way to see the exact shape of anything: build it in **Automation → Flows**, then `GET /v1/flows/{id}`.

## Errors

| Status | Code | When |
| - | - | - |
| 400 | `validation_error` | The flow was refused; `errors` lists every problem with its step |
| 403 | `forbidden_scope` | The key lacks read or write |
| 404 | `not_found` | No flow with that id in your organisation |
| 409 | `not_ready` | Going live with a message that has no template |
| 409 | `flow_live` | Deleting a flow that is still live |
| 412 | `precondition_failed` | The flow changed since you read it |
| 428 | `precondition_required` | `PATCH` without `If-Match` |
| 429 | `rate_limited` | More than 600 reads or 60 changes a minute |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.