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

# Preview a OneDrive spreadsheet (xlsx/xls/xlsm/ods/csv/tsv)

> Download a OneDrive tabular file and return a CSV-preview-shaped
response so the frontend wizard can share its rendering logic.

Response body::

    {
      "columns":     [{"name": str, "type": str}, ...],
      "row_count":   int,
      "sample_rows": [ {col: value, ...}, ... ],  # ≤ 10 rows
      "sheet_name":  str | None  # echo of the active sheet (null for csv/tsv)
    }

Error codes:
  - 400 — neither ``item_path`` nor ``item_id`` was provided
  - 401 — user has no OneDrive integration
  - 404 — file does not exist on the drive
  - 415 — file extension not supported
  - 500 — any other parse failure



## OpenAPI

````yaml /api-reference/openapi.json post /api/v1/bi/onedrive/preview
openapi: 3.1.0
info:
  title: apowerb API
  description: REST API of the apowerb agentic framework (open-source edition).
  version: 0.1.2
  license:
    name: MIT
    url: https://github.com/apowerb/apowerb/blob/main/LICENSE
servers:
  - url: https://api.example.com
    description: Your apowerb instance
  - url: http://localhost:8000
    description: Local stack
security: []
paths:
  /api/v1/bi/onedrive/preview:
    post:
      tags:
        - bi-datasets
      summary: Preview a OneDrive spreadsheet (xlsx/xls/xlsm/ods/csv/tsv)
      description: |-
        Download a OneDrive tabular file and return a CSV-preview-shaped
        response so the frontend wizard can share its rendering logic.

        Response body::

            {
              "columns":     [{"name": str, "type": str}, ...],
              "row_count":   int,
              "sample_rows": [ {col: value, ...}, ... ],  # ≤ 10 rows
              "sheet_name":  str | None  # echo of the active sheet (null for csv/tsv)
            }

        Error codes:
          - 400 — neither ``item_path`` nor ``item_id`` was provided
          - 401 — user has no OneDrive integration
          - 404 — file does not exist on the drive
          - 415 — file extension not supported
          - 500 — any other parse failure
      operationId: preview_onedrive_spreadsheet_api_v1_bi_onedrive_preview_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/OnedrivePreviewRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema: {}
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    OnedrivePreviewRequest:
      properties:
        item_path:
          anyOf:
            - type: string
            - type: 'null'
          title: Item Path
        item_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Item Id
        drive_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Drive Id
        sheet_name:
          anyOf:
            - type: string
            - type: integer
            - type: 'null'
          title: Sheet Name
      type: object
      title: OnedrivePreviewRequest
      description: |-
        Body for ``POST /api/v1/bi/onedrive/preview``.

        Either ``item_path`` or ``item_id`` must be provided. When both are
        set, ``item_path`` wins (no Graph round-trip needed). ``sheet_name``
        accepts either a string (sheet title) or an integer (0-based index)
        — ignored for ``.csv`` / ``.tsv`` files.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````

## Related topics

- [Get Excel Preview](/api-reference/onedrive-browser/get-excel-preview.md)
- [List Files](/api-reference/onedrive-browser/list-files.md)
- [Get File Content](/api-reference/onedrive-browser/get-file-content.md)
- [Search Files](/api-reference/onedrive-browser/search-files.md)
- [Integrations](/guides/integrations.md)
