> ## 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 Bordereau to Google Sheets

> Exports the bordereau report to a Google Sheets spreadsheet. Writes the same
transaction-level premium data as the
[List Bordereau Rows](/api-reference/field-model/bordereau/list) endpoint into
a Google Sheets tab.

Provide either `spreadsheetId` (to write into an existing spreadsheet) or
`folderId` (to create a new spreadsheet in that Google Drive folder). When using
`folderId`, the spreadsheet name defaults to
`"{companyShortName}-bordereau-export {UTC timestamp}"` unless overridden via
`spreadsheetName`.

The caller must supply a `googleOAuthToken` with write access to the target
spreadsheet or folder.

To take full control of the column set — selecting, omitting, and
reordering the fixed columns, with field columns interleaved anywhere —
pass `columns`: an ordered array that completely describes the output.

Default limit is 50,000 rows (maximum 50,000).

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




## OpenAPI

````yaml /openapi/generated-external-api.yaml post /api/v1/companies/{companyId}/policies/bordereau/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}/policies/bordereau/export:
    post:
      tags:
        - Field Model Bordereau
      summary: Export Bordereau to Google Sheets
      description: >
        Exports the bordereau report to a Google Sheets spreadsheet. Writes the
        same

        transaction-level premium data as the

        [List Bordereau Rows](/api-reference/field-model/bordereau/list)
        endpoint into

        a Google Sheets tab.


        Provide either `spreadsheetId` (to write into an existing spreadsheet)
        or

        `folderId` (to create a new spreadsheet in that Google Drive folder).
        When using

        `folderId`, the spreadsheet name defaults to

        `"{companyShortName}-bordereau-export {UTC timestamp}"` unless
        overridden via

        `spreadsheetName`.


        The caller must supply a `googleOAuthToken` with write access to the
        target

        spreadsheet or folder.


        To take full control of the column set — selecting, omitting, and

        reordering the fixed columns, with field columns interleaved anywhere —

        pass `columns`: an ordered array that completely describes the output.


        Default limit is 50,000 rows (maximum 50,000).


        **Required permission:** `company.policy:read`
      operationId: exportBordereauGoogleSheets
      parameters:
        - $ref: '#/components/parameters/companyId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - googleOAuthToken
              properties:
                spreadsheetId:
                  type: string
                  description: >
                    ID of an existing Google Sheets spreadsheet to write into.

                    Mutually exclusive with `folderId` — provide one or the
                    other.
                folderId:
                  type: string
                  description: >
                    Google Drive folder ID in which to create a new spreadsheet.

                    Mutually exclusive with `spreadsheetId` — provide one or the
                    other.
                spreadsheetName:
                  type: string
                  description: >
                    Custom name for the created spreadsheet. Only used when
                    `folderId` is

                    provided. Defaults to `"{companyShortName}-bordereau-export
                    {UTC timestamp}"`.
                googleOAuthToken:
                  type: string
                  description: >
                    Google OAuth2 access token with write access to the target
                    spreadsheet

                    or folder.
                periodStart:
                  type: string
                  format: date-time
                  description: >
                    Inclusive lower bound on `transactionTimestamp`. Only
                    transactions at or

                    after this timestamp are included.
                periodEnd:
                  type: string
                  format: date-time
                  description: >
                    Exclusive upper bound on `transactionTimestamp`. Only
                    transactions before

                    this timestamp are included.
                actions:
                  type: array
                  items:
                    type: string
                    enum:
                      - NEW_BUSINESS
                      - ENDORSE
                      - CANCEL
                      - REINSTATE
                      - RENEW
                  description: |
                    Transaction actions to include. Omit to include all actions.
                columns:
                  type: array
                  items:
                    $ref: '#/components/schemas/BordereauColumnSpec'
                  description: >
                    Ordered column specs that COMPLETELY describe the output

                    columns: fixed columns become selectable, omittable, and

                    reorderable, and field columns (`{"kind":"field"}` entries —

                    a dot-path into the policy's field data plus a display
                    header,

                    resolved per row as of the transaction's effective date)

                    interleave anywhere. A path that does not exist in the
                    policy

                    data yields an empty cell. Omit for the default column set

                    (the fixed 12).
                filters:
                  type: array
                  items:
                    $ref: '#/components/schemas/FieldModelV1ListFilter'
                  description: >
                    Policy filters restricting the export to transactions of the

                    policies whose CURRENT segment matches every filter — the
                    filter

                    selects the policies, then all of each matching policy's

                    transactions in the period are included. Omit to include
                    every

                    policy. Same field-filter model as the

                    [Policy List](/api-reference/field-model/policies/list)
                    `filters`

                    parameter.
                sortBy:
                  type: string
                  enum:
                    - policyNumber
                    - primaryInsuredName
                    - effectiveDate
                    - transactionTimestamp
                    - createdAt
                  description: Field to sort results by. Default `transactionTimestamp`.
                sortDirection:
                  type: string
                  enum:
                    - asc
                    - desc
                  default: desc
                  description: Sort direction (default `desc`).
                limit:
                  type: integer
                  minimum: 1
                  maximum: 50000
                  default: 50000
                  description: >-
                    Maximum number of rows to export. Default and maximum
                    50,000.
                offset:
                  type: integer
                  minimum: 0
                  default: 0
                  description: >-
                    Number of rows to skip before starting the export. Default
                    0.
            examples:
              writeToExisting:
                summary: Write into an existing spreadsheet
                value:
                  spreadsheetId: 1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgVE2upms
                  googleOAuthToken: ya29.a0AfH6SMA...
                  periodStart: '2025-01-01T00:00:00.000Z'
                  periodEnd: '2025-07-01T00:00:00.000Z'
              createInFolder:
                summary: Create a new spreadsheet in a folder
                value:
                  folderId: 1a2b3c4d5e6f7g8h9i0j
                  googleOAuthToken: ya29.a0AfH6SMA...
                  spreadsheetName: Q1 2025 Bordereau
                  actions:
                    - NEW_BUSINESS
                    - ENDORSE
              customColumns:
                summary: >-
                  Fully custom ordered column set (fixed keys interleaved with
                  field paths)
                value:
                  folderId: 1a2b3c4d5e6f7g8h9i0j
                  googleOAuthToken: ya29.a0AfH6SMA...
                  columns:
                    - kind: fixed
                      key: policyNumber
                    - kind: field
                      path: policyStatus
                      header: Status
                    - kind: fixed
                      key: effectiveDate
                    - kind: field
                      path: fullTermPricingInfo.taxes
                      header: Taxes
      responses:
        '200':
          description: Bordereau exported to Google Sheets
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ExportBordereauGoogleSheetsResponse'
              examples:
                success:
                  summary: Export completed
                  value:
                    spreadsheetId: 1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgVE2upms
                    spreadsheetUrl: >-
                      https://docs.google.com/spreadsheets/d/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgVE2upms/edit
                    rowCount: 247
        '400':
          description: Invalid request parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                missingDestination:
                  summary: Neither spreadsheetId nor folderId provided
                  value:
                    error:
                      code: missing-destination
                      message: Either spreadsheetId or folderId must be provided
                invalidFieldColumnPath:
                  summary: columns field path is a malformed dot-path
                  value:
                    error:
                      code: ValidationError
                      message: >-
                        path must be a dot-separated field path (no empty,
                        leading, trailing, or doubled segments)
                      userMessages:
                        - >-
                          path must be a dot-separated field path (no empty,
                          leading, trailing, or doubled segments)
                limitExceeded:
                  summary: Limit exceeds maximum
                  value:
                    error:
                      code: INVALID_REQUEST
                      message: limit must not exceed 50000
        '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:
    BordereauColumnSpec:
      description: >
        One column of a fully caller-ordered bordereau — the single
        column-selection

        mechanism on every bordereau endpoint. On the rendered surfaces (CSV

        download, Google Sheets export) an ordered `columns` array is the
        COMPLETE

        column set: the fixed columns become selectable, omittable, and
        reorderable,

        and configured field columns (resolved per row as of the transaction's

        effective date) interleave anywhere. On the typed-JSON list endpoint
        only

        `field` entries are accepted (they select into each row's `fieldColumns`

        map); a `fixed` entry there is rejected with HTTP 400, since the JSON
        rows

        always carry every fixed property.


        Two kinds:

        - `fixed` — one of the 12 built-in transaction-metadata columns,
        addressed by
          key; the column header comes from the built-in registry (e.g.
          `policyNumber` → "Policy Number").
        - `field` — a dot-separated path into the policy's field data plus the
          display `header` for the column. A path absent from the policy data yields
          an empty cell.
      oneOf:
        - type: object
          required:
            - kind
            - key
          properties:
            kind:
              type: string
              enum:
                - fixed
            key:
              type: string
              enum:
                - policyNumber
                - primaryInsuredName
                - transactionAction
                - policyVersion
                - effectiveDate
                - transactionTimestamp
                - policyStartDate
                - policyEndDate
                - createdAt
                - createdBy
                - policyPremium
                - policyPremiumChange
              description: The fixed column to include, by `BordereauRow` property name.
        - type: object
          required:
            - kind
            - path
            - header
          properties:
            kind:
              type: string
              enum:
                - field
            path:
              type: string
              description: >
                Dot-separated path into the policy's field data, resolved per
                row as

                of the transaction's effective date (e.g.

                `fullTermPricingInfo.taxes`, or a per-segment field like

                `policyStatus`).
            header:
              type: string
              description: Display name for this column in the output.
      discriminator:
        propertyName: kind
    FieldModelV1ListFilter:
      description: >-
        Structured per-field filter against FMV1 field data or system columns.
        Each filter names a `fieldReferenceId`, a `fieldType` tag, an
        `operator`, and a `value` (plus `valueTo` for `between` and
        `systemColumn` for `systemUser` / `systemDate`). The set of operators
        and the `value` shape depend on `fieldType`. Pass one or more filters in
        the `filters` query parameter — multiple filters are combined with AND
        semantics.
      oneOf:
        - type: object
          description: Filter against a Text field.
          required:
            - fieldReferenceId
            - fieldType
            - operator
            - value
          properties:
            fieldReferenceId:
              type: string
              description: Reference ID of the field to filter on.
            fieldType:
              type: string
              enum:
                - text
            operator:
              type: string
              enum:
                - matches
                - contains
                - doesNotContain
            value:
              type: string
        - type: object
          description: >-
            Filter against an Option Set field — `value` is the set of allowed
            option keys.
          required:
            - fieldReferenceId
            - fieldType
            - operator
            - value
          properties:
            fieldReferenceId:
              type: string
            fieldType:
              type: string
              enum:
                - optionSet
            operator:
              type: string
              enum:
                - in
            value:
              type: array
              items:
                type: string
        - type: object
          description: Scalar comparison on a Number field.
          required:
            - fieldReferenceId
            - fieldType
            - operator
            - value
          properties:
            fieldReferenceId:
              type: string
            fieldType:
              type: string
              enum:
                - number
            operator:
              type: string
              enum:
                - equals
                - greaterThan
                - lessThan
            value:
              type: number
        - type: object
          description: >-
            Between comparison on a Number field (inclusive `value` through
            `valueTo`).
          required:
            - fieldReferenceId
            - fieldType
            - operator
            - value
            - valueTo
          properties:
            fieldReferenceId:
              type: string
            fieldType:
              type: string
              enum:
                - number
            operator:
              type: string
              enum:
                - between
            value:
              type: number
            valueTo:
              type: number
        - type: object
          description: Filter against a Boolean field.
          required:
            - fieldReferenceId
            - fieldType
            - operator
            - value
          properties:
            fieldReferenceId:
              type: string
            fieldType:
              type: string
              enum:
                - boolean
            operator:
              type: string
              enum:
                - equals
            value:
              type: boolean
        - type: object
          description: Scalar date comparison on a Date field.
          required:
            - fieldReferenceId
            - fieldType
            - operator
            - value
          properties:
            fieldReferenceId:
              type: string
            fieldType:
              type: string
              enum:
                - date
            operator:
              type: string
              enum:
                - 'on'
                - before
                - after
            value:
              type: object
              required:
                - year
                - month
                - day
              properties:
                year:
                  type: integer
                month:
                  type: integer
                day:
                  type: integer
        - type: object
          description: Between date comparison on a Date field.
          required:
            - fieldReferenceId
            - fieldType
            - operator
            - value
            - valueTo
          properties:
            fieldReferenceId:
              type: string
            fieldType:
              type: string
              enum:
                - date
            operator:
              type: string
              enum:
                - between
            value:
              type: object
              required:
                - year
                - month
                - day
              properties:
                year:
                  type: integer
                month:
                  type: integer
                day:
                  type: integer
            valueTo:
              type: object
              required:
                - year
                - month
                - day
              properties:
                year:
                  type: integer
                month:
                  type: integer
                day:
                  type: integer
        - type: object
          description: Scalar comparison on a Currency field.
          required:
            - fieldReferenceId
            - fieldType
            - operator
            - value
          properties:
            fieldReferenceId:
              type: string
            fieldType:
              type: string
              enum:
                - currency
            operator:
              type: string
              enum:
                - equals
                - greaterThan
                - lessThan
            value:
              type: number
        - type: object
          description: Between comparison on a Currency field.
          required:
            - fieldReferenceId
            - fieldType
            - operator
            - value
            - valueTo
          properties:
            fieldReferenceId:
              type: string
            fieldType:
              type: string
              enum:
                - currency
            operator:
              type: string
              enum:
                - between
            value:
              type: number
            valueTo:
              type: number
        - type: object
          description: >-
            Substring match against an Address field (searches across
            street/city/state/zip).
          required:
            - fieldReferenceId
            - fieldType
            - operator
            - value
          properties:
            fieldReferenceId:
              type: string
            fieldType:
              type: string
              enum:
                - address
            operator:
              type: string
              enum:
                - contains
            value:
              type: string
        - type: object
          description: >-
            Filter against a Join field — `value` is the set of allowed
            linked-entity IDs.
          required:
            - fieldReferenceId
            - fieldType
            - operator
            - value
          properties:
            fieldReferenceId:
              type: string
            fieldType:
              type: string
              enum:
                - join
            operator:
              type: string
              enum:
                - in
            value:
              type: array
              items:
                type: string
        - type: object
          description: >-
            Filter against the `createdBy` or `updatedBy` system column. `value`
            is the set of allowed user IDs; use `systemColumn` to pick which
            column.
          required:
            - fieldReferenceId
            - fieldType
            - operator
            - value
            - systemColumn
          properties:
            fieldReferenceId:
              type: string
            fieldType:
              type: string
              enum:
                - systemUser
            operator:
              type: string
              enum:
                - in
            value:
              type: array
              items:
                type: string
            systemColumn:
              type: string
              enum:
                - createdBy
                - updatedBy
        - type: object
          description: >-
            Scalar date comparison against the `createdAt` or `updatedAt` system
            column.
          required:
            - fieldReferenceId
            - fieldType
            - operator
            - value
            - systemColumn
          properties:
            fieldReferenceId:
              type: string
            fieldType:
              type: string
              enum:
                - systemDate
            operator:
              type: string
              enum:
                - 'on'
                - before
                - after
            value:
              type: object
              required:
                - year
                - month
                - day
              properties:
                year:
                  type: integer
                month:
                  type: integer
                day:
                  type: integer
            systemColumn:
              type: string
              enum:
                - createdAt
                - updatedAt
        - type: object
          description: Between date comparison against a system date column.
          required:
            - fieldReferenceId
            - fieldType
            - operator
            - value
            - valueTo
            - systemColumn
          properties:
            fieldReferenceId:
              type: string
            fieldType:
              type: string
              enum:
                - systemDate
            operator:
              type: string
              enum:
                - between
            value:
              type: object
              required:
                - year
                - month
                - day
              properties:
                year:
                  type: integer
                month:
                  type: integer
                day:
                  type: integer
            valueTo:
              type: object
              required:
                - year
                - month
                - day
              properties:
                year:
                  type: integer
                month:
                  type: integer
                day:
                  type: integer
            systemColumn:
              type: string
              enum:
                - createdAt
                - updatedAt
        - type: object
          description: Match an item within a Text List field.
          required:
            - fieldReferenceId
            - fieldType
            - operator
            - value
          properties:
            fieldReferenceId:
              type: string
            fieldType:
              type: string
              enum:
                - textList
            operator:
              type: string
              enum:
                - listIncludes
            value:
              type: string
        - type: object
          description: Match an item within a Number List field.
          required:
            - fieldReferenceId
            - fieldType
            - operator
            - value
          properties:
            fieldReferenceId:
              type: string
            fieldType:
              type: string
              enum:
                - numberList
            operator:
              type: string
              enum:
                - listIncludes
            value:
              type: number
        - type: object
          description: Match items within an Option Set List field.
          required:
            - fieldReferenceId
            - fieldType
            - operator
            - value
          properties:
            fieldReferenceId:
              type: string
            fieldType:
              type: string
              enum:
                - optionSetList
            operator:
              type: string
              enum:
                - listIn
                - listAll
                - listExcludes
            value:
              type: array
              items:
                type: string
        - type: object
          description: Match an item within an Address List field.
          required:
            - fieldReferenceId
            - fieldType
            - operator
            - value
          properties:
            fieldReferenceId:
              type: string
            fieldType:
              type: string
              enum:
                - addressList
            operator:
              type: string
              enum:
                - listIncludes
            value:
              type: string
    ExportBordereauGoogleSheetsResponse:
      type: object
      description: Result of exporting bordereau data to Google Sheets.
      required:
        - spreadsheetId
        - spreadsheetUrl
        - rowCount
      properties:
        spreadsheetId:
          type: string
          description: The Google Sheets spreadsheet ID.
        spreadsheetUrl:
          type: string
          format: uri
          description: Direct URL to the Google Sheets spreadsheet.
        rowCount:
          type: integer
          description: Number of data rows written to the spreadsheet.
    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.

````