#
Inspections API
Manage building inspections within the Exit WeWeb Portal system.
#
Endpoints
#
List Inspections
GET /inspections
Returns inspections based on your role:
- Super Admin: All inspections
- Client Admin: All inspections for your client's buildings
- Client Manager: Only assigned inspections
Query Parameters:
select- Columns to return (can include related tables)building_id- Filter by building (eq, in)inspection_type- Filter by type (eq)date_visited- Filter by date (eq, gte, lte)status- Filter by status (eq)order- Sort resultslimit- Limit resultsoffset- Pagination offset
Example Request:
GET /inspections?select=*,buildings(name,city)&building_id=eq.123&date_visited=gte.2025-01-01
Authorization: Bearer YOUR_TOKEN
apikey: YOUR_ANON_KEY
Response:
[
{
"id": 1,
"building_id": 123,
"inspection_type": "annual",
"date_visited": "2025-01-22",
"status": "completed",
"inspector_id": 456,
"notes": "All systems functional",
"buildings": {
"name": "Empire State Building",
"city": "New York"
}
}
]
#
Get Single Inspection
GET /inspections?id=eq.INSPECTION_ID&select=*,buildings(*),inspectors(*),reports_lead(*)
Response:
[
{
"id": 1,
"building_id": 123,
"inspection_type": "annual",
"date_visited": "2025-01-22",
"status": "completed",
"inspector_id": 456,
"notes": "All systems functional",
"created_at": "2025-01-22T10:00:00Z",
"updated_at": "2025-01-22T10:00:00Z",
"buildings": {
"id": 123,
"name": "Empire State Building",
"address": "350 5th Ave",
"city": "New York",
"state": "NY"
},
"inspectors": {
"id": 456,
"name": "John Inspector",
"email": "john@inspectors.com"
},
"reports_lead": [
{
"id": 789,
"gun_id": 101,
"result": "pass"
}
]
}
]
#
Create Inspection
POST /inspections
Content-Type: application/json
Prefer: return=representation
Request Body:
{
"building_id": 123,
"inspection_type": "annual",
"date_visited": "2025-01-22",
"inspector_id": 456,
"status": "scheduled",
"notes": "Annual inspection"
}
Permissions:
- Super Admins can create inspections for any building
- Client Admins can create inspections for their client's buildings
#
Update Inspection
PATCH /inspections?id=eq.INSPECTION_ID
Content-Type: application/json
Prefer: return=representation
Request Body:
{
"status": "completed",
"notes": "Inspection completed successfully",
"date_visited": "2025-01-22"
}
Permissions:
- Super Admins can update any inspection
- Client Admins can update inspections for their client's buildings
#
Delete Inspection
DELETE /inspections?id=eq.INSPECTION_ID
Permissions:
- Super Admins can delete any inspection
- Client Admins can delete inspections for their client's buildings
#
Inspection Object
interface Inspection {
id: number;
building_id: number;
inspection_type: string;
date_visited?: string;
status?: string;
inspector_id?: number;
notes?: string;
created_at: string;
updated_at: string;
// Related objects when using select
buildings?: Building;
inspectors?: Inspector;
reports_lead?: ReportLead[];
}
#
Related Endpoints
#
Get Inspection Dashboard Summary
GET /rpc/get_inspections_dashboard_summary_fast
Content-Type: application/json
{}
Returns aggregated inspection statistics optimized for dashboard display.
#
Get Building Stats Chart
GET /rpc/get_building_stats_chart_fast
Content-Type: application/json
{
"start_date": "2025-01-01",
"end_date": "2025-12-31"
}
#
Assign Inspections to Client Admin
POST /rpc/assign_inspections_to_client_admin
Content-Type: application/json
{
"admin_id": "uuid",
"inspection_ids": [1, 2, 3]
}
#
Assign Inspections to Client Manager
POST /rpc/assign_to_client_manager
Content-Type: application/json
{
"manager_id": "uuid",
"building_ids": [],
"inspection_ids": [1, 2, 3]
}
#
Inspection Types
Common inspection types in the system:
annual- Annual safety inspectionfire- Fire safety inspectionlead- Lead paint inspectionstructural- Structural integrity inspectionemergency- Emergency inspection
#
Inspection Status
Common status values:
scheduled- Inspection scheduledin_progress- Inspection in progresscompleted- Inspection completedfailed- Inspection failedcancelled- Inspection cancelled
#
Access Control
Inspection access is controlled through:
- Building ownership (client relationship)
client_admin_inspection_accesstableclient_manager_inspection_accesstable
Access is hierarchical - if you have access to a building, you typically have access to its inspections.