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

# Update an automation rule

> Update an automation rule. Send only the keys you want to change. When you send `events`, `conditions` or `actions`, it replaces the whole current list. Header values of `send_to_api` actions are never returned, so send them again when you resend such an action.

> [!NOTE]
>
> Replace `{your-subdomain}` with your workspace’s subdomain. \
> Learn how to find your subdomain in [Workspace subdomain](https://apidocs.neetoform.com/api/workspace-subdomain.md).


## OpenAPI

````yaml bundled/automation-rules.yaml PATCH /forms/{form_id}/automation_rules/{id}
openapi: 3.0.3
info:
  title: NeetoForm APIs
  version: 2.0.0
servers:
  - description: NeetoForm APIs
    url: https://{your-subdomain}.neetoform.com/api/external/v2
    variables:
      your-subdomain:
        default: spinkart
        description: >-
          Replace **spinkart** with your [workspace's
          subdomain](/api/workspace-subdomain).
security: []
paths:
  /forms/{form_id}/automation_rules/{id}:
    patch:
      tags:
        - Automation Rules
      summary: Update an automation rule
      description: >-
        Update an automation rule. Send only the keys you want to change. When
        you send `events`, `conditions` or `actions`, it replaces the whole
        current list. Header values of `send_to_api` actions are never returned,
        so send them again when you resend such an action.
      parameters:
        - $ref: '#/components/parameters/api_key_header'
        - $ref: '#/components/parameters/form_id_param'
        - $ref: '#/components/parameters/rule_id_param'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - automation_rule
              properties:
                automation_rule:
                  $ref: '#/components/schemas/automation_rule_body'
      responses:
        '200':
          description: OK - The automation rule was updated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/automation_rule_response'
        '400':
          description: Bad Request - The `automation_rule` key is missing
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error_response'
              example:
                error: 'param is missing or the value is empty: automation_rule'
        '404':
          description: Not Found - The form or the automation rule does not exist
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error_response'
              example:
                error: Automation::Rule does not exist.
        '422':
          description: >-
            Unprocessable Entity - The rule is invalid, for example the name is
            missing or already used
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error_response'
              example:
                error: name is required.
components:
  parameters:
    api_key_header:
      in: header
      name: X-Api-Key
      description: >-
        Use the X-Api-Key header to provide your workspace API key. Refer to
        [Authentication](/api/authentication) for more information.
      required: true
      schema:
        type: string
        default: your-api-key
    form_id_param:
      in: path
      name: form_id
      description: >-
        Unique ID of the form. Refer to [Getting the Form
        ID](/api/getting-form-id) for detailed instructions.
      required: true
      schema:
        type: string
    rule_id_param:
      in: path
      name: id
      description: Unique ID of the automation rule.
      required: true
      schema:
        type: string
  schemas:
    automation_rule_body:
      type: object
      properties:
        name:
          type: string
          description: >-
            Name of the rule. Must be unique in the form, ignoring case.
            Required when creating a rule.
          example: Email the sales team
        description:
          type: string
          example: New leads
        status:
          type: string
          enum:
            - enabled
            - disabled
          description: Defaults to `enabled`.
        performer:
          type: string
          description: '`any` (default), or the name of an organization role.'
        execution_delay:
          $ref: '#/components/schemas/execution_delay'
        events:
          type: array
          description: >-
            When the rule runs. When you send this on update, it replaces all
            current events.
          items:
            type: string
            enum:
              - submission_created
              - custom_field_updated
        conditions:
          type: array
          description: >-
            Conditions that must match. When you send this on update, it
            replaces all current conditions.
          items:
            type: object
            properties:
              field:
                type: string
                description: ID of a question or a custom field.
              kind:
                type: string
                enum:
                  - record
                  - custom_field
              verb:
                type: string
                description: See the `verb` values in the response.
              join_type:
                type: string
                enum:
                  - and_operator
                  - or_operator
              metadata:
                type: object
        actions:
          type: array
          description: >
            Actions to run. When you send this on update, it replaces all
            current actions.

            Header values are not returned when you read a rule, so send the
            header values again when you resend a `send_to_api` action.
          items:
            type: object
            properties:
              name:
                type: string
                description: See the `name` values in the response.
              actionable_type:
                type: string
              actionable_id:
                type: string
              metadata:
                type: object
    automation_rule_response:
      type: object
      properties:
        automation_rule:
          $ref: '#/components/schemas/automation_rule'
    error_response:
      type: object
      properties:
        error:
          type: string
    execution_delay:
      type: object
      nullable: true
      description: How long to wait after the event before the actions run.
      properties:
        value:
          type: integer
          minimum: 1
          maximum: 15
          example: 5
        unit:
          type: string
          enum:
            - minutes
            - hours
            - days
          example: minutes
    automation_rule:
      allOf:
        - $ref: '#/components/schemas/automation_rule_summary'
        - type: object
          properties:
            events:
              type: array
              items:
                type: string
                enum:
                  - submission_created
                  - custom_field_updated
            conditions:
              type: array
              items:
                $ref: '#/components/schemas/rule_condition'
            actions:
              type: array
              items:
                $ref: '#/components/schemas/rule_action'
    automation_rule_summary:
      type: object
      properties:
        id:
          type: string
          example: 0d4a5b8e-2f61-4b0c-8a3e-5f7c9e2d1a44
        name:
          type: string
          example: Email the sales team
        description:
          type: string
          nullable: true
          example: New leads
        status:
          type: string
          enum:
            - enabled
            - disabled
        performer:
          type: string
          description: '`any`, or the name of an organization role.'
          example: any
        display_order:
          type: integer
          description: Position in the order in which rules run, starting from 1.
        disabled_reason:
          type: string
          nullable: true
        execution_delay:
          $ref: '#/components/schemas/execution_delay'
        created_at:
          $ref: '#/components/schemas/date_time_field'
        updated_at:
          $ref: '#/components/schemas/date_time_field'
    rule_condition:
      type: object
      properties:
        id:
          type: string
        field:
          type: string
          description: ID of a question or a custom field.
        kind:
          type: string
          enum:
            - record
            - custom_field
        verb:
          type: string
          description: >-
            One of `is`, `is_not`, `contains`, `does_not_contain`,
            `contains_any_of`, `contains_all_of`, `contains_none_of`,
            `starts_with`, `ends_with`, `any_of`, `none_of`, `less_than`,
            `greater_than`, `any_time`, `during`, `not_during`, `is_before` or
            `is_after`.
          example: contains
        join_type:
          type: string
          enum:
            - and_operator
            - or_operator
        metadata:
          type: object
          description: >-
            Holds `value`, or `values` (a list) for verbs that take many values.
            For choice questions, use option IDs.
          example:
            value: '@example.com'
    rule_action:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
          description: >-
            One of `email_to_responder`, `email_to_form_creator`,
            `email_to_all_members`, `email_to`, `sms_to_responder`, `sms_to`,
            `send_to_api` or `assign_field_value`.
          example: email_to
        actionable_type:
          type: string
          nullable: true
          description: >-
            `Record` for the `*_to_responder` actions,
            `NeetoFieldsEngine::Field` for `assign_field_value`. Otherwise
            empty.
        actionable_id:
          type: string
          nullable: true
        metadata:
          type: object
          description: >
            Settings of the action.

            - Email actions: `subject`, `body` and, for `email_to`, `emails`.
            The body can use Liquid, for example `{{all-answers}}`.

            - SMS actions: `body` and, for `sms_to`, `phone_numbers`.

            - `*_to_responder` actions: `value` is the ID of the question that
            holds the responder's address or number.

            - `send_to_api`: `endpoint`, `body` (a JSON string),
            `enable_custom_headers` and `custom_headers`. Header values are
            never returned, only the keys.

            - `assign_field_value`: `value`.
          example:
            subject: New lead
            body: '{{all-answers}}'
            emails:
              - sales@example.com
    date_time_field:
      type: string
      format: date-time

````

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