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

# Update an automation

> Changes only the fields you send; `trigger` replaces the whole trigger, and null makes the automation manual. An automation runs as whoever last saved what it runs. If that is someone else and your edit changes what it runs or how and when it runs, the request is refused with 409 unless it sends `"runAsMe": true`. Renaming, disabling or turning off admin tools keeps the current writer.



## OpenAPI

````yaml /openapi/customer-api.json patch /project/{projectId}/automations/{automationId}
openapi: 3.0.0
info:
  contact: {}
  description: >-
    Flow customer API reference. Start with the [quickstart](/api/quickstart)
    and [authentication guide](/api/authentication).
  title: Customer API
  version: 1.0.0
servers:
  - description: Flow API
    url: '{baseUrl}'
    variables:
      baseUrl:
        default: https://backend.branch.flowengineering.com
security: []
tags:
  - name: Automations
  - name: Branches
  - name: Comments
  - name: Convert
  - name: Data Model
  - name: Diagrams
  - name: Entities
  - name: Files
  - name: Import
  - name: Notifications
  - name: Projects
  - name: ReqIF
  - name: ReqIF Import
  - name: Shared Access Grants
  - name: User Groups
  - name: Users
paths:
  /project/{projectId}/automations/{automationId}:
    patch:
      tags:
        - Automations
      summary: Update an automation
      description: >-
        Changes only the fields you send; `trigger` replaces the whole trigger,
        and null makes the automation manual. An automation runs as whoever last
        saved what it runs. If that is someone else and your edit changes what
        it runs or how and when it runs, the request is refused with 409 unless
        it sends `"runAsMe": true`. Renaming, disabling or turning off admin
        tools keeps the current writer.
      operationId: AutomationsController_update
      parameters:
        - in: path
          name: projectId
          required: true
          schema:
            type: string
        - in: path
          name: automationId
          required: true
          schema:
            type: string
        - description: Workspace identifier
          in: header
          name: customer
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateAutomationDto'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AutomationDto'
          description: ''
        '409':
          description: >-
            The edit would make the automation run as you instead of its current
            writer, and `runAsMe` was not sent.
      security:
        - api-key: []
        - bearer: []
components:
  schemas:
    UpdateAutomationDto:
      properties:
        allowAdminTools:
          description: >-
            Let runs keep the admin-only data-model, saved-view and template
            tools, honored only while the user it runs as is a project admin.
            Can't be turned on with an API key; turn it on in Flow.
          type: boolean
        confirmBeforeExecute:
          description: >-
            Branch-review triggers: whether the agent presents a plan for
            approval before writing. Defaults to true.
          type: boolean
        enabled:
          description: >-
            Whether script automation runs are enabled. Defaults to true;
            ignored in agent mode.
          type: boolean
        mode:
          description: >-
            What runs: `agent` (the default) follows `prompt`; `script` runs
            `script` and needs the automation scripts beta.
          enum:
            - agent
            - script
          type: string
        name:
          example: Nightly orphan check
          type: string
        prompt:
          description: >-
            The instructions an agent automation follows. Required in agent
            mode.
          type: string
        runAsMe:
          description: >-
            Confirms that this automation should run as you from now on.
            Required when you are not its current writer and the edit changes
            what it runs, or how and when it runs. Renaming it, disabling it or
            turning off admin tools never changes whom it runs as. Sent with no
            other change, it only makes you the writer.
          type: boolean
        script:
          description: The python a script automation runs. Required in script mode.
          type: string
        trigger:
          allOf:
            - $ref: '#/components/schemas/AutomationTriggerDto'
          description: >-
            When the automation runs. Omit or send null for an automation that
            is only run by hand.
          nullable: true
          type: object
      type: object
    AutomationDto:
      properties:
        allowAdminTools:
          type: boolean
        confirmBeforeExecute:
          type: boolean
        enabled:
          description: >-
            Whether script automation runs are enabled. Defaults to true;
            ignored in agent mode.
          type: boolean
        id:
          type: string
        mode:
          enum:
            - agent
            - script
          type: string
        name:
          type: string
        prompt:
          type: string
        runsAs:
          $ref: '#/components/schemas/AutomationRunsAsDto'
        script:
          type: string
        trigger:
          allOf:
            - $ref: '#/components/schemas/AutomationTriggerDto'
          nullable: true
          type: object
      required:
        - id
        - name
      type: object
    AutomationTriggerDto:
      properties:
        authors:
          description: >-
            GitHub/GitLab triggers: only fire for these authors. Empty or absent
            fires for everyone.
          items:
            type: string
          type: array
        branch:
          description: 'Manual triggers: whether the automation can be run from a branch.'
          type: boolean
        branchId:
          description: 'Schedule triggers: the branch each run starts from.'
          type: string
        branchIds:
          description: >-
            Schedule triggers: run once per listed branch on every occurrence.
            Takes precedence over `branchId`.
          items:
            type: string
          type: array
        cronExpression:
          description: 'Schedule triggers: a five-field cron expression.'
          example: 0 9 * * 1-5
          type: string
        paths:
          description: >-
            GitHub/GitLab triggers: only fire for changes under these paths.
            Empty or absent fires for every change.
          items:
            type: string
          type: array
        source:
          description: >-
            When the automation runs: a built-in source (branch, endpoint,
            import, schedule, slack, github, gitlab, onshape), 'manual', or the
            name of a custom webhook trigger.
          example: schedule
          type: string
        timeZone:
          description: >-
            Schedule triggers: the IANA timezone the cron expression is read in.
            Defaults to UTC.
          example: America/Los_Angeles
          type: string
        types:
          description: 'Manual triggers: the category ids of the items it can be run from.'
          items:
            type: string
          type: array
      required:
        - source
      type: object
    AutomationRunsAsDto:
      properties:
        isAdmin:
          type: boolean
        kind:
          enum:
            - user
            - author_unknown
            - author_unavailable
          type: string
        userId:
          type: string
      required:
        - kind
      type: object
  securitySchemes:
    api-key:
      in: header
      name: X-API-Key
      type: apiKey
    bearer:
      bearerFormat: JWT
      scheme: bearer
      type: http

````

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