> ## 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.

# Create an automation

> Creates one automation at the end of the project's list. It runs as you: its scheduled and webhook runs use your access to the project for as long as you can edit it, and pause when you no longer can. Check `runsAs` on the response. Script automations need the automation scripts beta, and `allowAdminTools` cannot be turned on with an API key.



## OpenAPI

````yaml /openapi/customer-api.json post /project/{projectId}/automations
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:
    post:
      tags:
        - Automations
      summary: Create an automation
      description: >-
        Creates one automation at the end of the project's list. It runs as you:
        its scheduled and webhook runs use your access to the project for as
        long as you can edit it, and pause when you no longer can. Check
        `runsAs` on the response. Script automations need the automation scripts
        beta, and `allowAdminTools` cannot be turned on with an API key.
      operationId: AutomationsController_create
      parameters:
        - in: path
          name: projectId
          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/CreateAutomationDto'
        required: true
      responses:
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AutomationDto'
          description: ''
      security:
        - api-key: []
        - bearer: []
components:
  schemas:
    CreateAutomationDto:
      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
        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
      required:
        - name
      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.