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

# Audit Form Template Smart Tags

> **Read-only** smart-tag audit of a form template's current version:
classifies every `AII…` smart-tag identity in the stored document —
live anchors and dormant `DOCVARIABLE` authoring codes alike — against
the company's current field configuration. Nothing is written.

Use it to find document rot the write-path convergence cannot see:
`dead-hashed` identities (render as raw hex and cannot self-heal),
`legacy-orphan` names (readable but permanently unfilled), and `foreign`
tags the platform cannot bind. A healthy template reports only
`resolvable` and `framework` findings.

**Required permission:** `forms:read`




## OpenAPI

````yaml /openapi/generated-external-api.yaml get /api/v1/companies/{companyId}/forms/template/{number}/smart-tag-audit
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://go.aiinsurance.io
    description: Production
security:
  - ApiKeyAuth: []
paths:
  /api/v1/companies/{companyId}/forms/template/{number}/smart-tag-audit:
    get:
      tags:
        - Forms
      summary: Audit Form Template Smart Tags
      description: |
        **Read-only** smart-tag audit of a form template's current version:
        classifies every `AII…` smart-tag identity in the stored document —
        live anchors and dormant `DOCVARIABLE` authoring codes alike — against
        the company's current field configuration. Nothing is written.

        Use it to find document rot the write-path convergence cannot see:
        `dead-hashed` identities (render as raw hex and cannot self-heal),
        `legacy-orphan` names (readable but permanently unfilled), and `foreign`
        tags the platform cannot bind. A healthy template reports only
        `resolvable` and `framework` findings.

        **Required permission:** `forms:read`
      operationId: auditFormTemplateSmartTags
      parameters:
        - $ref: '#/components/parameters/companyId'
        - name: number
          in: path
          required: true
          schema:
            type: string
          description: The template's stable form number, e.g. `FM-0012`.
      responses:
        '200':
          description: The audit outcome for the template's current version.
          content:
            application/json:
              schema:
                allOf:
                  - type: object
                    required:
                      - number
                    properties:
                      number:
                        type: string
                        description: The audited template's form number.
                  - $ref: '#/components/schemas/Fmv1SmartTagAuditOutcome'
              examples:
                healthy:
                  summary: Only resolvable/framework identities
                  value:
                    number: FM-0012
                    fileKind: docx
                    findings:
                      - identity: AIIFmv1Fld9E5D74B94AC85D40
                        form: anchor
                        classification: resolvable
                    summary:
                      resolvable: 1
                      framework: 0
                      legacyRenameable: 0
                      legacyOrphan: 0
                      deadHashed: 0
                      foreign: 0
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          description: >-
            No live form template carries the given number
            (`form-template-not-found`), or the template's row exists but its
            stored file is missing from storage (`form-file-missing`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: >-
            The stored `.docx` bytes could not be parsed
            (`form-file-unreadable`) — a corrupt or empty object worth
            investigating.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  parameters:
    companyId:
      name: companyId
      in: path
      required: true
      schema:
        type: string
        format: uuid
      description: Company identifier
  schemas:
    Fmv1SmartTagAuditOutcome:
      type: object
      description: >-
        A read-only classification of every `AII…` smart-tag identity a stored
        document carries, judged against the company's current field
        configuration.
      required:
        - fileKind
        - findings
        - summary
      properties:
        fileKind:
          type: string
          enum:
            - docx
            - static
          description: >-
            `static` means a PDF file — it carries no smart-tag anchors, so the
            audit is an empty no-op.
        findings:
          type: array
          description: >-
            One entry per (identity, form) the document carries, deduplicated
            and sorted by identity.
          items:
            type: object
            required:
              - identity
              - form
              - classification
            properties:
              identity:
                type: string
                description: The smart-tag identity, e.g. `AIIFmv1Fld9E5D74B94AC85D40`.
              form:
                type: string
                enum:
                  - anchor
                  - docvariable
                description: >-
                  `anchor` = a live content-control anchor; `docvariable` = a
                  dormant Word authoring field code (converted to an anchor only
                  when a form is generated from the document).
              classification:
                type: string
                enum:
                  - resolvable
                  - framework
                  - legacy-renameable
                  - legacy-orphan
                  - dead-hashed
                  - foreign
                description: >-
                  `resolvable` = a hashed identity the field configuration
                  resolves. `framework` = a fixed framework tag (current date,
                  forms list, financial, …). `legacy-renameable` = a
                  retired-style name whose field exists; the next write
                  converges it. `legacy-orphan` = a retired-style name naming NO
                  configured field — it renders as an unfilled placeholder and
                  nothing converges it. `dead-hashed` = a hashed identity the
                  configuration does not resolve — it renders as raw hex and
                  cannot be repaired by any automatic pass. `foreign` = an
                  `AII…` tag outside the platform's grammar entirely (e.g.
                  another system's tag vocabulary).
        summary:
          type: object
          description: Finding counts per classification.
          required:
            - resolvable
            - framework
            - legacyRenameable
            - legacyOrphan
            - deadHashed
            - foreign
          properties:
            resolvable:
              type: integer
            framework:
              type: integer
            legacyRenameable:
              type: integer
            legacyOrphan:
              type: integer
            deadHashed:
              type: integer
            foreign:
              type: integer
    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'
            userMessages:
              type: array
              description: >-
                Clean, verbatim-displayable messages — one entry per failure,
                free of error-code tags, field paths, and internal noise.
                Suitable for showing to end users as-is.
              items:
                type: string
              example:
                - Exposures of type 'company' require an address
            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: AuthenticationError
                  message: API key authentication required
                  userMessages:
                    - API key authentication required
            invalidApiKey:
              summary: >-
                Invalid API key (e.g. unknown key, or a Bearer token used
                instead of an API key)
              value:
                error:
                  code: AuthenticationError
                  message: Invalid API key
                  userMessages:
                    - Invalid API key
    Forbidden:
      description: Forbidden - Insufficient permissions
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            insufficientPermissions:
              summary: Insufficient permissions
              value:
                error:
                  code: AuthorizationError
                  message: User is not authorized to perform the requested action
                  userMessages:
                    - User is not authorized to perform the requested action
            companyMismatch:
              summary: A valid API key naming another company in the URL
              value:
                error:
                  code: AuthorizationError
                  message: API key is not scoped to the requested company
                  userMessages:
                    - API key is not scoped to the requested company
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: >-
        API key authentication. Send your raw API key as the `Authorization`
        header value with NO scheme prefix — `Authorization: YOUR-API-KEY`. Do
        NOT prefix it with `Bearer ` or `ApiKey `, and do not use an `X-API-Key`
        header; those are not accepted.

````