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

# Actualizar automatización

> Actualiza una automatización.



## OpenAPI

````yaml /es/automations-api/api-reference/openapi-automations.json patch /v1/automations/{automationId}
openapi: 3.0.3
info:
  title: 'Notifique API v1: Automatizaciones y eventos'
  version: 1.0.0
  description: >-
    Definición de **eventos** (nombre + esquema `payload` opcional),
    **automatizaciones** como gráfico (activador por evento o **mensaje
    entrante** en un canal, retrasos, condiciones, incluido **`source:
    "message"`** en entrante, **`endFlow`** para finalizar una sucursal, envíos
    multicanal, actualizaciones de contactos, etc.) y **activador** mediante
    `POST /v1/events/send`. Autenticación: encabezado `Authorization: Bearer
    sk_live_...` o `x-api-key`. Todos los cuerpos usan **camelCase**.


    **Alcances:** `events:read` | `events:write` | `automations:read` |
    `automations:write`. Los pasos de envío (`sendTemplate`, correos
    electrónicos directos, etc.) aún requieren las claves de envío del canal
    correspondiente.


    **Paginación:** consulta `page` (≥1, predeterminado 1) y `limit` (1 a 100,
    predeterminado 20), como cadenas o números coherentes.


    **Espacio de trabajo bloqueado** devuelve **402** con `Payment Required`.


    **Incorporación:** en cualquier ruta `/v1`, si la incorporación está
    incompleta, el middleware devuelve **403** con `code: ONBOARDING_REQUIRED`
    (cuerpo similar a otros 403).


    **Escopos adicionais:** `assistants:read` | `assistants:write` |
    `assistants:invoke` | `knowledge_bases:read` | `knowledge_bases:write` |
    `mcp_connections:read` | `mcp_connections:write` | `http_tools:read` |
    `http_tools:write`.
servers:
  - url: https://api.notifique.dev
    description: Producción
security:
  - ntfAutoBearerAuth: []
  - ntfAutoApiKeyHeader: []
tags:
  - name: Eventos
    description: CRUD de configuración de eventos + disparador `POST /v1/events/send`.
  - name: Automatizaciones
    description: CRUD de automatizaciones, listado de parada y ejecución.
  - name: Runs
    description: Historial y detalles de ejecuciones (`AutomationRun` + pasos).
  - name: Assistentes
    description: CRUD de WorkspaceAssistant, invoke de teste e bindings MCP/HTTP.
  - name: Bases de conhecimento
    description: CRUD de bases RAG e documentos.
  - name: MCP
    description: Conexões MCP do workspace (CUSTOM_URL via API; OAuth curado no painel).
  - name: HTTP tools
    description: Ferramentas REST allowlist para assistentes.
  - name: Inbox
    description: Conversaciones unificadas y métricas (recurso premium).
paths:
  /v1/automations/{automationId}:
    patch:
      tags:
        - Automações
      summary: Actualizar automatización
      description: Actualiza una automatización.
      operationId: ntfAuto_patchAutomation
      parameters:
        - $ref: '#/components/parameters/NtfAuto_automationId'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/NtfAuto_AutomationPatchBody'
            example:
              name: Exemplo
              status: ENABLED
              graph:
                steps:
                  - stepKey: string
                    stepType: trigger
                connections:
                  - from: '5511999999999'
                    to: '5511999999999'
                    branch: 'true'
                nodeLayout: {}
      responses:
        '200':
          $ref: '#/components/responses/NtfAuto_AutomationPatch200'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ntfAuto_PatchAutomationResponse'
        '400':
          $ref: '#/components/responses/NtfAuto_GraphOrBody400Patch'
        '401':
          $ref: '#/components/responses/NtfAuto_401'
        '402':
          $ref: '#/components/responses/NtfAuto_402'
        '403':
          $ref: '#/components/responses/NtfAuto_403AutomationsWrite'
        '404':
          $ref: '#/components/responses/NtfAuto_AutomationNotFound'
