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

# Create Configuration Rating Field

> Creates a new rating input field and associates it with the specified entity type
and rating engine revision.

The field definition is stored in `company_fields`, an association is created in
`application_fields`, and the field is added to the rating engine revision's
`config.applicationFields` array.

**Allowed field class names:** `AddressField`, `DateField`, `GroupField`, `InputField`, `LocalCurrency`, `MultiSelectField`, `SelectField`, `StaticField`

The field key cannot be `companyId` (reserved).

**Required permission:** `company:update`




## OpenAPI

````yaml /openapi/generated-external-api.yaml post /api/external/companies/{companyId}/configuration/rating/fields
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/fields:
    post:
      tags:
        - Configuration Rating Fields
      summary: Create Configuration Rating Field
      description: >
        Creates a new rating input field and associates it with the specified
        entity type

        and rating engine revision.


        The field definition is stored in `company_fields`, an association is
        created in

        `application_fields`, and the field is added to the rating engine
        revision's

        `config.applicationFields` array.


        **Allowed field class names:** `AddressField`, `DateField`,
        `GroupField`, `InputField`, `LocalCurrency`, `MultiSelectField`,
        `SelectField`, `StaticField`


        The field key cannot be `companyId` (reserved).


        **Required permission:** `company:update`
      operationId: createConfigurationRatingField
      parameters:
        - $ref: '#/components/parameters/companyId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateConfigurationRatingFieldRequest'
            examples:
              minimalInput:
                summary: Minimal request (required fields only)
                value:
                  fieldDefinition:
                    className: InputField
                    key: baseAnnualRate
                    path: ratingData.baseAnnualRate
                  entityType: policies
                  ratingEngineRevisionId: 550e8400-e29b-41d4-a716-446655440200
                  revisionStrategy: UpdateExistingRevision
              completeInput:
                summary: Complete request with all optional fields
                value:
                  fieldDefinition:
                    className: SelectField
                    key: locationDiscount
                    path: ratingData.locationDiscount
                    label: Location Discount
                    section: Rating Factors
                    required: true
                    fields:
                      options:
                        - label: Urban
                          value: urban
                        - label: Rural
                          value: rural
                    displayCondition: entityData.state != null
                  entityType: dealership
                  ratingEngineRevisionId: 550e8400-e29b-41d4-a716-446655440200
                  revisionStrategy: UpdateExistingRevision
      responses:
        '201':
          description: Configuration rating field created successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: The ID of the created rating field
              examples:
                success:
                  summary: Field created
                  value:
                    id: 550e8400-e29b-41d4-a716-446655440100
        '400':
          description: Bad Request - Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                invalidRevisionStrategy:
                  summary: Invalid revision strategy
                  value:
                    error:
                      code: InvalidProperties
                      message: >-
                        revisionStrategy: Value is not among the list of allowed
                        values
                      details:
                        - field: revisionStrategy
                          message: Value is not among the list of allowed values
        '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 not found
                  value:
                    error:
                      code: NotFoundError
                      message: >-
                        Rating engine revision not found:
                        550e8400-e29b-41d4-a716-446655440200
        '500':
          $ref: '#/components/responses/InternalServerError'
        '501':
          description: Not Implemented - CreateNewRevision is not yet supported
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                notImplemented:
                  summary: CreateNewRevision not yet implemented
                  value:
                    error:
                      code: NotImplemented
                      message: CreateNewRevision is not yet implemented
components:
  parameters:
    companyId:
      name: companyId
      in: path
      required: true
      schema:
        type: string
        format: uuid
      description: Company identifier
  schemas:
    CreateConfigurationRatingFieldRequest:
      type: object
      description: Request body for creating a configuration rating field
      required:
        - fieldDefinition
        - entityType
        - ratingEngineRevisionId
        - revisionStrategy
      properties:
        fieldDefinition:
          $ref: '#/components/schemas/RatingFieldDefinition'
        entityType:
          type: string
          description: >-
            The rating entity type to associate this field with (e.g.,
            "policies", "dealership", or any exposure type)
        ratingEngineRevisionId:
          type: string
          format: uuid
          description: The rating engine revision to add this field to (must already exist)
        revisionStrategy:
          type: string
          enum:
            - UpdateExistingRevision
            - CreateNewRevision
          description: >-
            How to handle the rating engine revision. `UpdateExistingRevision`
            modifies the specified revision in place. `CreateNewRevision` is not
            yet implemented and will return a 501 error.
    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
    RatingFieldDefinition:
      type: object
      description: >-
        Field definition specifying the rating field's type, key, and
        configuration
      required:
        - className
        - key
        - path
      properties:
        className:
          type: string
          enum:
            - AddressField
            - DateField
            - GroupField
            - InputField
            - LocalCurrency
            - MultiSelectField
            - SelectField
            - StaticField
          description: The field type class
        key:
          type: string
          description: Unique field key (cannot be "companyId")
        path:
          type: string
          description: Dot-notation path for the field value in rating data
        label:
          type: string
          description: Human-readable label for the field
        section:
          type: string
          description: UI section grouping for the field
        required:
          type: boolean
          description: Whether the field is required
        fields:
          type: object
          description: Additional sub-field configuration (e.g., select options, format)
        displayCondition:
          type: string
          description: Expression controlling when the field is displayed
        displayConditions:
          type: object
          description: Multiple display conditions for the field
        value:
          type: string
          description: Default value for the field
  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.

````