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
- Authenticate and fetch the job row
- Record
analyze_started_attimestamp - Download File from Supabase Storage
- Parse Excel into
CellGridobjects (one per Sheet) - Count Sheets and total rows
- Sheet scanning — classify each Sheet into sections via Claude Sonnet (parallel)
- Structure analysis — deep column mapping via Claude Opus (extended thinking)
- Record
analyze_finished_attimestamp - Store full
structure_resultin the job row
Progress Updates
| % | Stage Message |
|---|---|
| 8 | Opening your spreadsheet… |
| 12 | Reading the File… |
| 15 | Found N Sheet(s) with M rows |
| 16 | Scanning N Sheet(s)… |
| 19 | Found N sections across M Sheets |
| 20–38 | Structure analysis milestones |
| 40 | Found: {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:
| Condition | User-facing Message |
|---|---|
| Credit balance issues | AI service temporarily unavailable. Please try again later. |
| Rate limits | Too many requests. Please wait a moment and try again. |
| Overloaded | AI service is busy. Please try again in a minute. |
| Other | Something 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