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

# List Parse Runs

> List a company's parse runs, newest-first and paginated. Use this to poll
the outcome of a parse you kicked with **Trigger Parse**.

A run record is one **logical parse run** — the `extract` stage and the
`create_<flow>_v<N>` parse stage of a single trigger, reported together:

- `runId` is the logical run's stable id.
- `flow` is the flow the run implements (`submission` or `policy`).
- `target` is the `{ kind, id }` file or folder the run parsed.
- `status` is the overall run status, collapsed to one of `running`,
  `succeeded`, or `failed` (every internal `failed_*` retry state reads as
  `failed`; a run that will still be retried reports `failed` here — check
  `stages` for `retrying` detail. A run holding for a precondition reads as
  `running`, because it has not failed).
- `stages` breaks the run into its `extract` and `parse` stages, each with
  its own `status` (including the distinct `retrying`, the not-yet-started
  `pending`, and `waiting` — holding for a precondition, not a failure),
  `attempts`, optional `error`, and `finishedAt`.
- `createdEntities` lists the entities the run created (`entityType` +
  `entityId`); an entity deleted after the run reports `deleted: true`.
- `extractionReady` says whether the run's merged extraction artifact was
  persisted.
- `error` is present only on a run that recorded a failure message.

Runs that predate run grouping are reported as **legacy** records
(`legacy: true`): one record per pipeline task, `target: null`, no
`stages`/`createdEntities`.

Pagination uses the standard 1-based `page` / `pageSize` query params.

**Required permission:** `company.file:read`




## OpenAPI

