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

# Guardar fases, mapeo, reglas de entrada y alertas

> Reemplaza la configuración completa. Enviar el `updatedAt` leído para detectar cambios concurrentes; `null` si se editó la semilla. Las alertas omitidas toman sus valores por defecto.



## OpenAPI

````yaml /generated/specs/sales.json put /api/v1/cases/config
openapi: 3.0.0
info:
  title: Raul API - Ventas
  description: >-
    Cotizaciones, pipeline, outreach comercial, equipos cotizables y ventas de
    equipamiento.
  version: 2.0.0
  contact: {}
servers:
  - url: https://api.raul.ugps.io
    description: Production
security: []
tags: []
paths:
  /api/v1/cases/config:
    put:
      tags:
        - cases
      summary: Guardar fases, mapeo, reglas de entrada y alertas
      description: >-
        Reemplaza la configuración completa. Enviar el `updatedAt` leído para
        detectar cambios concurrentes; `null` si se editó la semilla. Las
        alertas omitidas toman sus valores por defecto.
      operationId: CaseBoardConfigController_saveConfig
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                version:
                  type: number
                  enum:
                    - 1
                columns:
                  minItems: 2
                  maxItems: 8
                  type: array
                  items:
                    type: object
                    properties:
                      id:
                        type: string
                        pattern: ^[a-z0-9-]{1,40}$
                      name:
                        type: string
                        minLength: 1
                        maxLength: 40
                      color:
                        type: string
                        pattern: ^#[0-9A-Fa-f]{6}$
                      order:
                        type: integer
                        minimum: 0
                        maximum: 100
                      isFinal:
                        type: boolean
                    required:
                      - id
                      - name
                      - color
                      - order
                      - isFinal
                    additionalProperties: false
                stageMap:
                  type: object
                  additionalProperties:
                    type: string
                    maxLength: 40
                entryRules:
                  type: object
                  additionalProperties:
                    anyOf:
                      - type: object
                        properties:
                          type:
                            type: string
                            enum:
                              - minStageOrder
                          minStageOrder:
                            type: integer
                            minimum: 0
                            maximum: 1000
                        required:
                          - minStageOrder
                        additionalProperties: false
                      - type: object
                        properties:
                          type:
                            type: string
                            enum:
                              - scheduledResume
                        required:
                          - type
                        additionalProperties: false
                dueAlerts:
                  default:
                    blinkSeconds: 8
                    default:
                      warnHours: 2
                      criticalHours: 0
                    byType: {}
                  type: object
                  properties:
                    blinkSeconds:
                      type: integer
                      minimum: 0
                      maximum: 60
                    default:
                      type: object
                      properties:
                        warnHours:
                          type: number
                          minimum: 0
                          maximum: 720
                        criticalHours:
                          type: number
                          minimum: 0
                          maximum: 720
                      required:
                        - warnHours
                        - criticalHours
                      additionalProperties: false
                    byType:
                      type: object
                      additionalProperties:
                        type: object
                        properties:
                          warnHours:
                            type: number
                            minimum: 0
                            maximum: 720
                          criticalHours:
                            type: number
                            minimum: 0
                            maximum: 720
                        required:
                          - warnHours
                          - criticalHours
                        additionalProperties: false
                  required:
                    - blinkSeconds
                    - default
                    - byType
                  additionalProperties: false
                replyAlert:
                  default:
                    warnHours: 2
                    criticalHours: 9
                    windowDays: null
                  type: object
                  properties:
                    warnHours:
                      type: number
                      minimum: 0
                      maximum: 720
                    criticalHours:
                      type: number
                      minimum: 0
                      maximum: 720
                    windowDays:
                      nullable: true
                      type: integer
                      minimum: 1
                      maximum: 90
                  required:
                    - warnHours
                    - criticalHours
                    - windowDays
                  additionalProperties: false
                waitingStages:
                  default:
                    stageKeys: []
                    warnHours: 9
                    criticalHours: 18
                  type: object
                  properties:
                    stageKeys:
                      maxItems: 200
                      type: array
                      items:
                        type: string
                        pattern: ^ticket:[0-9a-f-]{36}:\d{1,9}$
                    warnHours:
                      type: number
                      minimum: 0
                      maximum: 720
                    criticalHours:
                      type: number
                      minimum: 0
                      maximum: 720
                  required:
                    - stageKeys
                    - warnHours
                    - criticalHours
                  additionalProperties: false
                mentionAlert:
                  default:
                    warnHours: 4
                    criticalHours: 9
                  type: object
                  properties:
                    warnHours:
                      type: number
                      minimum: 0
                      maximum: 720
                    criticalHours:
                      type: number
                      minimum: 0
                      maximum: 720
                  required:
                    - warnHours
                    - criticalHours
                  additionalProperties: false
                updatedAt:
                  nullable: true
                  type: string
                  format: date-time
                  pattern: >-
                    ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z|([+-](?:[01]\d|2[0-3]):[0-5]\d)))$
              required:
                - version
                - columns
                - stageMap
                - entryRules
              additionalProperties: false
      responses:
        '200':
          description: Configuración guardada, con su nueva revisión `updatedAt`
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CaseBoardConfigViewDto'
        '400':
          description: >-
            Configuración inválida (case_board_config_invalid) o una etapa
            apunta a una fase inexistente (case_board_stage_column_missing)
        '403':
          description: Usuario con empresa (case_board_staff_only)
        '409':
          description: >-
            Otra persona guardó cambios después de `updatedAt`
            (case_board_config_conflict)
