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

# List Rating Revision Form Logic

> Returns all form-logic rules from a rating engine revision's config JSON
(`config.policyFormLogicConfigs`). Rules are returned as a flat list with
no pagination.

**Filtering:**
- `ruleName` - Filter by rule name (exact match, non-empty)
- `id` - Filter by rule ID (single UUID or array)

**Sorting:**
- `ruleName` (default), `rank`
- Default direction: ascending
- Ties are broken by `id` ascending (or descending when `sortDirection=desc`)

**Required permission:** `company:read`




## OpenAPI

````yaml /openapi/generated-external-api.yaml get /api/external/companies/{companyId}/configuration/rating/form-logic
openapi: 3.0.3
info:
  title: AI Insurance External API
  description: External API for AI Insurance platform
  version: 1.0.0
  contact:
    email: support@aiinsurance.io
servers:
  - url: https://app.aiinsurance.io
    description: Production
security:
  - ApiKeyAuth: []
paths:
  /api/external/companies/{companyId}/configuration/rating/form-logic:
    get:
      tags:
        - Configuration Rating Form Logic
      summary: List Rating Revision Form Logic
      description: >
        Returns all form-logic rules from a rating engine revision's config JSON

        (`config.policyFormLogicConfigs`). Rules are returned as a flat list
        with

        no pagination.


        **Filtering:**

        - `ruleName` - Filter by rule name (exact match, non-empty)

        - `id` - Filter by rule ID (single UUID or array)


        **Sorting:**

        - `ruleName` (default), `rank`

        - Default direction: ascending

        - Ties are broken by `id` ascending (or descending when
        `sortDirection=desc`)


        **Required permission:** `company:read`
      operationId: listRatingRevisionFormLogic
      parameters:
        - $ref: '#/components/parameters/companyId'
        - $ref: '#/components/parameters/ratingEngineRevisionId'
        - name: ruleName
          in: query
          schema:
            type: string
            minLength: 1
          description: >-
            Filter to rules whose `ruleName` matches exactly. Must be non-empty
            when provided.
        - name: id
          in: query
          schema:
            oneOf:
              - type: string
                format: uuid
              - type: array
                items:
                  type: string
                  format: uuid
          description: Filter to a single rule ID or an array of rule IDs
        - $ref: '#/components/parameters/ratingRevisionFormLogicSortBy'
        - $ref: '#/components/parameters/ratingRevisionFormLogicSortDirection'
      responses:
        '200':
          description: List of form-logic rules
          content:
            application/json:
              schema:
                type: object
                required:
                  - items
                properties:
                  items:
                    type: array
                    items:
                      $ref: '#/components/schemas/RatingRevisionFormLogic'
              examples:
                success:
                  summary: Two rules returned
                  value:
                    items:
                      - id: bc6a626e-7a96-49fd-b477-2b18cf189a0d
                        ruleName: Attach Certificate of Insurance
                        rank: 1
                        step: policies
                        shouldAdd:
                          leftKey: form.number
                          operator: '='
                          rightValue: FM-0001
                      - id: 7dc1e6fa-9f03-4b81-8f36-ee9fb5b5fde5
                        ruleName: Attach state-specific endorsement
                        rank: 2
                        step:
                          - policies
                          - quotes
                        shouldAdd:
                          operator: AND
                          conditions:
                            - leftKey: form.number
                              operator: '='
                              rightValue: FM-0002
                            - leftKey: policy.data.state
                              operator: '='
                              rightValue: CA
                emptyList:
                  summary: No rules found
                  value:
                    items: []
        '400':
          description: Bad Request - Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                missingRevisionId:
                  summary: Missing or invalid ratingEngineRevisionId
                  value:
                    error:
                      code: InvalidProperties
                      message: 'ratingEngineRevisionId: The value is not a uuidv4'
                      details:
                        - field: ratingEngineRevisionId
                          message: The value is not a uuidv4
                emptyRuleName:
                  summary: Empty ruleName filter
                  value:
                    error:
                      code: InvalidProperties
                      message: 'ruleName: The value is an empty string'
                      details:
                        - field: ruleName
                          message: The value is an empty string
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          description: Rating engine revision not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                revisionNotFound:
                  summary: Revision does not exist or does not belong to this company
                  value:
                    error:
                      code: NotFoundError
                      message: >-
                        Rating engine revision not found:
                        e06153b8-53c8-4305-bc23-0b67450ec450
        '500':
          $ref: '#/components/responses/InternalServerError'
