Skip to Content
API ReferencePOST /api/analyze

POST /api/analyze

Downloads the uploaded File, reads all Sheets, scans for Tables, and performs deep structure analysis to identify column mappings and data boundaries.

Request

{ "job_id": "uuid-string" }

Headers: Authorization: Bearer <token>

Max duration: 120 seconds (Vercel serverless timeout)

Processing Steps

  1. Authenticate and fetch the job row
  2. Record analyze_started_at timestamp
  3. Download File from Supabase Storage
  4. Parse Excel into CellGrid objects (one per Sheet)
  5. Count Sheets and total rows
  6. Sheet scanning — classify each Sheet into sections via Claude Sonnet (parallel)
  7. Structure analysis — deep column mapping via Claude Opus (extended thinking)
  8. Record analyze_finished_at timestamp
  9. Store full structure_result in the job row

Progress Updates

%Stage Message
8Opening your spreadsheet…
12Reading the File…
15Found N Sheet(s) with M rows
16Scanning N Sheet(s)
19Found N sections across M Sheets
20–38Structure analysis milestones
40Found: {property_name} ({report_date}) — or “Got the layout figured out” if no property name detected

Response

Success (200):

{ "job_id": "uuid-string", "property_name": "Montrose at Vintage Park", "report_date": "2025-02-10", "data_sheet": "Sheet1" }

Error Sanitization

Raw error messages are sanitized before returning:

ConditionUser-facing Message
Credit balance issuesAI service temporarily unavailable. Please try again later.
Rate limitsToo many requests. Please wait a moment and try again.
OverloadedAI service is busy. Please try again in a minute.
OtherSomething went wrong. Please try again.

On failure, the job status is set to failed with the sanitized message.

Abort Handling

If the client aborts the request, the route catches the AbortError and returns a 499 response with { "error": "Cancelled" }. The job status is not updated on abort — it remains in analyzing state. Only non-abort errors update the job to failed.

Last updated on