components:
  schemas:
    CaseBoardConfigViewDto:
      type: object
      properties:
        config:
          $ref: '#/components/schemas/CaseBoardConfigDto'
        isDefault:
          type: boolean
          description: '`true` si no hay configuración guardada (semilla)'
        updatedAt:
          type: string
          format: date-time
          nullable: true
          description: >-
            Revisión guardada; se reenvía en el PUT para detectar conflictos
            (409). `null` sin fila
        pipelines:
          type: array
          items:
            $ref: '#/components/schemas/CaseBoardPipelineViewDto'
        dueAlerts:
          $ref: '#/components/schemas/CaseDueAlertsDto'
        replyAlert:
          $ref: '#/components/schemas/CaseReplyAlertDto'
        waitingStages:
          $ref: '#/components/schemas/CaseWaitingStagesDto'
        mentionAlert:
          $ref: '#/components/schemas/CaseMentionAlertDto'
        activityTypes:
          type: array
          items:
            $ref: '#/components/schemas/CaseActivityTypeDto'
        warnings:
          description: >-
            Etapas abiertas sin fase en la configuración guardada; vacío en la
            semilla
          type: array
          items:
            $ref: '#/components/schemas/CaseBoardConfigWarningDto'
        defaults:
          description: Umbrales por defecto de las alertas del caso
          allOf:
            - $ref: '#/components/schemas/CaseAlertRulesDto'
      required:
        - config
        - isDefault
        - updatedAt
        - pipelines
        - dueAlerts
        - replyAlert
        - waitingStages
        - mentionAlert
        - activityTypes
        - warnings
        - defaults
    CaseBoardConfigDto:
      type: object
      properties:
        version:
          type: number
          enum:
            - 1
        columns:
          type: array
          items:
            $ref: '#/components/schemas/CaseBoardColumnDto'
        stageMap:
          type: object
          additionalProperties:
            type: string
          description: >-
            Fase por etapa: `<kind>:<pipelineId>:<stageId>` → id de fase; una
            etapa sin entrada usa el mapeo por defecto
        entryRules:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/CaseEntryRuleDto'
          description: 'Regla de entrada por pipeline: `<kind>:<pipelineId>`'
        dueAlerts:
          $ref: '#/components/schemas/CaseDueAlertsDto'
        replyAlert:
          $ref: '#/components/schemas/CaseReplyAlertDto'
        waitingStages:
          $ref: '#/components/schemas/CaseWaitingStagesDto'
        mentionAlert:
          $ref: '#/components/schemas/CaseMentionAlertDto'
      required:
        - version
        - columns
        - stageMap
        - entryRules
        - dueAlerts
        - replyAlert
        - waitingStages
        - mentionAlert
    CaseBoardPipelineViewDto:
      type: object
      properties:
        kind:
          type: string
          enum:
            - opportunity
            - ticket
        id:
          type: string
          format: uuid
        name:
          type: string
        isDefault:
          type: boolean
        stages:
          type: array
          items:
            $ref: '#/components/schemas/CaseStageDto'
        columnByStage:
          type: object
          additionalProperties:
            type: string
          description: Fase de cada etapa (id de etapa → id de fase) con el mapeo vigente
        entryRule:
          nullable: true
          type: object
          allOf:
            - $ref: '#/components/schemas/CaseEntryRuleDto'
      required:
        - kind
        - id
        - name
        - isDefault
        - stages
        - columnByStage
        - entryRule
    CaseDueAlertsDto:
      type: object
      properties:
        blinkSeconds:
          type: number
          description: >-
            Segundos de parpadeo de una tarjeta en alerta hasta que alguien
            actúe; la UI guarda 8 (encendido) o 0 (sólo color)
        default:
          $ref: '#/components/schemas/CaseDueAlertRuleDto'
        byType:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/CaseDueAlertRuleDto'
          description: >-
            Umbral por id de tipo de actividad de la tarea; la clave heredada
            `nextAction` se acepta pero ya no se aplica
      required:
        - blinkSeconds
        - default
        - byType
    CaseReplyAlertDto:
      type: object
      properties:
        warnHours:
          type: number
          description: Horas desde el mensaje del cliente para naranjo
        criticalHours:
          type: number
          description: Horas desde el mensaje del cliente para rojo
        windowDays:
          type: number
          nullable: true
          description: Días de mensajes que cuentan; `null` = sin límite
      required:
        - warnHours
        - criticalHours
        - windowDays
    CaseWaitingStagesDto:
      type: object
      properties:
        stageKeys:
          description: 'Etapas de espera de tickets: `ticket:<pipelineId>:<stageId>`'
          type: array
          items:
            type: string
        warnHours:
          type: number
          description: Horas hábiles en la etapa para naranjo
        criticalHours:
          type: number
          description: Horas hábiles en la etapa para rojo
      required:
        - stageKeys
        - warnHours
        - criticalHours
    CaseMentionAlertDto:
      type: object
      properties:
        warnHours:
          type: number
          description: Horas hábiles desde la mención para naranjo
        criticalHours:
          type: number
          description: Horas hábiles desde la mención para rojo
      required:
        - warnHours
        - criticalHours
    CaseActivityTypeDto:
      type: object
      properties:
        id:
          type: number
        name:
          type: string
      required:
        - id
        - name
    CaseBoardConfigWarningDto:
      type: object
      properties:
        key:
          type: string
          description: Clave de `stageMap` sin fase
        pipelineId:
          type: string
          format: uuid
        stageId:
          type: string
        stageName:
          type: string
      required:
        - key
        - pipelineId
        - stageId
        - stageName
    CaseAlertRulesDto:
      type: object
      properties:
        dueAlerts:
          $ref: '#/components/schemas/CaseDueAlertsDto'
        replyAlert:
          $ref: '#/components/schemas/CaseReplyAlertDto'
        waitingStages:
          $ref: '#/components/schemas/CaseWaitingStagesDto'
        mentionAlert:
          $ref: '#/components/schemas/CaseMentionAlertDto'
      required:
        - dueAlerts
        - replyAlert
        - waitingStages
        - mentionAlert
    CaseBoardColumnDto:
      type: object
      properties:
        id:
          type: string
          example: pending
        name:
          type: string
          example: Pendiente
        color:
          type: string
          example: '#F59E0B'
        order:
          type: number
        isFinal:
          type: boolean
          description: 'Fase de cerrados: sólo la usa la vista Lista'
      required:
        - id
        - name
        - color
        - order
        - isFinal
    CaseEntryRuleDto:
      type: object
      properties:
        type:
          type: string
          enum:
            - minStageOrder
            - scheduledResume
          description: >-
            Sin `type` = `minStageOrder`. `scheduledResume` (sólo negocios)
            oculta el negocio hasta su reactivación programada
        minStageOrder:
          type: number
          description: Orden mínimo de etapa para entrar a Casos (`minStageOrder`)
    CaseStageDto:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        color:
          type: string
        order:
          type: number
        isFinal:
          type: boolean
        isWon:
          type: boolean
        isLost:
          type: boolean
        probability:
          type: number
          nullable: true
          description: >-
            Probabilidad de cierre de una etapa de negocios (0 a 1; ganada 1,
            perdida 0); `null` en tickets o sin configurar
      required:
        - id
        - name
        - color
        - order
        - isFinal
        - isWon
        - isLost
        - probability
    CaseDueAlertRuleDto:
      type: object
      properties:
        warnHours:
          type: number
          description: Horas antes del vencimiento para naranjo
        criticalHours:
          type: number
          description: Horas antes del vencimiento para rojo; 0 = al vencer
      required:
        - warnHours
        - criticalHours

````

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