> ## 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 Smart Tag

> Creates a new smart tag for the company.

**Required fields:**
- `tagName` - Tag identifier (must match pattern /^AII[A-Za-z0-9]+$/)
- `tagDisplayName` - Display name for the tag
- `tagCategories` - Array of categories (e.g., ['quote', 'policy'])

**Optional fields:**
- `tagDescription` - Description of what the tag does
- `tagData` - Custom smart tag configuration (see below)

**Custom Smart Tag Types:**

When creating a custom smart tag, specify the `type` field in `tagData`. Available types include:

*Coverage & Premium Types:*
- `coveragePremium` - Coverage premium amount
- `coveragePremiumTax` - Coverage premium tax
- `coveragePremiumPlusTax` - Coverage premium plus tax
- `specificCoverageProperty` - Specific coverage property
- `specificCoverageLimit` - Specific coverage limit

*Policy Types:*
- `policy` - Policy-level data
- `policyLevelRatingOutput` - Policy-level rating outputs
- `policyList` - List of policies
- `policyTable` - Policy data table
- `firstPolicyCoverage` - First policy coverage
- `firstPolicyLimit` - First policy limit

*Insured Types:*
- `insuredsSchedule` - Schedule of insureds
- `selectedInsured` - Selected insured data
- `primaryInsured` - Primary insured information
- `primaryInsuredCoverageRatingOutput` - Primary insured coverage rating output
- `primaryInsuredCoverageRatingOutputTable` - Primary insured coverage rating output table
- `insuredCoverageRatingOutputsTable` - Insured coverage ratings outputs table
- `summedInsuredCoverageRatings` - Summed insured coverage ratings
- `insuredClaimsTable` - Insured claims table

*Other Types:*
- `dynamic` - Dynamic field lookup (most flexible for custom fields)
- `staticTable` - Static table data
- `stateSpecificDisclosures` - State-specific disclosure text
- `eventFinancialAmount` - Event financial amount

**Allowed tagData fields:**
- `type` - Smart tag type (required if using custom smart tags)
- `fieldId` - Field identifier
- `fieldKey` - Field key
- `fieldLabel` - Field label
- `fieldSection` - Field section
- `entityType` - Entity type
- `outputLabel` - Output label
- `coverageKey` - Coverage key
- `filters` - Filter conditions (array)
- `columns` - Column definitions (array)

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




## OpenAPI

