> ## Documentation Index
> Fetch the complete documentation index at: https://kapso-1adbad2d.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a new flow

> Creates a new flow with basic data and optional definition



## OpenAPI

````yaml api/legacy/openapi-agents.yaml post /flows
openapi: 3.0.3
info:
  title: Kapso External API - Agents & Flows API
  description: >-
    API for programmatically interacting with Kapso agents, executions, and
    WhatsApp conversations. This specification includes only Agents & Flows API
    endpoints.
  version: 1.0.0
  contact:
    name: Kapso Support
servers:
  - url: https://app.kapso.ai/api/v1
    description: Production server
security:
  - ApiKeyAuth: []
paths:
  /flows:
    post:
      tags:
        - Flows
      summary: Create a new flow
      description: Creates a new flow with basic data and optional definition
      operationId: createFlow
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - flow
              properties:
                flow:
                  type: object
                  required:
                    - name
                  properties:
                    name:
                      type: string
                      example: Customer Onboarding Flow
                    description:
                      type: string
                      example: Automated flow for onboarding new customers
                    definition:
                      type: object
                      description: Optional flow definition structure
                      properties:
                        nodes:
                          type: array
                          description: Array of flow node definitions
                          items:
                            type: object
                            required:
                              - id
                              - position
                              - data
                            properties:
                              id:
                                type: string
                                description: Unique identifier for the node
                                example: start_node_1
                              position:
                                type: object
                                required:
                                  - x
                                  - 'y'
                                properties:
                                  x:
                                    type: number
                                    example: 100
                                  'y':
                                    type: number
                                    example: 200
                              data:
                                type: object
                                required:
                                  - node_type
                                properties:
                                  node_type:
                                    type: string
                                    enum:
                                      - start
                                      - send_text
                                      - send_template
                                      - set_variable
                                      - webhook
                                      - wait_for_response
                                      - decide
                                      - send_interactive
                                      - pipedream
                                      - function
                                      - agent
                                    example: start
                                  config:
                                    type: object
                                    description: Configuration specific to the node type
                                    additionalProperties: true
                        edges:
                          type: array
                          description: Array of flow edge definitions
                          items:
                            type: object
                            required:
                              - source
                              - target
                            properties:
                              id:
                                type: string
                                description: Edge identifier
                                example: edge_1
                              source:
                                type: string
                                description: Source node ID
                                example: start_node_1
                              target:
                                type: string
                                description: Target node ID
                                example: send_text_1
                              label:
                                type: string
                                description: Label for the edge
                                example: next
                              flow_condition_id:
                                type: string
                                description: ID of the flow condition (for decide nodes)
      responses:
        '201':
          description: Flow created successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/Flow'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    Flow:
      type: object
      properties:
        id:
          type: string
          format: uuid
          example: flow-123abc
        name:
          type: string
          example: Customer Onboarding Flow
        description:
          type: string
          nullable: true
          example: Automated flow for onboarding new customers
        status:
          type: string
          enum:
            - draft
            - active
            - archived
          example: active
        project_id:
          type: string
          format: uuid
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
        created_by:
          type: object
          nullable: true
          properties:
            id:
              type: string
              format: uuid
            name:
              type: string
        last_executed_at:
          type: string
          format: date-time
          nullable: true
        execution_count:
          type: integer
          example: 42
    Error:
      type: object
      properties:
        error:
          type: string
          example: Resource not found
        status:
          type: integer
          example: 404
        message:
          type: string
          example: The requested resource could not be found
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: API key required for all endpoints

````