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

# Create a flow

> Creates a new automation flow for the specified organization. The flow defines execution logic, conditions, and target workspaces. Returns data of the created flow upon successful creation.



## OpenAPI

````yaml /en/api-reference/openapi.en-v2.json post /v2/organizations/{organization_id}/flows
openapi: 3.0.3
info:
  title: API Publica Portal
  version: 2.0.0
  description: Public REST API for portal
servers:
  - url: https://api.flexxible.net
    description: Portal API (production)
security:
  - bearerAuth: []
tags:
  - name: Digital activity
    description: Creation of core process groups by organization
  - name: Roles
    description: Endpoint de creacion de roles de organizacion
  - name: Usuarios
    description: Endpoint de creacion de usuarios de organizacion
  - name: Grupos de workspaces
    description: Endpoints de gestión de grupos de workspaces
  - name: Workspaces
    description: Endpoint de eliminacion de workspaces de la organizacion
  - name: Aplicaciones instaladas
    description: Endpoint de detalle de aplicación instalada de la organización
  - name: Autenticación
    description: Endpoints de autenticación y contexto de sesión
  - name: Microservicios
    description: Detalle de microservicios por organizacion
  - name: Operaciones
    description: Consulta de detalle de operaciones por organización
  - name: Organización
    description: Operaciones de organización
  - name: Objetivos de política de parches
    description: Endpoints de gestión de objetivos de política de parches
  - name: Configuraciones de producto
    description: Endpoints de gestión de configuraciones de producto
  - name: Grupos de reporte
    description: Operaciones sobre grupos de reporte
  - name: Sesiones
    description: Endpoint de detalle de sesion de la organizacion
  - name: Tenants
    description: Endpoints de gestión de tenants
paths:
  /v2/organizations/{organization_id}/flows:
    post:
      tags:
        - Flows
      summary: Create a flow
      description: >-
        Creates a new automation flow for the specified organization. The flow
        defines execution logic, conditions, and target workspaces. Returns data
        of the created flow upon successful creation.
      operationId: createFlow
      parameters:
        - name: organization_id
          in: path
          required: true
          schema:
            type: string
            maxLength: 24
            pattern: ^[0-9a-f]{24}$
          description: The unique identifier of the organization
          example: 507f1f77bcf86cd799439011
        - name: Accept-Language
          in: header
          required: false
          schema:
            type: string
            enum:
              - en-EN
              - es-ES
              - pt-BR
              - ca-ES
              - eu-ES
            default: es-ES
          description: >-
            Language code for text fields supporting multiple languages. When
            creating or updating resources, this specifies the language for the
            provided text values. When retrieving resources, this determines
            which language variant the multilingual text fields return. Accepted
            values: 'en-EN' (English), 'es-ES' (Spanish), 'pt-BR' (Portuguese),
            'ca-ES' (Catalan), 'eu-ES' (Basque). The default is 'es-ES' if not
            provided.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateFlowV2Request'
            examples:
              create-workspace-flow:
                summary: Create a flow targeting specific workspaces
                value:
                  name:
                    en-EN: Daily Backup Flow
                    es-ES: Proceso de copia diaria
                  description:
                    en-EN: Automated daily backup process
                    es-ES: Proceso automatizado de copia de seguridad diaria
                  type: workspace
                  detection_only: false
                  cooldown_minutes: 60
                  enabled: false
                  init_text:
                    en-EN: Starting backup process...
                    es-ES: Iniciando proceso de copia...
                  ok_text:
                    en-EN: Backup completed successfully
                    es-ES: Copia completada correctamente
                  ko_text:
                    en-EN: Backup failed. Please check logs.
                    es-ES: Copia fallida. Revise los registros.
                  target:
                    type: workspaces
                    ids:
                      - 507f1f77bcf86cd799439012
                      - 507f1f77bcf86cd799439013
                  microservice_id: 507f1f77bcf86cd799439014
                  conditions:
                    - condition_type_id: 507f1f77bcf86cd799439015
                      operator: gt
                      compare_to: '80'
                      check_every: 300
      responses:
        '201':
          description: >-
            Flow successfully created. The response contains the created
            resource.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FlowV2'
              example:
                id: 507f1f77bcf86cd799439011
        '400':
          $ref: '#/components/responses/BadRequest'
          description: >-
            Invalid request. Common causes: - Mandatory fields are missing -
            Invalid field values - Invalid condition configuration - Invalid
            microservice identifier
        '401':
          $ref: '#/components/responses/Unauthorized'
          description: Unauthorized - authentication required
        '404':
          $ref: '#/components/responses/NotFound'
          description: Organization not found
        '422':
          $ref: '#/components/responses/UnprocessableEntity'
          description: >-
            Unprocessable entity. Common causes: - Referenced microservice not
            found - Target referenced entities (workspaces, Workspace groups,
            report groups) not found or do not belong - Invalid condition type -
            Flow cannot be enabled
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '500':
          $ref: '#/components/responses/InternalServerError'
