> ## 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).
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).
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'
      responses:
        '200':
          $ref: '#/components/responses/NtfAuto_AutomationPatch200'
        '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'
    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).'
      description: >-
        Gráfico acíclico (DAG) con exactamente un `trigger`. Las aristas que
        comienzan en `condition` requieren `branch`: `true` | `false`.
    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
            graphJson:
              $ref: '#/components/schemas/NtfAuto_AutomationGraph'
            graphVersion:
              type: integer
            updatedAt:
              type: string
              format: date-time
    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
    NtfAuto_ErrorEnvelope401:
      type: object
      required:
        - success
        - error
        - message
      properties:
        success:
          type: boolean
          enum:
            - false
        error:
          type: string
          example: Unauthorized
        message:
          type: 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
    NtfAuto_ErrorForbiddenScope:
      type: object
      required:
        - success
        - error
        - message
      properties:
        success:
          type: boolean
          enum:
            - false
        error:
          type: string
          enum:
            - Forbidden
        message:
          type: string
    NtfAuto_ErrorNotFound:
      type: object
      required:
        - success
        - error
        - message
      properties:
        success:
          type: boolean
          enum:
            - false
        error:
          type: string
          enum:
            - Not Found
        message:
          type: 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`.
    NtfAuto_StepTrigger:
      type: object
      required:
        - stepKey
        - stepType
        - config
      properties:
        stepKey:
          type: string
          minLength: 1
          maxLength: 128
        stepType:
          type: string
          enum:
            - trigger
        config:
          type: object
          required:
            - eventName
          properties:
            eventName:
              type: string
              minLength: 1
              maxLength: 256
              description: >-
                No puede comenzar con `notifique:` (no distingue entre
                mayúsculas y minúsculas).
    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
    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.
    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
    NtfAuto_StepSendEmail:
      type: object
      required:
        - stepKey
        - stepType
        - config
      properties:
        stepKey:
          type: string
        stepType:
          type: string
          enum:
            - sendEmail
        config:
          type: object
          required:
            - subject
            - htmlBody
          properties:
            subject:
              type: string
              maxLength: 512
            htmlBody:
              type: string
              maxLength: 100000
            fromEmail:
              type: string
              nullable: true
    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
            body:
              type: string
              maxLength: 8192
    NtfAuto_StepSendSms:
      type: object
      required:
        - stepKey
        - stepType
        - config
      properties:
        stepKey:
          type: string
        stepType:
          type: string
          enum:
            - sendSms
        config:
          type: object
          required:
            - body
          properties:
            body:
              type: string
              maxLength: 2000
    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
            body:
              type: string
              maxLength: 8192
    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
            title:
              type: string
              maxLength: 256
            body:
              type: string
              maxLength: 4096
            url:
              type: string
              nullable: true
    NtfAuto_StepSendRcs:
      type: object
      required:
        - stepKey
        - stepType
        - config
      properties:
        stepKey:
          type: string
        stepType:
          type: string
          enum:
            - sendRcs
        config:
          type: object
          required:
            - body
          properties:
            body:
              type: string
              maxLength: 4096
    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`.'
    NtfAuto_StepDeleteContact:
      type: object
      required:
        - stepKey
        - stepType
        - config
      properties:
        stepKey:
          type: string
        stepType:
          type: string
          enum:
            - deleteContact
        config:
          type: object
          additionalProperties: false
    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.
    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
    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`).
  responses:
    NtfAuto_AutomationPatch200:
      description: >-
        Actualizado (incluye `graphJson` y `graphVersion` incrementados cuando
        cambia el gráfico).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/NtfAuto_AutomationPatchResponse'
    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: Plano caducado o espacio de trabajo suspendido.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/NtfAuto_ErrorPaymentRequired'
          example:
            success: false
            error: Payment Required
            message: Plan expired or suspended
            code: WORKSPACE_BLOCKED
    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.

````