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

# Create Workflow

> When a record enters or leaves a view, do these actions

Creates a [Workflow](/workflows): a trigger block pointing at a saved view, plus one
or more action blocks.

<Note>
  **Nothing fires on save.** The first pass records who already matches the
  view; only a real transition after that — a record entering or leaving —
  triggers an action. Creating a Workflow over a view with 500 existing matches
  does not send 500 notifications.
</Note>

## Body

<ParamField body="name" type="string" required>
  Display name.
</ParamField>

<ParamField body="description" type="string">
  Optional free text.
</ParamField>

<ParamField body="is_active" type="boolean" default="false">
  Whether the Workflow runs. Create it inactive to review it first.
</ParamField>

<ParamField body="workflow_data" type="object" required>
  `{ blocks: [...] }`. The first block is the trigger:

  ```json theme={null}
  { "type": "trigger", "id": "trigger-view-membership",
    "config": { "viewId": "<saved view id>", "entity": "accounts",
                "on": "enter" } }
  ```

  `on` is `enter`, `leave`, or `schedule` (which additionally requires a
  5-field cron in `config.schedule`). Every block after the trigger is an
  action — see [Workflows](/workflows#actions) for the full list of action ids and
  their config shape.
</ParamField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://api.clustr-ai.com/api/public/workflows" \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "Hot accounts",
      "is_active": true,
      "workflow_data": {
        "blocks": [
          { "type": "trigger", "id": "trigger-view-membership",
            "config": { "viewId": "3e5f1a22-...", "entity": "accounts", "on": "enter" } },
          { "type": "action", "id": "action-slack",
            "config": { "channel": "sales", "channelName": "#sales" } }
        ]
      }
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json 201 theme={null}
  {
    "success": true,
    "data": {
      "workflow": {
        "id": "7f1e2a33-...",
        "name": "Hot accounts",
        "is_active": true,
        "viewId": "3e5f1a22-...",
        "entity": "accounts",
        "on": "enter",
        "memberCount": 0
      }
    }
  }
  ```

  ```json 400 theme={null}
  {
    "success": false,
    "error": { "message": "'viewId' field is required", "code": "BAD_REQUEST" }
  }
  ```
</ResponseExample>
