> ## Documentation Index
> Fetch the complete documentation index at: https://docs.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-v1.json post /v1/organizations/{organization_id}/flows
openapi: 3.0.3
info:
  title: Public Portal API
  version: 1.0.0
  description: Public REST API for portal
servers:
  - url: https://api.staging.flxwvdexternal.com
    description: Staging API server.
security:
  - bearerAuth: []
tags: []
paths:
  /v1/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: create flow
      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/CreateFlowV1Request'
            examples:
              create-workspace-flow:
                summary: Create a flow targeting specific workspaces
                value:
                  name:
                    en-EN: Daily Backup Flow
                    es-ES: Daily Copy Process
                  description:
                    en-EN: Automated daily backup process
                    es-ES: Automated Daily Backup Process
                  type: workspace
                  detection_only: false
                  cooldown_minutes: 60
                  enabled: false
                  init_text:
                    en-EN: Starting backup process...
                    es-ES: Starting copy process...
                  ok_text:
                    en-EN: Backup completed successfully
                    es-ES: Copy Completed Successfully
                  ko_text:
                    en-EN: Backup failed. Please check logs.
                    es-ES: Copy failed. Check the logs.
                  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/FlowV1'
              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:
    CreateFlowV1Request:
      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/FlowConditionInputV1'
      required:
        - name
        - description
        - type
        - detection_only
        - cooldown_minutes
        - target
        - microservice_id
        - conditions
    FlowV1:
      type: object
      description: >-
        Flow detail as returned by GET flow by id. Organization is implied by
        the route `/v1/organizations/{organization_id}/flows/{flow_id}`. Target
        workspaces/groups are normalized in target.ids (hexadecimal strings of
        MongoDB ObjectId).
      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/FlowConditionV1'
          description: Omitted or empty when the flow has no conditions
        trigger:
          type: string
          nullable: true
        target:
          $ref: '#/components/schemas/FlowTargetSelectorV1'
          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/FlowExecutionMetricsV1'
          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
    FlowConditionInputV1:
      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
    FlowConditionV1:
      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
    FlowTargetSelectorV1:
      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
    FlowExecutionMetricsV1:
      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

````