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

# Export Entities

> Export the FULL filtered result set of one entity type as a spreadsheet-style
table — the bulk counterpart of [List Entities](/api-reference/entities/list-entities).
Unlike the paginated list, the export is unpaginated: it returns every record
matching the same `filterText` / `filters`, as flat records keyed by each
column's field `referenceId`.

The response is a JSON envelope — `{ entityType, rowCount, fields, data }` —
where `fields` describes the exported columns (`referenceId`, `type`, `label`)
and `data` is the array of row records. CSV / spreadsheet materialization is a
client concern (render `data` against `fields`); the endpoint itself returns
structured JSON.

By default EVERY configured field of the type is exported (plus the system
`id` / `createdAt` / `updatedAt` columns). Pass `fields` to restrict or reorder
the columns.

Accepts both authentication modes: an API key (`Authorization: <key>`) or an
Auth0 user Bearer token.

**Required permission:** `company.{entity}:list` — the exact key varies by
type (Policy uses `company.policy:export`). See
[Permissions](/api-reference/entities/overview#permissions).




## OpenAPI

````yaml /openapi/generated-external-api.yaml get /api/v1/companies/{companyId}/entities/{entityType}/export
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}/entities/{entityType}/export:
    get:
      tags:
        - Entities
      summary: Export Entities
      description: >
        Export the FULL filtered result set of one entity type as a
        spreadsheet-style

        table — the bulk counterpart of [List
        Entities](/api-reference/entities/list-entities).

        Unlike the paginated list, the export is unpaginated: it returns every
        record

        matching the same `filterText` / `filters`, as flat records keyed by
        each

        column's field `referenceId`.


        The response is a JSON envelope — `{ entityType, rowCount, fields, data
        }` —

        where `fields` describes the exported columns (`referenceId`, `type`,
        `label`)

        and `data` is the array of row records. CSV / spreadsheet
        materialization is a

        client concern (render `data` against `fields`); the endpoint itself
        returns

        structured JSON.


        By default EVERY configured field of the type is exported (plus the
        system

        `id` / `createdAt` / `updatedAt` columns). Pass `fields` to restrict or
        reorder

        the columns.


        Accepts both authentication modes: an API key (`Authorization: <key>`)
        or an

        Auth0 user Bearer token.


        **Required permission:** `company.{entity}:list` — the exact key varies
        by

        type (Policy uses `company.policy:export`). See

        [Permissions](/api-reference/entities/overview#permissions).
      operationId: exportEntities
      parameters:
        - $ref: '#/components/parameters/companyId'
        - $ref: '#/components/parameters/crudEntityType'
        - $ref: '#/components/parameters/filterText'
        - $ref: '#/components/parameters/entityFilters'
        - $ref: '#/components/parameters/sortByField'
        - $ref: '#/components/parameters/sortDirection'
        - name: fields
          in: query
          required: false
          description: >
            JSON-encoded array of explicit export columns, each

            `{ referenceId, type, label }` where `type` is one of
            `field-model-v1`,

            `financial`, or `system`. Omit to export the type's full default
            column

            set (system columns + every configured field).
          schema:
            type: string
          example: >-
            [{"referenceId":"exposureName","type":"field-model-v1","label":"Exposure
            Name"}]
        - name: asOf
          in: query
          required: false
          description: >
            Point-in-time lens (`YYYY-MM-DD`). For Policy it resolves each
            policy to

            the segment in effect on this date; for Event it bounds the
            financial

            export columns. Ignored for entities with neither segments nor
            financials.
          schema:
            type: string
            format: date
          example: '2026-01-01'
      responses:
        '200':
          description: The exported rows as a JSON envelope
          content:
            application/json:
              schema:
                type: object
                properties:
                  entityType:
                    type: string
                    description: >-
                      The canonical entity type that was exported (e.g.
                      `Exposure`).
                  rowCount:
                    type: integer
                    description: Total number of exported records.
                  fields:
                    type: array
                    description: The exported column descriptors, in column order.
                    items:
                      type: object
                      properties:
                        referenceId:
                          type: string
                        type:
                          type: string
                          enum:
                            - field-model-v1
                            - financial
                            - system
                        label:
                          type: string
                  data:
                    type: array
                    description: >-
                      The exported rows — one flat record per entity, keyed by
                      each column's field `referenceId`, with formatted scalar
                      cell values.
                    items:
                      type: object
                      additionalProperties: true
              examples:
                success:
                  summary: Exported exposures
                  value:
                    entityType: Exposure
                    rowCount: 2
                    fields:
                      - referenceId: id
                        type: system
                        label: ID
                      - referenceId: createdAt
                        type: system
                        label: Created At
                      - referenceId: updatedAt
                        type: system
                        label: Updated At
                      - referenceId: exposureName
                        type: field-model-v1
                        label: Exposure Name
                    data:
                      - id: 550e8400-e29b-41d4-a716-446655440301
                        createdAt: '2026-01-15T12:30:00.000Z'
                        updatedAt: '2026-01-15T12:30:00.000Z'
                        exposureName: Acme Corp HQ
                      - id: 550e8400-e29b-41d4-a716-446655440302
                        createdAt: '2026-01-16T09:00:00.000Z'
                        updatedAt: '2026-01-16T09:00:00.000Z'
                        exposureName: Beta Warehouse
                emptyExport:
                  summary: No matching records
                  value:
                    entityType: Exposure
                    rowCount: 0
                    fields:
                      - referenceId: id
                        type: system
                        label: ID
                      - referenceId: exposureName
                        type: field-model-v1
                        label: Exposure Name
                    data: []
        '400':
          description: Bad Request - Invalid entity type or query parameter
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                invalidFiltersJson:
                  summary: Malformed filters JSON
                  value:
                    error:
                      code: INVALID_REQUEST
                      message: filters must be valid JSON
                      userMessages:
                        - filters must be valid JSON
                invalidEntityType:
                  summary: Unknown entity type
                  value:
                    error:
                      code: INVALID_ENTITY_TYPE
                      message: Invalid entity type. Must be a configured entity.
                      userMessages:
                        - Invalid entity type. Must be a configured entity.
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '500':
          $ref: '#/components/responses/InternalServerError'
      security:
        - ApiKeyAuth: []
        - BearerAuth: []
components:
  parameters:
    companyId:
      name: companyId
      in: path
      required: true
      schema:
        type: string
        format: uuid
      description: Company identifier
    crudEntityType:
      name: entityType
      in: path
      required: true
      schema:
        type: string
        enum:
          - event
          - exposure
          - quote
          - submission
          - person
          - organization
      description: >
        Field Model V1 entity type (lowercase kebab-case URL slug). One of the
        six

        CRUD entity types: `event`, `exposure`, `quote`, `submission`, `person`,

        `organization`. `policy` is NOT valid here — Policy has no generic CRUD
        (its

        writes go through the policy transaction endpoints), though it does have
        a

        read-only `/configuration` schema.
    filterText:
      name: filterText
      in: query
      schema:
        type: string
      description: Search across quote number, description, and other text fields
    entityFilters:
      name: filters
      in: query
      schema:
        type: string
      description: >
        JSON-encoded array of field filters applied **server-side** against the

        entity's `fieldModelV1Data`. Use this to look an entity up by a business
        key

        (e.g. a document ID or any configured field value) instead of paging the
        whole

        collection and matching client-side. Complements `filterText`, which
        only

        searches the configured display field.


        Each filter is `{ fieldReferenceId, fieldType, operator, value }` and
        supports

        type-specific operators. Supported field types: `text`, `number`,
        `boolean`,

        `date`, `currency`, `optionSet`, `address`, `join`, `textList`,
        `numberList`,

        `optionSetList`, `addressList`. This is the same filter shape the

        [List Policies](/api-reference/policies/list-policies) endpoint accepts.


        List-cardinality types support operators: `listIncludes` (textList,
        numberList,

        addressList), `listIn`, `listAll`, `listExcludes` (optionSetList).

        The `join` type supports the `in` operator.


        See the Configuration API for available field reference IDs.
      examples:
        textFilter:
          summary: Text field filter (look up by business key)
          value: >-
            [{"fieldReferenceId":"exposureName","fieldType":"text","operator":"matches","value":"Acme
            Corp HQ"}]
        optionSetFilter:
          summary: Option-set field filter
          value: >-
            [{"fieldReferenceId":"exposureType","fieldType":"optionSet","operator":"in","value":["company"]}]
    sortByField:
      name: sortBy
      in: query
      schema:
        type: string
        default: createdAt
      description: >
        Field to sort by. Accepts `createdAt`, `updatedAt`, or any configured
        field

        `referenceId` for the entity type (sorting is config-driven). Default
        `createdAt`.
    sortDirection:
      name: sortDirection
      in: query
      schema:
        type: string
        enum:
          - asc
          - desc
        default: desc
      description: Sort direction (default desc)
  schemas:
    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
    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: UncaughtActionError
                  message: Uncaught error occurred in <actionName>
                  userMessages:
                    - An unexpected error occurred. Please try again later.
  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.
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        User-principal OAuth 2.0 Bearer authentication. Send a user-scoped Auth0
        access token (audience = the app API audience) as `Authorization: Bearer
        <jwt>`. The request resolves to the user's identity and is authorized by
        their Role on the `{companyId}` in the path — the same role-based
        permissions the web app enforces. This is the path the MCP connector
        uses to act on a user's behalf; endpoints that accept it list both
        `BearerAuth` and `ApiKeyAuth`.

````