---
title: "Analyze spreadsheet columns with AI"
method: POST
path: "/upload/analyze"
tags: ["upload"]
---

# Analyze spreadsheet columns with AI

`POST /upload/analyze`

Detects whether a file is ERP or BOM and suggests column mappings based on headers and sample rows.

## Request body

- HandlersAnalyzeColumnsRequest
  - `force_file_type` string — ForceFileType optionally overrides AI auto-detection ("erp" or "bom"). When set, the file is classified as that type and only that type's column mappings are populated. Empty means auto-detect.
  - `headers` string[]
  - `sample_rows` array[]
    - string[]

## Response `200`

OK

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

## Other responses

- `400` — Bad Request
- `401` — Unauthorized
- `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)