components:
  schemas:
    CreateFlowV2Request:
      type: object
      properties:
        name:
          $ref: '#/components/schemas/MultilangField'
          description: >-
            Flow name. Requires at least one language key; each value must be
            between 1 and 512 characters.
        description:
          $ref: '#/components/schemas/MultilangField'
          description: >-
            Flow description. Requires at least one language key; each value
            must be between 1 and 512 characters.
        type:
          type: string
          enum:
            - session
            - workspace
        detection_only:
          type: boolean
        cooldown_minutes:
          type: number
          minimum: 10
          maximum: 1440
          description: Waiting time in minutes. Must be between 10 and 1440.
        enabled:
          type: boolean
          default: false
          description: >-
            If true, the flow is enabled upon creation (requires valid
            conditions, microservice, and target). If omitted or false, a
            disabled flow is created.
        init_text:
          $ref: '#/components/schemas/MultilangField'
          description: >-
            Initial text message. Omitted if not needed. When provided, requires
            at least one language key; each value must be between 1 and 512
            characters.
        ok_text:
          $ref: '#/components/schemas/MultilangField'
          description: >-
            Success text message. Omitted if not needed. When provided, requires
            at least one language key; each value must be between 1 and 512
            characters.
        ko_text:
          $ref: '#/components/schemas/MultilangField'
          description: >-
            Error text message. Omitted if not needed. When provided, requires
            at least one language key; each value must be between 1 and 512
            characters.
        target:
          type: object
          properties:
            type:
              type: string
              enum:
                - all_workspaces
                - workspaces
                - workspace_groups
                - reporting_groups
            ids:
              type: array
              items:
                type: string
                maxLength: 512
          required:
            - type
        microservice_id:
          type: string
          maxLength: 24
          pattern: ^[0-9a-f]{24}$
        conditions:
          type: array
          items:
            $ref: '#/components/schemas/FlowConditionInputV2'
      required:
        - name
        - description
        - type
        - detection_only
        - cooldown_minutes
        - target
        - microservice_id
        - conditions
    FlowV2:
      type: object
      description: >-
        Flow details as returned by GET flow by id. The organization is implied
        by the path `/v2/organizations/{organization_id}/flows/{flow_id}`.
        Target workspaces/groups are normalized in target.ids (MongoDB ObjectId
        hexadecimal strings).
      properties:
        id:
          type: string
          maxLength: 24
          pattern: ^[0-9a-f]{24}$
        created_at:
          type: string
          format: date-time
        name:
          type: string
          description: Resolved to Accept-Language when multilingual
        description:
          type: string
          description: Resolved to Accept-Language when multilingual
        type:
          type: string
          enum:
            - session
            - workspace
        version:
          type: number
        detection_only:
          type: boolean
        cooldown_minutes:
          type: number
          description: Waiting time in minutes
        enabled:
          type: boolean
        conditions:
          type: array
          items:
            $ref: '#/components/schemas/FlowConditionV2'
          description: Omitted or empty when the flow has no conditions
        trigger:
          type: string
          nullable: true
        target:
          $ref: '#/components/schemas/FlowTargetSelectorV2'
          description: >-
            Execution destination: type selects the scope; ids list Workspace
            _id values, Workspace group _id values, or Reporting Group _id
            (empty when type is ALL_WORKSPACES)
        microservice_id:
          type: string
          nullable: true
          description: Linked microservice ID when present
        init_text:
          type: string
          nullable: true
          description: Resolved to Accept-Language when multilingual
        ok_text:
          type: string
          nullable: true
          description: Resolved to Accept-Language when multilingual
        ko_text:
          type: string
          nullable: true
          description: Resolved to Accept-Language when multilingual
        execution_metrics:
          $ref: '#/components/schemas/FlowExecutionMetricsV2'
          nullable: true
          description: Present when metrics are calculated for this flow
      required:
        - id
        - created_at
        - name
        - description
        - type
        - version
        - detection_only
        - cooldown_minutes
        - enabled
        - target
    MultilangField:
      type: object
      description: >-
        Multilanguage field. Keys are language codes (en-EN, es-ES, pt-BR,
        eu-ES, ca-ES). At least one key must be present. Each value must be
        between 1 and 512 characters.
      properties:
        en-EN:
          type: string
          minLength: 1
          maxLength: 512
        es-ES:
          type: string
          minLength: 1
          maxLength: 512
        pt-BR:
          type: string
          minLength: 1
          maxLength: 512
        eu-ES:
          type: string
          minLength: 1
          maxLength: 512
        ca-ES:
          type: string
          minLength: 1
          maxLength: 512
      additionalProperties: false
    FlowConditionInputV2:
      type: object
      properties:
        condition_type_id:
          type: string
          maxLength: 24
          pattern: ^[0-9a-f]{24}$
        operator:
          type: string
          enum:
            - eq
            - gt
            - lt
            - gte
            - lte
            - startsWith
            - endsWith
            - contains
            - at
        compare_to:
          type: string
          maxLength: 512
        period:
          type: number
          nullable: true
        check_every:
          type: number
      required:
        - condition_type_id
        - operator
        - compare_to
        - check_every
    FlowConditionV2:
      type: object
      properties:
        condition_type_id:
          type: string
        metric:
          type: string
        operator:
          type: string
        compare_to:
          type: string
        period:
          type: number
          nullable: true
        check_every:
          type: number
      required:
        - condition_type_id
        - metric
        - operator
        - compare_to
        - check_every
    FlowTargetSelectorV2:
      type: object
      properties:
        type:
          type: string
          enum:
            - all_workspaces
            - workspaces
            - workspace_groups
            - reporting_groups
          description: >-
            ALL_WORKSPACES: ids are always []. WORKSPACES: ids are Workspace
            document _id (24 hex). WORKSPACE_GROUPS / REPORTING_GROUPS: ids are
            group _id values.
        ids:
          type: array
          items:
            type: string
            maxLength: 24
            pattern: ^[0-9a-f]{24}$
      required:
        - type
        - ids
    FlowExecutionMetricsV2:
      type: object
      properties:
        targeted_workspaces:
          type: number
        evaluations_per_day:
          type: number
        possible_executions_per_day:
          type: number
        total_possible_executions_per_day:
          type: number
      required:
        - targeted_workspaces
        - evaluations_per_day
        - possible_executions_per_day
        - total_possible_executions_per_day
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
            code:
              type: string
            details:
              type: string
          required:
            - message
            - code
      required:
        - error
  responses:
    BadRequest:
      description: Bad Request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Unauthorized:
      description: Unauthorized
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    NotFound:
      description: Not Found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    UnprocessableEntity:
      description: Unprocessable Entity
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    TooManyRequests:
      description: Too Many Requests
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    InternalServerError:
      description: Internal Server Error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````