````yaml /openapi/generated-external-api.yaml post /api/external/companies/{companyId}/smart-tags
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}/smart-tags:
    post:
      tags:
        - Smart Tags
      summary: Create Smart Tag
      description: >
        Creates a new smart tag for the company.


        **Required fields:**

        - `tagName` - Tag identifier (must match pattern /^AII[A-Za-z0-9]+$/)

        - `tagDisplayName` - Display name for the tag

        - `tagCategories` - Array of categories (e.g., ['quote', 'policy'])


        **Optional fields:**

        - `tagDescription` - Description of what the tag does

        - `tagData` - Custom smart tag configuration (see below)


        **Custom Smart Tag Types:**


        When creating a custom smart tag, specify the `type` field in `tagData`.
        Available types include:


        *Coverage & Premium Types:*

        - `coveragePremium` - Coverage premium amount

        - `coveragePremiumTax` - Coverage premium tax

        - `coveragePremiumPlusTax` - Coverage premium plus tax

        - `specificCoverageProperty` - Specific coverage property

        - `specificCoverageLimit` - Specific coverage limit


        *Policy Types:*

        - `policy` - Policy-level data

        - `policyLevelRatingOutput` - Policy-level rating outputs

        - `policyList` - List of policies

        - `policyTable` - Policy data table

        - `firstPolicyCoverage` - First policy coverage

        - `firstPolicyLimit` - First policy limit


        *Insured Types:*

        - `insuredsSchedule` - Schedule of insureds

        - `selectedInsured` - Selected insured data

        - `primaryInsured` - Primary insured information

        - `primaryInsuredCoverageRatingOutput` - Primary insured coverage rating
        output

        - `primaryInsuredCoverageRatingOutputTable` - Primary insured coverage
        rating output table

        - `insuredCoverageRatingOutputsTable` - Insured coverage ratings outputs
        table

        - `summedInsuredCoverageRatings` - Summed insured coverage ratings

        - `insuredClaimsTable` - Insured claims table


        *Other Types:*

        - `dynamic` - Dynamic field lookup (most flexible for custom fields)

        - `staticTable` - Static table data

        - `stateSpecificDisclosures` - State-specific disclosure text

        - `eventFinancialAmount` - Event financial amount


        **Allowed tagData fields:**

        - `type` - Smart tag type (required if using custom smart tags)

        - `fieldId` - Field identifier

        - `fieldKey` - Field key

        - `fieldLabel` - Field label

        - `fieldSection` - Field section

        - `entityType` - Entity type

        - `outputLabel` - Output label

        - `coverageKey` - Coverage key

        - `filters` - Filter conditions (array)

        - `columns` - Column definitions (array)


        **Required permission:** `company:update`
      operationId: createSmartTag
      parameters:
        - $ref: '#/components/parameters/companyId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateSmartTagRequest'
            examples:
              minimal:
                summary: Minimal request (required fields only)
                value:
                  tagName: AIIBaseRevenue
                  tagDisplayName: Base Revenue
                  tagCategories:
                    - policy
              complete:
                summary: Complete request with all fields
                value:
                  tagName: AIIBaseRevenuePrimaryInsured
                  tagDisplayName: Base Revenue (Primary Insured)
                  tagDescription: 'Rating Output: base revenue for primary insured'
                  tagCategories:
                    - policy
                    - quote
                  tagData:
                    type: primaryInsuredCoverageRatingOutput
                    outputLabel: Base Revenue
                    coverageKey: ltc_professional_liability_pllabel
      responses:
        '201':
          description: Smart tag created successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: The ID of the created smart tag
              examples:
                success:
                  summary: Smart tag created
                  value:
                    id: 550e8400-e29b-41d4-a716-446655440003
        '400':
          description: Bad Request - Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                missingRequiredField:
                  summary: Missing required field
                  value:
                    error:
                      code: KeyMissing
                      message: 'tagName: Required keys were missing'
                      details:
                        - field: tagName
                          message: Required keys were missing
                invalidTagName:
                  summary: Invalid tagName pattern
                  value:
                    error:
                      code: InvalidTagName
                      message: >-
                        tagName must match pattern /^AII[A-Za-z0-9]+$/ (must
                        start with "AII" followed by alphanumeric characters)
                      details:
                        - field: tagName
                          message: Must match pattern /^AII[A-Za-z0-9]+$/
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '500':
          $ref: '#/components/responses/InternalServerError'
components:
  parameters:
    companyId:
      name: companyId
      in: path
      required: true
      schema:
        type: string
        format: uuid
      description: Company identifier
  schemas:
    CreateSmartTagRequest:
      type: object
      description: Request body for creating a smart tag
      required:
        - tagName
        - tagDisplayName
        - tagCategories
      properties:
        tagName:
          type: string
          description: |
            Tag identifier (required). Must match pattern /^AII[A-Za-z0-9]+$/.
            Must start with "AII" followed by alphanumeric characters only.
          pattern: ^AII[A-Za-z0-9]+$
          example: AIIMyCustomTag
        tagDisplayName:
          type: string
          description: Display name for the tag (required)
          example: My Custom Tag
        tagDescription:
          type: string
          description: Description of what the tag does
        tagCategories:
          type: array
          items:
            type: string
            enum:
              - policy
              - policy-insured
              - quote
              - quote-insured
              - insured
              - event
              - payee
          description: >
            Categories the tag can be used in. Determines which contexts the tag
            is available in:

            - `policy` - Adhoc generated forms for a policy

            - `quote` - Forms generated during quote wizard

            - `policy-insured` - Adhoc generated forms with both a policy and an
            insured

            - `quote-insured` - Forms generated during quote wizard for one
            insured

            - `insured` - Adhoc generated forms with an insured and related data

            - `event` - Adhoc generated forms with an event and related data

            - `payee` - Adhoc generated forms for a payee with payment and
            invoice data
          example:
            - quote
            - policy
        tagData:
          type: object
          description: >
            Arbitrary JSON metadata. Can contain any valid JSON structure.

            Common uses: storing type classifications, configuration, or custom
            properties.
          example:
            type: text
    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
    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.

````