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

# Get field rules

> **Required scope:** `form:read`.



## OpenAPI

````yaml /api-reference/openapi.yaml get /api/v1/forms/{form_token}/rules
openapi: 3.0.1
info:
  title: FormHug API V1
  version: v1
  description: |
    FormHug public REST API. All request/response keys are snake_case.

    Successful response:

    ```json
    {
      "data": { ... }
    }
    ```

    Paginated response:

    ```json
    {
      "data": [ ... ],
      "pagination": {
        "total": 123,
        "next_cursor": "NQ=="
      }
    }
    ```

    Error response:

    ```json
    {
      "error": "Human-readable message",
      "error_details": [
        { "attribute": "field_name", "message": "specific error" }
      ]
    }
    ```

    `error_details` only appears for model validation failures.
servers:
  - url: https://formhug.ai
security: []
tags:
  - name: Forms
    description: Form CRUD
  - name: Attachments
    description: >-
      2-step upload for form-element images (theme, rich-text, or field-element
      images). Prepare returns an `upload_id`; consume it in a theme update,
      attachment_commitments, or the form `fields` payload depending on purpose.
  - name: Entries
    description: Entries collected by a form owned by the current user
  - name: Folders
    description: Folder CRUD
  - name: Participated Forms
    description: Forms the current user has submitted to (does not own)
  - name: Published Form Entries
    description: Submit entries to a published form
  - name: Published Forms
    description: Read a published form's public structure for filling
  - name: Entry Attachments
    description: >-
      2-step upload for `attachment` field submissions. Prepare returns an
      `upload_id`; submit it under the attachment field in `field_values` when
      creating the entry.
  - name: Me
    description: Current authenticated user
  - name: Webhooks
    description: Webhook integrations attached to a form
  - name: Form Themes
    description: Read and update a form's visual theme
  - name: Form Settings
    description: >-
      Per-form settings — submission flow, availability, access control,
      presentation
  - name: Field Rules
    description: >-
      Read and replace a form's conditional field-display and post-submission
      redirect rules.
  - name: OAuth
    description: OAuth 2.0 PKCE token issuance and revocation
paths:
  /api/v1/forms/{form_token}/rules:
    parameters:
      - name: form_token
        in: path
        description: Form token
        required: true
        schema:
          type: string
    get:
      tags:
        - Field Rules
      summary: Get field rules
      description: '**Required scope:** `form:read`.'
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: '#/components/schemas/FieldRulesEnvelope'
        '404':
          description: Form not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
      security:
        - PersonalAccessToken:
            - form:read
components:
  schemas:
    FieldRulesEnvelope:
      type: object
      required:
        - field_rules
        - redirect_rules
      properties:
        field_rules:
          type: array
          items:
            $ref: '#/components/schemas/FieldRuleRead'
        redirect_rules:
          type: array
          items:
            $ref: '#/components/schemas/RedirectRuleRead'
    ErrorEnvelope:
      type: object
      required:
        - error
      properties:
        error:
          type: string
          description: Error message
    FieldRuleRead:
      type: object
      required:
        - operator
        - targets_display_mode
        - rule_sets
      properties:
        operator:
          type: string
          enum:
            - or
            - and
          description: How the rule's conditions combine.
        targets_display_mode:
          type: string
          enum:
            - show
            - abort
          description: >-
            `show` reveals the target fields when conditions match; `abort`
            stops showing the rest of the form.
        targets:
          type: array
          items:
            type: string
          description: >-
            api_codes of the fields revealed when conditions match. Present only
            for `show` rules; each must be positioned after every trigger.
        rule_sets:
          type: array
          items:
            $ref: '#/components/schemas/RuleCondition'
    RedirectRuleRead:
      type: object
      required:
        - operator
        - redirect_url
        - rule_sets
      properties:
        operator:
          type: string
          enum:
            - or
            - and
        redirect_url:
          type: string
          description: URL to redirect to after submission when conditions match.
        rule_sets:
          type: array
          items:
            $ref: '#/components/schemas/RuleCondition'
    RuleCondition:
      type: object
      required:
        - trigger
        - comparator
        - condition
      properties:
        trigger:
          type: string
          description: >-
            api_code of the field whose value is tested. The field must be one
            that supports rules; the comparator must be one the field type
            allows (single/multi-choice fields: `equal`/`none_in`; text fields:
            `like`/`not_like`; rating and scale fields: `between`; cascading
            dropdown: `equal`). To test a sub-field of an associated form, use
            the combined api_code
            `<association_field_api_code>_associated_<sub_field_api_code>`; the
            comparator and condition then follow the sub-field type.
        comparator:
          type: string
          enum:
            - equal
            - none_in
            - between
            - like
            - not_like
          description: >-
            How the trigger value is matched. `equal` matches when the value is
            any of the given choices; `none_in` is its negation; `between`
            expects a `[min, max]` numeric range in `condition`;
            `like`/`not_like` do substring matching on text.
        condition:
          description: >-
            Choice api_code (or array of api_codes) for `equal`/`none_in`;
            `[min, max]` numbers for `between`; a substring for
            `like`/`not_like`. For a cascading dropdown trigger, a single
            leaf-choice api_code (the level and parent path are resolved
            automatically).
          oneOf:
            - type: string
            - type: number
            - type: array
              items: {}
  securitySchemes:
    PersonalAccessToken:
      type: http
      scheme: bearer
      bearerFormat: PAT
      description: >
        Personal Access Token prefixed with `fh_`. Sent as `Authorization:
        Bearer fh_xxx`.

        The scope required by each endpoint is listed in that endpoint's
        description.

````