---
title: "Analyze a data-source spreadsheet"
method: POST
path: "/datasources/analyze-file"
tags: ["datasources"]
---

# Analyze a data-source spreadsheet

`POST /datasources/analyze-file`

Reads a single data-source spreadsheet (xlsx/xlsm/xls/csv/tsv) from storage and returns the AI-detected file type and suggested column mapping.

## Request body

- ModelsAnalyzeFileRequest
  - `force_file_type` string
  - `key` string

## Response `200`

OK

- HandlersAnalyzeFileResponse
  - `analysis` ServicesUploadAnalysisResult
    - `columns` ServicesUploadColumnMapping
      - `attributes` ModelsERPAttributeMapping[] — Attributes holds every remaining ERP column (dynamic import): each spreadsheet column that is NOT one of the first-class ERP fields above, so it can be labeled by the AI, edited by the user, and preserved.
        - `label` string — human-friendly display name (AI-suggested, user-editable)
        - `source_column` string — exact header text in the uploaded file == metadata key
        - `type` string — "string" | "number" (display/format hint)
      - `description_column` string
      - `description_columns` string[]
      - `find_no_column` string — FindNoColumn is the column containing Find Number (position within parent). Used by teamcenter_traversal.
      - `hierarchy_pattern` string — HierarchyPattern is a regex to extract the level from the hierarchy source column. Used when hierarchy_type is "embedded_level" or "dot_notation".
      - `hierarchy_source_column` string — HierarchySourceColumn is the column that contains the embedded hierarchy info.
      - `hierarchy_type` string — Hierarchy detection HierarchyType: "none", "level_column", "embedded_level", "parent_reference", "dot_notation", "teamcenter_traversal"
      - `level_column` string
      - `manufacturer_column` string
      - `parent_column` string
      - `part_number_column` string — BOM-specific columns
      - `primary_identifier_column` string — ERP-specific columns
      - `purchase_price_column` string
      - `purchase_quantity_column` string
      - `quantity_column` string
      - `secondary_identifier_column` string
      - `supplier_name_column` string
      - `supplier_number_column` string
      - `unit_column` string
    - `confidence` number — Confidence is a value between 0 and 1 indicating how confident the AI is.
    - `file_type` string — FileType is "erp", "bom", or "unknown".
    - `reasoning` string — Reasoning explains why the AI chose this classification.
    - `suggested_levels` integer[] — SuggestedLevels contains the computed hierarchy levels for sample rows when hierarchy_type is "teamcenter_traversal". Index aligns with sample_rows.
  - `headers` string[]

## Other responses

- `400` — Bad Request
- `401` — Unauthorized
- `404` — Not Found
- `422` — Unprocessable Entity
- `500` — Internal Server Error

---

[API](https://skmtc.net/resourcly/apis/resourcly-api.md) · [All operations](https://skmtc.net/resourcly/apis/resourcly-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/resourcly/resourcly-api/revisions/7f97d8cd0f1e/schema)
