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

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

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

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




## OpenAPI

````yaml /openapi/generated-external-api.yaml post /api/v1/external/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://app.aiinsurance.io
    description: Production
security:
  - ApiKeyAuth: []
paths:
  /api/v1/external/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.


        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.
                additionalColumns:
                  type: array
                  items:
                    $ref: '#/components/schemas/BordereauAdditionalColumn'
                  description: >
                    FullTerm custom object fields to transpose into additional
                    columns.

                    Each entry maps a field path to a column header.
                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
                  additionalColumns:
                    - path: fullTermPolicyBilling.policyTaxes
                      columnHeader: Policy Taxes
                    - path: carrier
                      columnHeader: Carrier
      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
                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:
    BordereauAdditionalColumn:
      type: object
      description: >
        Maps a field path in the policy's FullTerm custom object data to a named
        column

        in the bordereau output. The `path` is a dot-separated path into the
        segment's

        policy data (e.g. `fullTermPolicyBilling.policyTaxes`). The
        `columnHeader` is

        the display name used as the column header in the output.
      required:
        - path
        - columnHeader
      properties:
        path:
          type: string
          description: |
            Dot-separated path into the segment's policy data object.
            Example: `fullTermPolicyBilling.policyTaxes`
        columnHeader:
          type: string
          description: |
            Display name for this column in the output.
            Example: `Policy Taxes`
    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'
            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.

````