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

# Change the field automation rules

> Ask the person before calling this: this replaces every rule in the workspace: a rule left out is deleted, and a rule with `trigger_existing` creates projects for the accounts that already match. Read the rules first (GET /v1/portals/field-automation), change what you need and send them all back with their `flow_id`. The lookup field must be an account field that looks up projects, and the template a project template: otherwise a 422 and nothing changes. Needs settings:update (an admin), as in the app.



## OpenAPI

````yaml /api/statisfy-api.openapi.json put /v1/portals/field-automation
openapi: 3.1.0
info:
  description: >-
    The agent-first Statisfy API. Authenticate with an API key (`Authorization:
    Bearer stfy_live_…`), then call `GET /v1/meta/capabilities` to discover
    every operation and its schemas.
  title: Statisfy API
  version: 1.0.0
servers:
  - url: https://api.statisfy.com
    description: Production
security: []
paths:
  /v1/portals/field-automation:
    put:
      tags:
        - portals
      summary: Change the field automation rules
      description: >-
        Ask the person before calling this: this replaces every rule in the
        workspace: a rule left out is deleted, and a rule with
        `trigger_existing` creates projects for the accounts that already match.
        Read the rules first (GET /v1/portals/field-automation), change what you
        need and send them all back with their `flow_id`. The lookup field must
        be an account field that looks up projects, and the template a project
        template: otherwise a 422 and nothing changes. Needs settings:update (an
        admin), as in the app.
      operationId: portals_update_field_automation
      requestBody:
        content:
          application/json:
            schema:
              additionalProperties: false
              properties:
                rules:
                  description: >-
                    The whole rule set: it replaces the current one, so a rule
                    left out is deleted. Send [] to delete every rule
                  items:
                    $ref: '#/components/schemas/FieldAutomationRuleInput'
                  maxItems: 100
                  title: Rules
                  type: array
              required:
                - rules
              type: object
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FieldAutomationRules'
          description: Successful Response
      security:
        - HTTPBearer: []
components:
  schemas:
    FieldAutomationRuleInput:
      properties:
        action:
          $ref: '#/components/schemas/FieldAutomationActionInput'
        flow_id:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          description: >-
            An existing rule's id, as GET /v1/portals/field-automation returns
            it: send it back to keep that rule. Left out: a new rule
          title: Flow Id
        segment:
          additionalProperties: true
          description: >-
            Which accounts: an ACCOUNT segment's conditions tree
            ({"and_conditions": [...]} or {"or_conditions": [...]} of {"field",
            "operation", "value", "entity": 4} filters). A filter "target field
            is empty" is always added, so an account gets one project
          title: Segment
          type: object
      required:
        - segment
        - action
      title: FieldAutomationRuleInput
      type: object
    FieldAutomationRules:
      properties:
        rules:
          description: Every rule in the workspace
          items:
            $ref: '#/components/schemas/FieldAutomationRule'
          title: Rules
          type: array
      required:
        - rules
      title: FieldAutomationRules
      type: object
    FieldAutomationActionInput:
      properties:
        target_field_key:
          description: >-
            The account lookup field that gets the new project: the key of an
            account field of type lookup to projects (GET /v1/fields)
          maxLength: 200
          minLength: 1
          title: Target Field Key
          type: string
        template_id:
          description: >-
            The project template to create the project from: an id from GET
            /v1/project_templates
          maxLength: 200
          minLength: 1
          title: Template Id
          type: string
        trigger_existing:
          default: false
          description: >-
            Also create the project for accounts that already match, not only
            new matches
          title: Trigger Existing
          type: boolean
        type:
          const: create_project
          default: create_project
          description: 'What the rule does: create_project'
          title: Type
          type: string
      required:
        - template_id
        - target_field_key
      title: FieldAutomationActionInput
      type: object
    FieldAutomationRule:
      properties:
        action:
          $ref: '#/components/schemas/FieldAutomationAction'
        flow_id:
          anyOf:
            - type: string
            - type: 'null'
          description: 'The rule''s id: send it back to keep the rule when saving'
          title: Flow Id
        segment:
          additionalProperties: true
          description: >-
            Which accounts: an ACCOUNT segment's conditions tree
            ({"and_conditions": [...]} or {"or_conditions": [...]} of {"field",
            "operation", "value", "entity": 4} filters). A filter "target field
            is empty" is always added, so an account gets one project
          title: Segment
          type: object
      required:
        - flow_id
        - segment
        - action
      title: FieldAutomationRule
      type: object
    FieldAutomationAction:
      properties:
        target_field_key:
          description: >-
            The account lookup field that gets the new project: the key of an
            account field of type lookup to projects (GET /v1/fields)
          title: Target Field Key
          type: string
        template_id:
          description: >-
            The project template to create the project from: an id from GET
            /v1/project_templates
          title: Template Id
          type: string
        trigger_existing:
          description: >-
            Also create the project for accounts that already match, not only
            new matches
          title: Trigger Existing
          type: boolean
        type:
          const: create_project
          description: 'What the rule does: create_project'
          title: Type
          type: string
      required:
        - type
        - template_id
        - target_field_key
        - trigger_existing
      title: FieldAutomationAction
      type: object
  securitySchemes:
    HTTPBearer:
      scheme: bearer
      type: http
      description: >-
        An API key, sent as `Authorization: Bearer stfy_live_…`. See
        [Authentication](/rest-api/authentication) for how to get one and which
        scopes it needs.

````

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