Overview
The Retrieve Report endpoint fetches complete details for a single report, including full client and user information. This endpoint is useful for displaying report details, downloading PDFs, and accessing complete analytics data.Endpoint
Authentication
Requires authentication via NextAuth.js session cookie. Users can only retrieve reports they own.Path Parameters
The unique identifier (CUID) of the report to retrieve.
Response
Success Response (200 OK)
Returns a detailed report object with nested client and user information:Complete report object with all fields
Error Responses
Example Request
Example Response
Use Cases
Display Report Details
Fetch complete report information for display on a report detail page, including all analytics data and AI insights.Download PDF
Use thepdfUrl field to provide a download link or embed the PDF in an iframe.
Regenerate Report
Extract thedata field to regenerate a report with the same configuration and parameters.
Performance Analysis
AnalyzegenerationTimeMs, pdfSize, and AI cost metrics for optimization and billing.
Troubleshooting
Checkstatus, errorMessage, and aiError fields to diagnose failed report generations.
Client Reporting
Combine report data with client and user information for comprehensive client dashboards.Security
This endpoint implements ownership verification:- Requires valid authentication session
- Verifies that the report belongs to the authenticated user
- Returns 404 if report doesn’t exist OR doesn’t belong to the user (preventing enumeration)
Data Persistence
All report data is stored in PostgreSQL with:- JSONB storage for flexible
datafield - Indexed queries on
userId,clientId, andstatus - Cascade deletion when user or client is deleted
- Automatic timestamps for
createdAtandupdatedAt
Related Endpoints
- Generate Report - Create a new report
- List Reports - Get all reports for a user
- Report Status - Check processing status
- Delete Report - Remove a report (see below)
Delete Report
Endpoint
Description
Permanently deletes a report and updates the associated client’s report count.Path Parameters
The unique identifier of the report to delete.
Response
Example Request
Behavior
- Verifies report exists and belongs to authenticated user
- Deletes the report record from database
- Decrements the client’s
totalReportsGeneratedcount - Does NOT delete the PDF file from Vercel Blob (manual cleanup required)