> ## 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](https://docs.clustr-ai.com/workflows.md): a trigger block pointing at a saved view, plus one
or more action blocks.

> [!NOTE]
>
> **Actions fire on transitions, starting after the first pass.** The first
> pass records who already matches the view; after that, each real transition
> (a record entering or leaving) triggers an action. Creating a Workflow over a
> view with 500 existing matches sends no notifications for those 500.

```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" } }
      ]
    }
  }'
```

```json 201 theme={null}
{
  "success": true,
  "data": {
    "workflow": {
      "clustr_workflow_id": "wf_6zzpxenvr4b2ya4598bgvgk7dg",
      "clustrViewId": "view_2smktjqhs4zr4rxsstanj669ya",
      "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" }
}
```


## OpenAPI

````yaml POST /workflows
openapi: 3.1.0
info:
  title: Clustr Public API
  description: >
    Programmatic access to your Clustr network: import connectors, search warm
    intros (opportunities), and manage target accounts.


    ## Authentication

    All endpoints require a Bearer token (API key) in the `Authorization`
    header.


    ```

    Authorization: Bearer <your_api_key>

    ```


    API keys can be created and managed from the [API settings
    page](https://app.clustr-ai.com/api).
  version: '1.0'
  contact:
    name: Clustr Support
    url: https://clustr-ai.com
servers:
  - url: https://api.clustr-ai.com/api/public
    description: Production
security:
  - BearerAuth: []
paths:
  /workflows:
    post:
      tags:
        - Workflows
      summary: Create Workflow
      description: >-
        Creates a Workflow: a view, a trigger (enter, leave or schedule) and one
        or more actions. The first pass records the view's current members as a
        starting point, so only records that enter or leave the view after that,
        or a schedule coming due, trigger an action.
      operationId: createWorkflow
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateWorkflowRequest'
      responses:
        '201':
          description: The new Workflow
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
                    properties:
                      workflow:
                        $ref: '#/components/schemas/Workflow'
        '400':
          description: Invalid trigger or action configuration
        '401':
          description: Invalid or missing API key
components:
  schemas:
    CreateWorkflowRequest:
      type: object
      required:
        - name
        - workflow_data
      properties:
        name:
          type: string
          description: Display name.
        description:
          type: string
          description: Optional free text.
        is_active:
          type: boolean
          default: false
          description: Whether the Workflow runs. Create it inactive to review it first.
        workflow_data:
          type: object
          description: >-
            The Workflow's blocks, as `{ blocks: [...] }`. The first block is
            the trigger:


            ```json

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


            `on` is `enter`, `leave` or `schedule`; `schedule` also 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.
          required:
            - blocks
          properties:
            blocks:
              type: array
              items:
                type: object
                additionalProperties: true
    Workflow:
      type: object
      description: >-
        A Workflow triggered by a saved view: it acts on records as they enter
        or leave the view, or on a schedule.
      required:
        - id
        - name
      properties:
        clustr_workflow_id:
          type: string
          description: >-
            The Workflow's Clustr ID, for example
            `wf_01afk2wz00yrbyda280rhtz7tc`. Use it to refer to this

            Workflow.
          example: wf_01afk2wz00yrbyda280rhtz7tc
        clustr_workspace_id:
          type: string
          description: >-
            The workspace's Clustr ID, for example
            `ten_7z5tpty5g2bh41zrdr9ccyp75k`.
          example: ten_7z5tpty5g2bh41zrdr9ccyp75k
        clustrViewId:
          type: string
          description: |-
            The Clustr ID of the saved view the Workflow watches, for example
            `view_57t0m43h0bwxfw1nc7p3800xrq`.
          example: view_57t0m43h0bwxfw1nc7p3800xrq
        id:
          type: string
          format: uuid
          description: >-
            Kept for integrations built before Clustr IDs. New integrations
            should use `clustr_workflow_id`.
        tenant_id:
          type: string
          format: uuid
          description: >-
            Kept for integrations built before Clustr IDs. New integrations
            should use `clustr_workspace_id`.
        name:
          type: string
        description:
          type: string
          nullable: true
        is_active:
          type: boolean
        viewId:
          type: string
          format: uuid
          description: >-
            Kept for integrations built before Clustr IDs. New integrations
            should use `clustrViewId`.
        entity:
          type: string
          enum:
            - accounts
            - people
        'on':
          type: string
          enum:
            - enter
            - leave
            - schedule
        schedule_cron:
          type: string
          nullable: true
          description: >-
            The schedule, as a 5-field cron expression. Set only when `on` is
            `schedule`.
        memberCount:
          type: integer
          description: How many records are currently in the view.
        last_run_at:
          type: string
          format: date-time
          nullable: true
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: The API key you created on the API settings page of the Clustr app.

````

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