components:
  parameters:
    companyId:
      name: companyId
      in: path
      required: true
      schema:
        type: string
        format: uuid
      description: Company identifier
    ratingEngineRevisionId:
      name: ratingEngineRevisionId
      in: query
      required: true
      schema:
        type: string
        format: uuid
      description: The rating engine revision ID (must exist and belong to the company)
    ratingRevisionFormLogicSortBy:
      name: sortBy
      in: query
      schema:
        type: string
        enum:
          - ruleName
          - rank
        default: ruleName
      description: Field to sort by (default ruleName)
    ratingRevisionFormLogicSortDirection:
      name: sortDirection
      in: query
      schema:
        type: string
        enum:
          - asc
          - desc
        default: asc
      description: Sort direction (default asc)
  schemas:
    RatingRevisionFormLogic:
      type: object
      description: A form-logic rule stored in a rating engine revision's config JSON.
      required:
        - id
        - ruleName
        - rank
        - step
        - shouldAdd
      properties:
        id:
          type: string
          format: uuid
          description: Server-generated rule ID
        ruleName:
          type: string
          description: Human-readable name for the rule
        rank:
          type: number
          description: >-
            Sort rank controlling the position of attached forms in the output
            list (lower values appear first). Does not control evaluation order.
        step:
          description: >
            Entity-type tag controlling which form-selection contexts the rule's
            output appears in. `"policies"` (policy form selection), `"quotes"`
            (quote form selection), an array of both, or `null` when the rule
            was created without a `step`. Null is represented via `nullable:
            true` on the string branch (OpenAPI 3.0 idiom for a nullable union).
          oneOf:
            - type: string
              nullable: true
              enum:
                - policies
                - quotes
            - type: array
              items:
                type: string
                enum:
                  - policies
                  - quotes
        shouldAdd:
          $ref: '#/components/schemas/ShouldAddExpression'
    ErrorResponse:
      type: object
      description: Standard error response for all external API endpoints
      required:
        - error
      properties:
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
              description: Machine-readable error code
              example: VALIDATION_ERROR
            message:
              type: string
              description: Human-readable error message
              example: 'submissionId: Required field is missing'
            details:
              type: array
              description: Additional details for validation errors (field-level errors)
              items:
                type: object
                properties:
                  field:
                    type: string
                    description: The field that caused the error
                    example: submissionId
                  message:
                    type: string
                    description: Description of the field error
                    example: Required field is missing
    ShouldAddExpression:
      description: >
        A conditional expression that evaluates to true or false during rating
        (of either a quote or a policy). Determines whether a form should be
        attached. Three variants are supported.
      oneOf:
        - title: Branch Expression
          description: Combines child expressions with a logical operator.
          type: object
          required:
            - operator
            - conditions
          properties:
            operator:
              type: string
              enum:
                - AND
                - OR
            conditions:
              type: array
              items:
                $ref: '#/components/schemas/ShouldAddExpression'
        - title: Leaf Expression
          description: >
            Compares the value at `leftKey` against `rightValue` using the given
            operator. `EXISTS` and `NOTEXISTS` check only whether `leftKey`
            resolves to a defined, non-null value (`rightValue` is required
            structurally but ignored). For `SOME`, `rightValue` is a nested
            expression evaluated against each element of the array at `leftKey`;
            the expression returns `false` if `leftKey` does not resolve to an
            array. `IN` and `NOTIN` accept either an array (membership check:
            the `leftKey` value must be an element) or a string (substring
            check: the `leftKey` value must appear within `rightValue`) for
            `rightValue`.
          type: object
          required:
            - leftKey
            - operator
            - rightValue
          properties:
            leftKey:
              type: string
              minLength: 1
              description: >
                Dotted path to a value in the rating context. The context
                includes `policy`, `insured`/`insureds`, `coverage`/`coverages`,
                and `form` (e.g. `policy.data.state`, `form.number`,
                `coverage.coverageTypeId`).
            operator:
              type: string
              enum:
                - '='
                - '!='
                - <
                - <=
                - '>'
                - '>='
                - IN
                - NOTIN
                - EXISTS
                - NOTEXISTS
                - SOME
            rightValue:
              description: >
                Primitive, array, `null`, or nested expression — a nested
                expression only makes sense with `SOME`. `null` is accepted by
                the runtime but cannot be expressed inside an OpenAPI 3.0
                `oneOf`.
              oneOf:
                - type: string
                - type: number
                - type: boolean
                - type: array
                  items: {}
                - $ref: '#/components/schemas/ShouldAddExpression'
        - title: Inverted Leaf Expression
          description: >
            Checks whether a static `leftValue` appears in the array or string
            at `rightKey`. Only the `IN` operator is supported.
          type: object
          required:
            - leftValue
            - operator
            - rightKey
          properties:
            leftValue:
              oneOf:
                - type: string
                - type: number
                - type: boolean
            operator:
              type: string
              enum:
                - IN
            rightKey:
              type: string
              minLength: 1
              description: >
                Dotted path to the array (or string) that `leftValue` is checked
                against. Resolved against the same rating context as `leftKey`.
  responses:
    Unauthorized:
      description: Unauthorized - Invalid or missing API key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            missingApiKey:
              summary: Missing API key
              value:
                error:
                  code: UNAUTHORIZED
                  message: Authorization header is required
            bearerTokenNotAllowed:
              summary: Bearer token used instead of API key
              value:
                error:
                  code: UNAUTHORIZED
                  message: External API endpoints require API key authentication
    Forbidden:
      description: Forbidden - Insufficient permissions
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            insufficientPermissions:
              summary: Insufficient permissions
              value:
                error:
                  code: FORBIDDEN
                  message: Insufficient permissions to perform this action
    InternalServerError:
      description: Internal Server Error - Unexpected error occurred
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            internalError:
              summary: Unexpected server error
              value:
                error:
                  code: INTERNAL_ERROR
                  message: An unexpected error occurred. Please try again later.
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: >-
        API key authentication. Include your API key in the Authorization
        header.

````