components:
  parameters:
    NtfAuto_automationId:
      name: automationId
      in: path
      required: true
      schema:
        type: string
      description: Cuida la automatización.
  schemas:
    NtfAuto_AutomationPatchBody:
      type: object
      properties:
        name:
          type: string
          maxLength: 256
        status:
          type: string
          enum:
            - ENABLED
            - DISABLED
        graph:
          $ref: '#/components/schemas/NtfAuto_AutomationGraph'
      example:
        name: Exemplo
        status: ENABLED
        graph:
          steps:
            - stepKey: string
              stepType: trigger
          connections:
            - from: '5511999999999'
              to: '5511999999999'
              branch: 'true'
          nodeLayout: {}
    ntfAuto_PatchAutomationResponse:
      type: object
      additionalProperties: false
      description: Resposta JSON vazia (sucesso sem payload).
      properties:
        success:
          type: boolean
          example: true
      example:
        success: true
    NtfAuto_AutomationGraph:
      type: object
      required:
        - steps
        - connections
      properties:
        steps:
          type: array
          minItems: 2
          items:
            $ref: '#/components/schemas/NtfAuto_GraphStep'
        connections:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/NtfAuto_GraphConnection'
        nodeLayout:
          type: object
          additionalProperties:
            type: object
            required:
              - x
              - 'y'
            properties:
              x:
                type: number
              'y':
                type: number
          description: 'Opcional: posiciones del editor visual (`stepKey` → coordenadas).'
          properties: {}
      description: >-
        Gráfico acíclico (DAG) con exactamente un `trigger`. Las aristas que
        comienzan en `condition` requieren `branch`: `true` | `false`.
      example:
        steps:
          - stepKey: string
            stepType: trigger
        connections:
          - from: '5511999999999'
            to: '5511999999999'
            branch: 'true'
        nodeLayout: {}
    NtfAuto_AutomationPatchResponse:
      type: object
      required:
        - success
        - data
      properties:
        success:
          type: boolean
          enum:
            - true
        data:
          type: object
          required:
            - id
            - name
            - status
            - triggerEventName
            - graphJson
            - graphVersion
            - updatedAt
          properties:
            id:
              type: string
            name:
              type: string
            status:
              type: string
              enum:
                - ENABLED
                - DISABLED
            triggerEventName:
              type: string
            triggerKind:
              type: string
              enum:
                - EVENT
                - CHANNEL_INBOUND
                - WEBHOOK
                - WHATSAPP_CALL
            triggerChannel:
              nullable: true
              type: string
              enum:
                - WHATSAPP
                - TELEGRAM
                - SMS
                - WEB_WIDGET
                - INSTAGRAM
            triggerInstanceId:
              type: string
              nullable: true
            triggerAiWebWidgetId:
              type: string
              nullable: true
            graphJson:
              $ref: '#/components/schemas/NtfAuto_AutomationGraph'
            graphVersion:
              type: integer
            updatedAt:
              type: string
              format: date-time
      example:
        success: true
        data:
          id: clxx...
          name: Exemplo
          status: ENABLED
          triggerEventName: string
          graphJson:
            steps:
              - stepKey: string
                stepType: trigger
            connections:
              - from: '5511999999999'
                to: '5511999999999'
                branch: 'true'
            nodeLayout: {}
          graphVersion: 1
          updatedAt: '2025-02-10T14:00:00.000Z'
          triggerKind: EVENT
          triggerChannel: WHATSAPP
          triggerInstanceId: clxx...
          triggerAiWebWidgetId: clxx...
    NtfAuto_ErrorGraphValidation:
      type: object
      required:
        - success
        - error
      properties:
        success:
          type: boolean
          enum:
            - false
        error:
          type: string
          description: >-
            Mensaje detallado (la validación de Zod se concatena con `; ` en
            INVALID_GRAPH).
        code:
          type: string
          description: Código estable cuando falla el gráfico o el enlace del evento.
          enum:
            - INVALID_GRAPH
            - DUPLICATE_STEP_KEY
            - TRIGGER_COUNT
            - UNKNOWN_STEP
            - CONDITION_BRANCHES
            - CONDITION_BRANCH_TAG
            - CONDITION_BRANCH_DUP
            - BRANCH_INVALID
            - TRIGGER_NOT_ROOT
            - GRAPH_CYCLE
            - UNREACHABLE_STEP
            - DELAY_INCOMPLETE
            - CONDITION_SOURCE
            - CONDITION_PROPERTY
            - CONDITION_OPERATOR
            - CONDITION_VALUE
            - SEND_TEMPLATE_ID
            - SEND_EMAIL_INCOMPLETE
            - SEND_WHATSAPP_INCOMPLETE
            - SEND_TEXT_INCOMPLETE
            - SEND_TELEGRAM_INCOMPLETE
            - SEND_PUSH_INCOMPLETE
            - UPDATE_CONTACT_EMPTY
            - UPDATE_CONTACT_FIELD
            - UPDATE_CONTACT_INTENT
            - UPDATE_CONTACT_CLEAR_CUSTOM
            - UPDATE_CONTACT_VALUE
            - CREATE_CONTACT_RECIPIENT
            - EVENT_NOT_REGISTERED
        message:
          type: string
          example: Campo inválido ou ausente.
      example:
        success: false
        error: string
        code: INVALID_GRAPH
    NtfAuto_ErrorEnvelope401:
      type: object
      required:
        - success
        - error
        - message
      properties:
        success:
          type: boolean
          enum:
            - false
        error:
          type: string
          example: Unauthorized
        message:
          type: string
        code:
          type: string
          example: VALIDATION_ERROR
      example:
        success: false
        error: Unauthorized
        message: string
    NtfAuto_ErrorPaymentRequired:
      type: object
      required:
        - success
        - error
        - message
      properties:
        success:
          type: boolean
          enum:
            - false
        error:
          type: string
          enum:
            - Payment Required
        message:
          type: string
          example: Plan expired or suspended
        code:
          type: string
          enum:
            - WORKSPACE_BLOCKED
            - PLAN_LIMIT_AUTOMATIONS
            - PREMIUM_FEATURE_REQUIRES_PLAN_OR_BALANCE
      example:
        success: false
        error: Payment Required
        message: Plan expired or suspended
        code: WORKSPACE_BLOCKED
    NtfAuto_ErrorForbiddenScope:
      type: object
      required:
        - success
        - error
        - message
      properties:
        success:
          type: boolean
          enum:
            - false
        error:
          type: string
          enum:
            - Forbidden
        message:
          type: string
        code:
          type: string
          example: FORBIDDEN
      example:
        success: false
        error: Forbidden
        message: string
    NtfAuto_ErrorNotFound:
      type: object
      required:
        - success
        - error
        - message
      properties:
        success:
          type: boolean
          enum:
            - false
        error:
          type: string
          enum:
            - Not Found
        message:
          type: string
        code:
          type: string
          example: NOT_FOUND
      example:
        success: false
        error: Not Found
        message: string
    NtfAuto_GraphStep:
      oneOf:
        - $ref: '#/components/schemas/NtfAuto_StepTrigger'
        - $ref: '#/components/schemas/NtfAuto_StepDelay'
        - $ref: '#/components/schemas/NtfAuto_StepCondition'
        - $ref: '#/components/schemas/NtfAuto_StepSendTemplate'
        - $ref: '#/components/schemas/NtfAuto_StepSendEmail'
        - $ref: '#/components/schemas/NtfAuto_StepSendWhatsapp'
        - $ref: '#/components/schemas/NtfAuto_StepSendSms'
        - $ref: '#/components/schemas/NtfAuto_StepSendTelegram'
        - $ref: '#/components/schemas/NtfAuto_StepSendPush'
        - $ref: '#/components/schemas/NtfAuto_StepSendRcs'
        - $ref: '#/components/schemas/NtfAuto_StepUpdateContact'
        - $ref: '#/components/schemas/NtfAuto_StepDeleteContact'
        - $ref: '#/components/schemas/NtfAuto_StepCreateContact'
        - $ref: '#/components/schemas/NtfAuto_StepEndFlow'
      discriminator:
        propertyName: stepType
        mapping:
          trigger:
            $ref: '#/components/schemas/NtfAuto_StepTrigger'
          delay:
            $ref: '#/components/schemas/NtfAuto_StepDelay'
          condition:
            $ref: '#/components/schemas/NtfAuto_StepCondition'
          sendTemplate:
            $ref: '#/components/schemas/NtfAuto_StepSendTemplate'
          sendEmail:
            $ref: '#/components/schemas/NtfAuto_StepSendEmail'
          sendWhatsapp:
            $ref: '#/components/schemas/NtfAuto_StepSendWhatsapp'
          sendSms:
            $ref: '#/components/schemas/NtfAuto_StepSendSms'
          sendTelegram:
            $ref: '#/components/schemas/NtfAuto_StepSendTelegram'
          sendPush:
            $ref: '#/components/schemas/NtfAuto_StepSendPush'
          sendRcs:
            $ref: '#/components/schemas/NtfAuto_StepSendRcs'
          updateContact:
            $ref: '#/components/schemas/NtfAuto_StepUpdateContact'
          deleteContact:
            $ref: '#/components/schemas/NtfAuto_StepDeleteContact'
          createContact:
            $ref: '#/components/schemas/NtfAuto_StepCreateContact'
          endFlow:
            $ref: '#/components/schemas/NtfAuto_StepEndFlow'
    NtfAuto_GraphConnection:
      type: object
      required:
        - from
        - to
      properties:
        from:
          type: string
          minLength: 1
          maxLength: 128
        to:
          type: string
          minLength: 1
          maxLength: 128
        branch:
          type: string
          enum:
            - 'true'
            - 'false'
          description: Obligatorio sólo dejando `condition`.
      example:
        from: '5511999999999'
        to: '5511999999999'
        branch: 'true'
    NtfAuto_StepTrigger:
      type: object
      required:
        - stepKey
        - stepType
        - config
      properties:
        stepKey:
          type: string
          minLength: 1
          maxLength: 128
        stepType:
          type: string
          enum:
            - trigger
        config:
          oneOf:
            - $ref: '#/components/schemas/NtfAuto_TriggerConfigEvent'
            - $ref: '#/components/schemas/NtfAuto_TriggerConfigChannelInbound'
            - $ref: '#/components/schemas/NtfAuto_TriggerConfigWebhook'
            - $ref: '#/components/schemas/NtfAuto_TriggerConfigWhatsappCall'
          discriminator:
            propertyName: triggerKind
            mapping:
              event:
                $ref: '#/components/schemas/NtfAuto_TriggerConfigEvent'
              channelInbound:
                $ref: '#/components/schemas/NtfAuto_TriggerConfigChannelInbound'
              webhook:
                $ref: '#/components/schemas/NtfAuto_TriggerConfigWebhook'
              whatsappCall:
                $ref: '#/components/schemas/NtfAuto_TriggerConfigWhatsappCall'
      example:
        stepKey: string
        stepType: trigger
    NtfAuto_StepDelay:
      type: object
      required:
        - stepKey
        - stepType
        - config
      properties:
        stepKey:
          type: string
          minLength: 1
          maxLength: 128
        stepType:
          type: string
          enum:
            - delay
        config:
          type: object
          required:
            - durationMs
          properties:
            durationMs:
              type: integer
              minimum: 0
              maximum: 2592000000
              description: >-
                Máximo 30 días en ms. Para persistir: `durationMs` > 0 y no use
                solo `editorDraft`.
            editorPlaceholder:
              type: boolean
            editorDraft:
              type: boolean
      example:
        stepKey: string
        stepType: delay
        config:
          durationMs: 1
          editorPlaceholder: true
          editorDraft: true
    NtfAuto_StepCondition:
      type: object
      required:
        - stepKey
        - stepType
        - config
      properties:
        stepKey:
          type: string
          minLength: 1
          maxLength: 128
        stepType:
          type: string
          enum:
            - condition
        config:
          type: object
          required:
            - source
            - operator
          properties:
            source:
              type: string
              enum:
                - event
                - contact
                - message
              description: >-
                `event` o `contact` cuando el desencadenante es un evento de
                API. `message` es **obligatorio** cuando el desencadenante es un
                mensaje recibido en un canal (compare el texto entrante: cuerpo
                → vista previa del cuerpo → vista previa).
            propertyKey:
              type: string
              maxLength: 256
              nullable: true
              description: >-
                Obligatorio para `source` `event` o `contact`: ruta en carga
                útil (puntos permitidos) o campo de contacto. Omitir por
                `message`.
            operator:
              type: string
              enum:
                - equals
                - notEquals
                - exists
                - isEmpty
                - contains
                - startsWith
                - endsWith
                - gt
                - lt
                - gte
                - lte
            compareValue:
              type: string
              nullable: true
              description: >-
                Obligatorio (no vacío) para operadores excepto `exists` y
                `isEmpty`. Para `gt`, `lt`, `gte` y `lte`, el valor de la
                izquierda y `compareValue` se interpretan como números (cadena
                numérica o número JSON); si alguno no es finito, la condición es
                falsa.
      example:
        stepKey: string
        stepType: condition
        config:
          source: event
          operator: equals
          propertyKey: string
          compareValue: string
    NtfAuto_StepSendTemplate:
      type: object
      required:
        - stepKey
        - stepType
        - config
      properties:
        stepKey:
          type: string
        stepType:
          type: string
          enum:
            - sendTemplate
        config:
          type: object
          required:
            - templateId
            - channels
          properties:
            templateId:
              type: string
            channels:
              type: array
              minItems: 1
              items:
                type: string
                enum:
                  - whatsapp
                  - sms
                  - email
                  - telegram
            fromEmail:
              type: string
              nullable: true
            instanceId:
              type: string
              nullable: true
            telegramInstanceId:
              type: string
              nullable: true
            variables:
              type: object
              additionalProperties:
                type: string
      example:
        stepKey: string
        stepType: sendTemplate
        config:
          templateId: clxx...
          channels:
            - whatsapp
          fromEmail: string
          instanceId: clxx...
          telegramInstanceId: clxx...
          variables: {}
    NtfAuto_StepSendEmail:
      type: object
      required:
        - stepKey
        - stepType
        - config
      properties:
        stepKey:
          type: string
        stepType:
          type: string
          enum:
            - sendEmail
        config:
          type: object
          required:
            - subject
            - htmlBody
          properties:
            htmlBody:
              type: string
              maxLength: 100000
            fromEmail:
              type: string
              nullable: true
      example:
        stepKey: string
        stepType: sendEmail
        config:
          htmlBody: string
          fromEmail: string
    NtfAuto_StepSendWhatsapp:
      type: object
      required:
        - stepKey
        - stepType
        - config
      properties:
        stepKey:
          type: string
        stepType:
          type: string
          enum:
            - sendWhatsapp
        config:
          type: object
          required:
            - instanceId
            - body
          properties:
            instanceId:
              type: string
      example:
        stepKey: string
        stepType: sendWhatsapp
        config:
          instanceId: clxx...
    NtfAuto_StepSendSms:
      type: object
      required:
        - stepKey
        - stepType
        - config
      properties:
        stepKey:
          type: string
        stepType:
          type: string
          enum:
            - sendSms
        config:
          type: object
          required:
            - body
          properties: {}
      example:
        stepKey: string
        stepType: sendSms
        config: {}
    NtfAuto_StepSendTelegram:
      type: object
      required:
        - stepKey
        - stepType
        - config
      properties:
        stepKey:
          type: string
        stepType:
          type: string
          enum:
            - sendTelegram
        config:
          type: object
          required:
            - instanceId
            - body
          properties:
            instanceId:
              type: string
      example:
        stepKey: string
        stepType: sendTelegram
        config:
          instanceId: clxx...
    NtfAuto_StepSendPush:
      type: object
      required:
        - stepKey
        - stepType
        - config
      properties:
        stepKey:
          type: string
        stepType:
          type: string
          enum:
            - sendPush
        config:
          type: object
          required:
            - pushAppId
            - title
            - body
          properties:
            pushAppId:
              type: string
      example:
        stepKey: string
        stepType: sendPush
        config:
          pushAppId: clxx...
    NtfAuto_StepSendRcs:
      type: object
      required:
        - stepKey
        - stepType
        - config
      properties:
        stepKey:
          type: string
        stepType:
          type: string
          enum:
            - sendRcs
        config:
          type: object
          required:
            - body
          properties: {}
      example:
        stepKey: string
        stepType: sendRcs
        config: {}
    NtfAuto_StepUpdateContact:
      type: object
      required:
        - stepKey
        - stepType
        - config
      properties:
        stepKey:
          type: string
        stepType:
          type: string
          enum:
            - updateContact
        config:
          type: object
          properties:
            name:
              type: string
              nullable: true
            email:
              type: string
              nullable: true
            phone:
              type: string
              nullable: true
            url:
              type: string
              nullable: true
            custom:
              type: object
              additionalProperties:
                type: string
            actions:
              type: array
              maxItems: 50
              items:
                $ref: '#/components/schemas/NtfAuto_UpdateContactAction'
              description: >-
                Lista preferida. Si está presente y no está vacío, se aplica una
                validación adicional (no mezcle `clear` con `custom:`).
          description: 'Legado: campos planos + `custom`. Nuevo flujo: `actions`.'
      example:
        stepKey: string
        stepType: updateContact
        config:
          name: Exemplo
          email: string
          phone: string
          url: https://example.com/resource
          custom: {}
          actions:
            - fieldKey: string
              intent: clear
              literal: string
              eventPath: string
    NtfAuto_StepDeleteContact:
      type: object
      required:
        - stepKey
        - stepType
        - config
      properties:
        stepKey:
          type: string
        stepType:
          type: string
          enum:
            - deleteContact
        config:
          type: object
          additionalProperties: false
      example:
        stepKey: string
        stepType: deleteContact
        config: {}
    NtfAuto_StepCreateContact:
      type: object
      required:
        - stepKey
        - stepType
        - config
      properties:
        stepKey:
          type: string
        stepType:
          type: string
          enum:
            - createContact
        config:
          type: object
          properties:
            name:
              type: string
              nullable: true
            email:
              type: string
              nullable: true
            phone:
              type: string
              nullable: true
          description: Al menos uno de `email` o `phone` no está vacío después del recorte.
      example:
        stepKey: string
        stepType: createContact
        config:
          name: Exemplo
          email: string
          phone: string
    NtfAuto_StepEndFlow:
      type: object
      required:
        - stepKey
        - stepType
        - config
      properties:
        stepKey:
          type: string
          minLength: 1
          maxLength: 128
        stepType:
          type: string
          enum:
            - endFlow
        config:
          type: object
          description: >-
            Terminator: sin conexiones salientes; El motor se completa sin
            efectos secundarios.
          additionalProperties: false
      example:
        stepKey: string
        stepType: endFlow
        config: {}
    NtfAuto_TriggerConfigEvent:
      type: object
      required:
        - triggerKind
        - eventName
      properties:
        triggerKind:
          type: string
          enum:
            - event
        eventName:
          type: string
          minLength: 1
          maxLength: 256
          description: >-
            Nombre registrado en `POST /v1/events`. No puede empezar con
            `notifique:` (case-insensitive), salvo eventos internos allowlisted.
      example:
        triggerKind: event
        eventName: string
    NtfAuto_TriggerConfigChannelInbound:
      type: object
      required:
        - triggerKind
        - channel
      properties:
        triggerKind:
          type: string
          enum:
            - channelInbound
        channel:
          type: string
          enum:
            - WHATSAPP
            - TELEGRAM
            - SMS
            - WEB_WIDGET
            - INSTAGRAM
        inboundKind:
          type: string
          enum:
            - dm
            - comment
          default: dm
          description: 'INSTAGRAM: DM o comentario en post. Otros canales lo ignoran.'
        instanceId:
          type: string
          nullable: true
          maxLength: 128
          description: >-
            WA/TG/SMS/INSTAGRAM: instancia específica; omitir o `null` =
            cualquier instancia del canal en el workspace.
        webWidgetId:
          type: string
          nullable: true
          maxLength: 128
          description: >-
            WEB_WIDGET: widget específico; omitir o `null` = cualquier widget
            del workspace.
        conversationSessionPolicy:
          type: object
          description: >-
            Política opcional de sesión inbound (inactividad, cooldown
            post-cierre, keywords, debounce del asistente).
      example:
        triggerKind: channelInbound
        channel: WHATSAPP
        inboundKind: dm
        instanceId: clxx...
        webWidgetId: clxx...
        conversationSessionPolicy: {}
    NtfAuto_TriggerConfigWebhook:
      type: object
      required:
        - triggerKind
      properties:
        triggerKind:
          type: string
          enum:
            - webhook
        payloadMappings:
          type: array
          maxItems: 40
          items:
            type: object
            required:
              - alias
              - jsonPath
            properties:
              alias:
                type: string
                maxLength: 64
              jsonPath:
                type: string
                maxLength: 512
          default: []
        contactIdPath:
          type: string
          nullable: true
          maxLength: 512
        emailPath:
          type: string
          nullable: true
          maxLength: 512
        phonePath:
          type: string
          nullable: true
          maxLength: 512
      example:
        triggerKind: webhook
        payloadMappings: []
        contactIdPath: clxx...
        emailPath: string
        phonePath: string
    NtfAuto_TriggerConfigWhatsappCall:
      type: object
      required:
        - triggerKind
        - callPhase
      properties:
        triggerKind:
          type: string
          enum:
            - whatsappCall
        callPhase:
          type: string
          enum:
            - initiated
            - answered
            - completed
            - hung_up
            - failed
            - no_answer
            - rejected
        instanceId:
          type: string
          nullable: true
          maxLength: 128
          description: >-
            Instancia WhatsApp específica; omitir o `null` = cualquier instancia
            del workspace.
      example:
        triggerKind: whatsappCall
        callPhase: initiated
        instanceId: clxx...
    NtfAuto_UpdateContactAction:
      type: object
      required:
        - fieldKey
        - intent
      properties:
        fieldKey:
          type: string
          minLength: 1
          maxLength: 128
          description: >-
            `name` | `email` | `phone` | `url` | `custom:chave`. Con `intent:
            clear`, no utilice `custom:`.
        intent:
          type: string
          enum:
            - clear
            - set
        literal:
          type: string
          nullable: true
          description: Valor fijo o marcadores de posición; utilizado con `set`.
        eventPath:
          type: string
          nullable: true
          description: Introduzca la carga útil del evento (con `set`).
      example:
        fieldKey: string
        intent: clear
        literal: string
        eventPath: string
  responses:
    NtfAuto_AutomationPatch200:
      description: >-
        Actualizado (incluye `graphJson` y `graphVersion` incrementados cuando
        cambia el gráfico).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/NtfAuto_AutomationPatchResponse'
          example:
            success: true
            data:
              id: clxx...
              name: Exemplo
              status: ENABLED
              triggerEventName: string
              graphJson:
                steps:
                  - stepKey: string
                    stepType: trigger
                connections:
                  - from: '5511999999999'
                    to: '5511999999999'
                    branch: 'true'
                nodeLayout: {}
              graphVersion: 1
              updatedAt: '2025-02-10T14:00:00.000Z'
              triggerKind: EVENT
              triggerChannel: WHATSAPP
              triggerInstanceId: clxx...
              triggerAiWebWidgetId: clxx...
    NtfAuto_GraphOrBody400Patch:
      description: '`name` vacío, o `graph` inválido (los mismos códigos que la creación).'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/NtfAuto_ErrorGraphValidation'
          examples:
            emptyName:
              value:
                success: false
                error: Bad Request
                message: name cannot be empty
                code: BAD_REQUEST
    NtfAuto_401:
      description: >-
        Clave faltante o no válida. En el middleware global de `/v1` también
        ocurre cuando no hay una clave API.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/NtfAuto_ErrorEnvelope401'
          examples:
            route:
              value:
                success: false
                error: Unauthorized
                message: Invalid or missing API Key
                code: UNAUTHORIZED
            middleware:
              value:
                success: false
                error: Unauthorized
                message: >-
                  API Key is required. Provide Authorization: Bearer <key> or
                  x-api-key header.
                code: UNAUTHORIZED
    NtfAuto_402:
      description: >-
        Plan expirado o workspace suspendido (`WORKSPACE_BLOCKED`), límite de
        automatizaciones del plan (`PLAN_LIMIT_AUTOMATIONS`) o plan/trial sin
        saldo para automatizaciones/eventos
        (`PREMIUM_FEATURE_REQUIRES_PLAN_OR_BALANCE`).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/NtfAuto_ErrorPaymentRequired'
          examples:
            workspaceBlocked:
              value:
                success: false
                error: Payment Required
                message: Plan expired or suspended
                code: WORKSPACE_BLOCKED
            premiumFeature:
              value:
                success: false
                error: Payment Required
                message: Premium automations require an active plan, trial, or balance
                code: PREMIUM_FEATURE_REQUIRES_PLAN_OR_BALANCE
    NtfAuto_403AutomationsWrite:
      description: Sin alcance `automations:write`.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/NtfAuto_ErrorForbiddenScope'
          example:
            success: false
            error: Forbidden
            message: 'Missing scope: automations:write'
            code: FORBIDDEN
    NtfAuto_AutomationNotFound:
      description: Automatización inexistente o excluida.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/NtfAuto_ErrorNotFound'
          example:
            success: false
            error: Not Found
            message: Automation not found
            code: NOT_FOUND
  securitySchemes:
    ntfAutoBearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: '`Authorization: Bearer sk_live_...`'
    ntfAutoApiKeyHeader:
      type: apiKey
      in: header
      name: x-api-key
      description: Mismo valor de clave, sin prefijo de portador.

````