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

# Set Coverage Type Fields

> Sets the fields associated with a company-specific coverage type.

This is a **replace** operation — the provided field list completely
replaces all existing fields for the coverage type. Pass an empty array
to remove all fields. Duplicate field keys in the request are
automatically deduplicated.

Only company-specific coverage types can be modified. Attempting to
modify a global (shared) coverage type returns a 403 error.

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




## OpenAPI

````yaml /openapi/generated-external-api.yaml post /api/external/companies/{companyId}/coverage-types/{coverageTypeId}/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}/coverage-types/{coverageTypeId}/fields:
    post:
      tags:
        - Coverage Types
      summary: Set Coverage Type Fields
      description: |
        Sets the fields associated with a company-specific coverage type.

        This is a **replace** operation — the provided field list completely
        replaces all existing fields for the coverage type. Pass an empty array
        to remove all fields. Duplicate field keys in the request are
        automatically deduplicated.

        Only company-specific coverage types can be modified. Attempting to
        modify a global (shared) coverage type returns a 403 error.

        **Required permission:** `company:update`
      operationId: setCoverageTypeFields
      parameters:
        - $ref: '#/components/parameters/companyId'
        - $ref: '#/components/parameters/coverageTypeId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SetCoverageTypeFieldsRequest'
            examples:
              setFields:
                summary: Set fields on a coverage type
                value:
                  fields:
                    - reportDate
                    - eventDescription
                    - settlementDemand
                    - indemnityPaid
              clearFields:
                summary: Clear all fields
                value:
                  fields: []
      responses:
        '200':
          description: Fields successfully set
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SetCoverageTypeFieldsResponse'
              examples:
                fieldsSet:
                  summary: Fields set successfully
                  value:
                    coverageTypeId: G5_fine_arts
                    coverageTypeName: Fine Arts
                    fieldsSet: 4
                fieldsCleared:
                  summary: All fields cleared
                  value:
                    coverageTypeId: G5_fine_arts
                    coverageTypeName: Fine Arts
                    fieldsSet: 0
        '400':
          description: Bad Request - Unknown field keys
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                unknownFields:
                  summary: Request contains unrecognized field keys
                  value:
                    error:
                      code: UnknownFieldKeys
                      message: 'Unknown field keys: fakeField, anotherFake'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          description: Forbidden - Cannot modify global coverage types
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                globalType:
                  summary: Cannot modify a global coverage type
                  value:
                    error:
                      code: GlobalCoverageTypeNotWritable
                      message: >-
                        Cannot modify fields for global coverage type
                        'general_liability'. Only company-specific coverage
                        types can be modified.
        '404':
          description: Coverage type not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                notFound:
                  summary: Coverage type does not exist
                  value:
                    error:
                      code: CoverageTypeNotFound
                      message: Coverage type 'nonexistent_type' not found
        '500':
          $ref: '#/components/responses/InternalServerError'
components:
  parameters:
    companyId:
      name: companyId
      in: path
      required: true
      schema:
        type: string
        format: uuid
      description: Company identifier
    coverageTypeId:
      name: coverageTypeId
      in: path
      required: true
      schema:
        type: string
      description: Coverage type identifier (e.g., "general_liability")
  schemas:
    SetCoverageTypeFieldsRequest:
      type: object
      required:
        - fields
      properties:
        fields:
          type: array
          items:
            type: string
          description: >
            List of field keys to assign to the coverage type. These must be
            valid

            field keys (e.g., "reportDate", "eventDescription"). Replaces all

            existing fields — pass an empty array to clear all fields.
    SetCoverageTypeFieldsResponse:
      type: object
      properties:
        coverageTypeId:
          type: string
          description: The coverage type identifier
        coverageTypeName:
          type: string
          description: The display name of the coverage type
        fieldsSet:
          type: integer
          description: The number of fields that were set on the coverage type
    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
  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
    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.

````