> ## 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.

# Actualitzar un flux

> Actualitza la configuració d'un flux existent, incloent nom, descripció, lògica d'execució, condicions i configuració de destí. Retorna el recurs actualitzat (200) després d'una actualització correcta.



## OpenAPI

````yaml /ca/api-reference/openapi.ca-v1.json put /v1/organizations/{organization_id}/flows/{flow_id}
openapi: 3.0.3
info:
  title: API Publica Portal
  version: 1.0.0
  description: API pública REST per al portal
servers:
  - url: https://api.flexxible.net
    description: Portal API (production)
security:
  - bearerAuth: []
tags: []
paths:
  /v1/organizations/{organization_id}/flows/{flow_id}:
    put:
      tags:
        - Fluxos
      summary: Actualitzar un flux
      description: >-
        Actualitza la configuració d'un flux existent, incloent nom, descripció,
        lògica d'execució, condicions i configuració de destí. Retorna el recurs
        actualitzat (200) després d'una actualització correcta.
      operationId: updateFlow
      parameters:
        - name: organization_id
          in: path
          required: true
          schema:
            type: string
            maxLength: 24
            pattern: ^[0-9a-f]{24}$
          description: El identificador únic de l'organització
          example: 507f1f77bcf86cd799439011
        - name: flow_id
          in: path
          required: true
          schema:
            type: string
            maxLength: 24
            pattern: ^[0-9a-f]{24}$
          description: L'identificador únic del flux a actualitzar
          example: 507f1f77bcf86cd799439012
        - 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: >-
            Codi de idioma per a camps de text que admeten diversos idiomes. Al
            crear o actualitzar recursos, això especifica el idioma dels valors
            de text proporcionats. Al recuperar recursos, això determina quina
            variant de idioma dels camps de text multilingües es retorna. Valors
            acceptats: 'en-EN' (anglès), 'es-ES' (espanyol), 'pt-BR'
            (portuguès), 'ca-ES' (català), 'eu-ES' (euskera). El valor
            predeterminat és 'es-ES' si no es proporciona.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateFlowV1Request'
            examples:
              update-flow-configuration:
                summary: Actualitza flux amb nova configuració
                value:
                  name:
                    en-EN: Flujo diario de copia actualizado
                    es-ES: Proceso de copia diaria actualizado
                  description:
                    en-EN: Proceso automatizado de copia diaria actualizado
                    es-ES: Proceso automatizado de copia actualizado
                  detection_only: false
                  cooldown_minutes: 120
                  enabled: true
                  init_text:
                    en-EN: Iniciando proceso de copia actualizado...
                    es-ES: Iniciando proceso de copia actualizado...
                  ok_text:
                    en-EN: Copia completada correctamente
                  ko_text:
                    en-EN: La copia fallo. Por favor, revisa los registros.
                  target:
                    type: workspaces
                    ids:
                      - 507f1f77bcf86cd799439012
                      - 507f1f77bcf86cd799439013
                  microservice_id: 507f1f77bcf86cd799439014
                  conditions:
                    - condition_type_id: 507f1f77bcf86cd799439015
                      operator: gte
                      compare_to: '90'
                      period: null
                      check_every: 600
      responses:
        '200':
          description: >-
            Flux actualitzat correctament. La resposta conté el recurs
            actualitzat.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FlowV1'
        '400':
          $ref: '#/components/responses/BadRequest'
          description: >-
            Sol·licitud incorrecta. Causes comunes: - Falten camps obligatoris -
            Valors de camp no vàlids - Configuració de condició no vàlida -
            Identificador de microservei no vàlid
        '401':
          $ref: '#/components/responses/Unauthorized'
          description: No autoritzat - autenticació requerida
        '404':
          $ref: '#/components/responses/NotFound'
          description: Flux o organització no trobats
        '422':
          $ref: '#/components/responses/UnprocessableEntity'
          description: >-
            Entitat no processable. Causes comunes: - Microservei referenciat no
            trobat - Entitats objectiu referenciades (Espais de treball, Grups
            d'espais de treball, Grups de report) no trobades o no pertanyents -
            Tipus de condició no vàlid - El flux no es pot habilitar
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '500':
          $ref: '#/components/responses/InternalServerError'
components:
  schemas:
    UpdateFlowV1Request:
      type: object
      properties:
        name:
          $ref: '#/components/schemas/MultilangField'
          description: >-
            Nom del flux. Es requereix almenys una clau d'idioma; cada valor
            entre 1 i 512 caràcters.
        description:
          $ref: '#/components/schemas/MultilangField'
          description: >-
            Descripció del flux. Es requereix almenys una clau d'idioma; cada
            valor entre 1 i 512 caràcters.
        detection_only:
          type: boolean
        cooldown_minutes:
          type: number
          minimum: 10
          maximum: 1440
          description: Temps d'espera en minuts. Ha d'estar entre 10 i 1440.
        enabled:
          type: boolean
          description: >-
            Indica si el flux està habilitat. PUT espera una definició completa;
            aquest camp és obligatori.
        init_text:
          $ref: '#/components/schemas/MultilangField'
          nullable: true
          description: >-
            Missatge de text inicial. Obligatori en PUT. Envia null per netejar;
            en cas contrari, objecte amb almenys una clau d'idioma; cada valor
            entre 1 i 512 caràcters.
        ok_text:
          $ref: '#/components/schemas/MultilangField'
          nullable: true
          description: >-
            Missatge de text d'èxit. Obligatori en PUT. Envia null per netejar;
            en cas contrari, objecte amb almenys una clau d'idioma; cada valor
            entre 1 i 512 caràcters.
        ko_text:
          $ref: '#/components/schemas/MultilangField'
          nullable: true
          description: >-
            Missatge de text d'error. Obligatori en PUT. Envia null per netejar;
            en cas contrari, objecte amb almenys una clau d'idioma; cada valor
            entre 1 i 512 caràcters.
        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
        - detection_only
        - cooldown_minutes
        - enabled
        - init_text
        - ok_text
        - ko_text
        - target
        - microservice_id
        - conditions
    FlowV1:
      type: object
      description: >-
        Detall del flux tal com el retorna GET flow by id. L'organització està
        implícita per la ruta
        `/v1/organizations/{organization_id}/flows/{flow_id}`. Els
        workspaces/grups de destinació es normalitzen en target.ids (cadenes
        hexadecimals de ObjectId de MongoDB).
      properties:
        id:
          type: string
          maxLength: 24
          pattern: ^[0-9a-f]{24}$
        created_at:
          type: string
          format: date-time
        name:
          type: string
          description: Resol per Accept-Language quan és multilingüe
        description:
          type: string
          description: Resol per Accept-Language quan és multilingüe
        type:
          type: string
          enum:
            - session
            - workspace
        version:
          type: number
        detection_only:
          type: boolean
        cooldown_minutes:
          type: number
          description: Temps d'espera en minuts
        enabled:
          type: boolean
        conditions:
          type: array
          items:
            $ref: '#/components/schemas/FlowConditionV1'
          description: Omitit o buit quan el flux no té condicions
        trigger:
          type: string
          nullable: true
        target:
          $ref: '#/components/schemas/FlowTargetSelectorV1'
          description: >-
            Destí d'execució: el tipus selecciona l'abast; ids enumera valors de
            _id de Workspace, _id de grup de Workspace o _id de Grup de reporte
            (buit quan el tipus és ALL_WORKSPACES)
        microservice_id:
          type: string
          nullable: true
          description: ID del microservei vinculat quan està present
        init_text:
          type: string
          nullable: true
          description: Resol per Accept-Language quan és multilingüe
        ok_text:
          type: string
          nullable: true
          description: Resol per Accept-Language quan és multilingüe
        ko_text:
          type: string
          nullable: true
          description: Resol per Accept-Language quan és multilingüe
        execution_metrics:
          $ref: '#/components/schemas/FlowExecutionMetricsV1'
          nullable: true
          description: Present quan es van calcular mètriques per a aquest flux
      required:
        - id
        - created_at
        - name
        - description
        - type
        - version
        - detection_only
        - cooldown_minutes
        - enabled
        - target
    MultilangField:
      type: object
      description: >-
        Camp multilingüe. Les claus són codis de idioma (en-EN, es-ES, pt-BR,
        eu-ES, ca-ES). Hi ha d'haver com a mínim una clau. Cada valor ha de
        tenir entre 1 i 512 caràcters.
      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 sempre és []. WORKSPACES: ids són _id de
            documents de Workspace (24 hex). WORKSPACE_GROUPS /
            REPORTING_GROUPS: ids són valors de _id de grup.
        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: Sol·licitud incorrecta
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Unauthorized:
      description: No autoritzat
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    NotFound:
      description: No trobat
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    UnprocessableEntity:
      description: Entitat no processable
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    TooManyRequests:
      description: Masses sol·licituds
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    InternalServerError:
      description: Error intern del servidor
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````