````yaml /openapi/generated-external-api.yaml get /api/v1/companies/{companyId}/files/parse-runs
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}/files/parse-runs:
    get:
      tags:
        - Submission Parsing
      summary: List Parse Runs
      description: >
        List a company's parse runs, newest-first and paginated. Use this to
        poll

        the outcome of a parse you kicked with **Trigger Parse**.


        A run record is one **logical parse run** — the `extract` stage and the

        `create_<flow>_v<N>` parse stage of a single trigger, reported together:


        - `runId` is the logical run's stable id.

        - `flow` is the flow the run implements (`submission` or `policy`).

        - `target` is the `{ kind, id }` file or folder the run parsed.

        - `status` is the overall run status, collapsed to one of `running`,
          `succeeded`, or `failed` (every internal `failed_*` retry state reads as
          `failed`; a run that will still be retried reports `failed` here — check
          `stages` for `retrying` detail. A run holding for a precondition reads as
          `running`, because it has not failed).
        - `stages` breaks the run into its `extract` and `parse` stages, each
        with
          its own `status` (including the distinct `retrying`, the not-yet-started
          `pending`, and `waiting` — holding for a precondition, not a failure),
          `attempts`, optional `error`, and `finishedAt`.
        - `createdEntities` lists the entities the run created (`entityType` +
          `entityId`); an entity deleted after the run reports `deleted: true`.
        - `extractionReady` says whether the run's merged extraction artifact
        was
          persisted.
        - `error` is present only on a run that recorded a failure message.


        Runs that predate run grouping are reported as **legacy** records

        (`legacy: true`): one record per pipeline task, `target: null`, no

        `stages`/`createdEntities`.


        Pagination uses the standard 1-based `page` / `pageSize` query params.


        **Required permission:** `company.file:read`
      operationId: listCompanyFileParseRuns
      parameters:
        - $ref: '#/components/parameters/companyId'
        - name: page
          in: query
          required: false
          description: 1-based page number. Defaults to the first page.
          schema:
            type: integer
            minimum: 1
        - name: pageSize
          in: query
          required: false
          description: Number of runs per page. Defaults to the API page size.
          schema:
            type: integer
            minimum: 1
      responses:
        '200':
          description: A page of parse runs, newest-first
          content:
            application/json:
              schema:
                type: object
                properties:
                  items:
                    type: array
                    items:
                      type: object
                      properties:
                        runId:
                          type: string
                          description: Stable logical-run identifier.
                        flow:
                          type: string
                          nullable: true
                          enum:
                            - submission
                            - policy
                          description: >-
                            The flow the run implements. `null` only on a legacy
                            `extract` record (the extract stage is
                            flow-agnostic).
                        target:
                          type: object
                          nullable: true
                          description: >-
                            The file or folder the run parsed. `null` on legacy
                            records (the target was not persisted before run
                            grouping).
                          properties:
                            kind:
                              type: string
                              enum:
                                - file
                                - folder
                            id:
                              type: string
                              description: The file or folder id.
                        parseTaskName:
                          type: string
                          enum:
                            - extract
                            - create_submission_v1
                            - create_policy_v1
                          description: >-
                            The run's parse-stage task name; on a legacy record,
                            that row's own task name (possibly `extract`).
                        status:
                          type: string
                          enum:
                            - running
                            - succeeded
                            - failed
                          description: >-
                            Caller-facing overall status. The internal
                            `failed_*` retry states all collapse to `failed`;
                            per-stage `retrying` detail is in `stages`.
                        attempts:
                          type: integer
                          description: >-
                            The active stage's attempt count (the parse stage
                            once claimed, else the extract stage).
                        error:
                          type: string
                          description: >-
                            Failure message from the failing stage. Present only
                            for a run that recorded one.
                        createdAt:
                          type: string
                          format: date-time
                          description: When the run was created.
                        finishedAt:
                          type: string
                          format: date-time
                          nullable: true
                          description: >-
                            When the run reached a terminal status, or `null`
                            while still in flight.
                        legacy:
                          type: boolean
                          description: >-
                            Present (`true`) only on records that predate run
                            grouping — one record per pipeline task, `target:
                            null`, no `stages`.
                        stages:
                          type: object
                          description: >-
                            Per-stage detail for the run's `extract` and `parse`
                            stages. Absent on legacy records.
                          properties:
                            extract:
                              $ref: '#/components/schemas/ParseRunStage'
                            parse:
                              $ref: '#/components/schemas/ParseRunStage'
                        createdEntities:
                          type: array
                          description: >-
                            Entities the run created (submission, quote, …).
                            Absent on legacy records; empty until the parse
                            stage creates entities.
                          items:
                            type: object
                            properties:
                              entityType:
                                type: string
                                description: >-
                                  The entity type slug (e.g. `submission`,
                                  `quote`).
                              entityId:
                                type: string
                              deleted:
                                type: boolean
                                description: >-
                                  `true` when the entity was deleted after the
                                  run created it.
                        createdCount:
                          type: integer
                          description: >-
                            How many enumerated records the run's per-record
                            tolerant create step successfully created. Present
                            only when the run recorded a per-record outcome (a
                            completed run of a flow that enumerates records) —
                            absent on legacy records, failed runs, and flows
                            without record-level enumeration.
                        failedCount:
                          type: integer
                          description: >-
                            How many enumerated records the run's per-record
                            tolerant create step skipped after their create was
                            rejected. Present under the same conditions as
                            `createdCount`; `0` means every record imported.
                        extractionReady:
                          type: boolean
                          description: >-
                            Whether the run's merged extraction artifact was
                            persisted. Absent on legacy records.
                        rerunOfRunId:
                          type: string
                          nullable: true
                          description: >-
                            The prior run this one re-ran, or `null` for a first
                            run. Absent on legacy records.
                        reusedExtractOfRunId:
                          type: string
                          nullable: true
                          description: >-
                            The prior run whose extraction this one reused, or
                            `null`. Absent on legacy records.
                  totalCount:
                    type: integer
                    description: >-
                      Total number of parse runs for the company, ignoring
                      pagination.
              examples:
                success:
                  summary: >-
                    One succeeded run with created entities and one legacy
                    record
                  value:
                    items:
                      - runId: 0f204eac-17e5-42bc-93b1-0dd2aea57baa
                        flow: submission
                        target:
                          kind: folder
                          id: 3c93ad46-9d7c-4f5a-b4de-9f0f9a4f6a2e
                        parseTaskName: create_submission_v1
                        status: succeeded
                        attempts: 1
                        createdAt: '2026-06-30T12:01:30.000Z'
                        finishedAt: '2026-06-30T12:03:05.000Z'
                        stages:
                          extract:
                            status: succeeded
                            attempts: 1
                            finishedAt: '2026-06-30T12:02:10.000Z'
                          parse:
                            status: succeeded
                            attempts: 1
                            finishedAt: '2026-06-30T12:03:05.000Z'
                        createdEntities:
                          - entityType: submission
                            entityId: 2b8dc3a1-51de-4f92-a3a0-1f5ba3a9a111
                            deleted: false
                          - entityType: quote
                            entityId: 61b3c2d4-7a90-4a1c-8321-9adf5f2f2222
                            deleted: false
                        extractionReady: true
                        rerunOfRunId: null
                        reusedExtractOfRunId: null
                      - runId: 994bfc11-8ff3-485a-89ff-7839c9bb6101
                        flow: null
                        target: null
                        parseTaskName: extract
                        status: succeeded
                        attempts: 1
                        createdAt: '2026-06-30T11:01:10.000Z'
                        finishedAt: '2026-06-30T11:01:25.000Z'
                        legacy: true
                    totalCount: 2
        '400':
          description: Bad Request — a non-integer or non-positive `page` / `pageSize`
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                badPage:
                  summary: Invalid page
                  value:
                    error:
                      code: BadRequest
                      message: 'Invalid page: must be a positive integer'
        '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:
    ParseRunStage:
      type: object
      description: One pipeline stage (`extract` or `parse`) of a logical parse run.
      properties:
        status:
          type: string
          enum:
            - pending
            - running
            - waiting
            - retrying
            - succeeded
            - failed
          description: >-
            The stage's own status. `pending` means the stage has not started
            yet; `waiting` means the stage is holding for a precondition (for
            example a source file still being virus-scanned) and has NOT failed;
            `retrying` means the last attempt failed but the stage WILL run
            again (distinct from terminal `failed`). `waiting` and `retrying`
            are both non-terminal — keep polling.
        attempts:
          type: integer
          description: 1-based attempt count; `0` while the stage is still `pending`.
        error:
          type: string
          description: >-
            The stage's failure message. Present only when the stage recorded
            one.
        finishedAt:
          type: string
          format: date-time
          nullable: true
          description: When the stage reached a terminal status, or `null` otherwise.
    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.

````