API Contract
This document acts as the API specification registry for the microservices in Helix.
API Standards
- All APIs must follow standard RESTful or gRPC practices.
- JSON payload formats must be validated using OpenAPI schemas.
- Authenticators must use JWT tokens.
Geo-Intelligence (Spatial) API Endpoints
The Spatial Intelligence service exposes geo-referencing, geocoding, boundary polygons, and Google Places proxy operations.
1. Search Nearby Civic Assets (Places Proxy)
- Endpoint:
GET /governance/spatial/places - Description: Queries nearby assets (schools, hospitals, parks) using the OpenStreetMap Overpass API. If the provider is offline, it falls back to realistic localized mock data.
- Parameters:
latitude(float, required): Center latitude.longitude(float, required): Center longitude.radius(int, optional): Search radius in meters (default: 1500).type(str, optional): Place type filters (e.g.,school,hospital,park, default:school).- Response Sample:
2. Geocode Address to Coordinates
- Endpoint:
GET /governance/spatial/geocode - Description: Geocodes text addresses to coordinates.
- Parameters:
address(str, required): The query address string.- Response Sample:
3. Reverse Geocode Coordinates to Address
- Endpoint:
GET /governance/spatial/reverse-geocode - Description: Converts coordinates to a formatted address.
- Parameters:
latitude(float, required): Target latitude.longitude(float, required): Target longitude.- Response Sample:
4. Filter Issues Geographically (Spatial Query)
- Endpoint:
GET /governance/spatial/query - Description: Query and filter issues by distance radius or bounding box, including logical status or category matching.
- Parameters:
lat/lng(float, optional): Coordinates of search center.radius_km(float, optional): Great-circle radius to search in.min_lat/min_lng/max_lat/max_lng(float, optional): Bounding box coordinates.category(str, optional): Filter by issue category.status(str, optional): Filter by issue status.- Response Sample:
Explainable AI Decision Engine API Endpoints
The Governance service exposes explainable structured Decision Briefs for pending tickets.
1. Compile Issue Decision Brief
- Endpoint:
GET /governance/issues/{issue_id}/decision-brief - Description: Compiles and retrieves a structured decision brief containing geographical context, duplicate checks, matched regulatory policies/schemes, alternative option evaluations, and hybrid scoring metrics.
- Parameters:
issue_id(str, required): The target issue ID.- Response Sample:
{ "problem": { "id": "mock-issue-101", "title": "Water Leakage near Government School", "description": "Large water main leak causing road erosion.", "category": "Water Supply & Sanitation", "location": { "latitude": 12.9755, "longitude": 77.5955 }, "status": "TRIAGED", "priority": "HIGH" }, "evidence": [ "18 duplicate complaints reported in the immediate coordinate buffer.", "Active constituency hotspot status triggered for this georeference coordinate.", "2 civic assets located within the buffer impact zone: Ward 12 Playground Garbage Bin Terminal, Govt School Block A." ], "nearby_assets": [ { "id": "asset-ref-0", "name": "Govt School Block A", "type": "school", "distance_meters": 140 } ], "applicable_policies": [ { "name": "Sanitation Waste Management Regulation 2024", "code": "REG-2024-09" } ], "applicable_schemes": [ { "name": "Swachh Bharat Abhiyan Subsidy", "subsidy_ratio": 0.6 } ], "impact_summary": { "affected_population": 4320, "urgency_score": 0.9, "severity_level": "HIGH" }, "alternative_actions": [ { "option_name": "Spot Patch Repair", "description": "Localized clearing and temporary segment sealing.", "estimated_cost": "₹2.5 Lakhs", "sla": "24 Hours", "durability": "Low (estimated lifespan < 6 months)", "risks": "High risk of recurring leak blockages under high water pressure.", "feasibility": "High", "is_recommended": false }, { "option_name": "Capital Pipeline Trunk Reconstruction", "description": "Full replacement of the damaged structural main trunk.", "estimated_cost": "₹18.0 Lakhs", "sla": "45 Days", "durability": "High (estimated lifespan 15+ years)", "risks": "Higher budget requirement; requires brief localized traffic detour.", "feasibility": "Medium-High", "is_recommended": true } ], "recommendation": { "suggested_department": "Municipal Sanitation Department", "recommended_action": "Dispatch Emergency Sanitation Leak Clearing Crew", "estimated_cost": "₹2.5 Lakhs", "sla": "24 Hours" }, "reasoning": [ "Jal Jeevan Mission guidelines suggest complete rebuilds for trunk failures exceeding 15 active tickets.", "Proximity to Govt School Block A (within 140m) increases priority to prevent public health hazards." ], "confidence": 94, "follow_up_actions": [ "Initiate structural design validation for the pipeline trunk.", "Notify school administration of the scheduled construction window." ] }
2. Retrieve Canonical Issue Lifecycle Timeline
- Endpoint:
GET /governance/issues/{issue_id}/timeline - Description: Compiles and retrieves the canonical progress timeline and audit trail for an issue. Entries are dynamically filtered and formatted based on user role-based permissions.
- Parameters:
issue_id(str, required): The target issue ID.role(str, optional): User role filter (citizen,officer,administrator, default:citizen).- Response Sample (role=citizen):
{ "issue_id": "mock-issue-101", "current_stage": "AI Verification & Grounding", "progress": 10, "estimated_next_action": "AI multi-agent verification & duplicate mapping scan.", "estimated_remaining_sla_hours": 48, "timeline": [ { "id": "tl-rep-uuid", "timestamp": "2026-07-07T12:00:00Z", "actor": "Citizen", "actor_type": "citizen", "action": "REPORT_SUBMITTED", "description": "Your complaint has been successfully registered.", "status": "COMPLETED", "metadata": { "channel": "mobile_app", "notification": { "type": "SMS", "status": "DELIVERED", "text": "Helix: Your complaint has been successfully registered." } } }, { "id": "tl-review-citizen-uuid", "timestamp": "2026-07-07T12:00:05Z", "actor": "Helix Platform", "actor_type": "system", "action": "UNDER_REVIEW", "description": "AI verification scan, duplicate mapping, and policy checks are in progress.", "status": "IN_PROGRESS", "metadata": { "agents_active": ["ClassificationAgent", "DuplicateAgent", "SpatialAgent", "PolicyAgent"] } } ] }
Evidence Intelligence & Duplicate Clustering API Endpoints
The Governance service exposes evidence clustering and duplicate report mapping operations.
1. Search Duplicate Complaints
- Endpoint:
GET /governance/issues/{issue_id}/duplicates - Description: Identifies potential duplicate citizen reports matching this issue's coordinates, text contents, and timing threshold window.
- Parameters:
issue_id(str, required): The target issue ID to match against.- Response Sample:
[ { "issue": { "id": "mock-uuid-2", "title": "Water leakage and flooding", "category": "Water Supply & Sanitation", "latitude": 12.9758, "longitude": 77.5957 }, "confidence": 0.767, "breakdown": { "spatial": 0.9, "text": 0.81, "temporal": 0.98, "category": 1.0, "distance_meters": 33.0, "time_diff_days": 0.08 }, "already_merged": false } ]
2. List Clustered Incidents
- Endpoint:
GET /governance/incidents - Description: Returns all grouped incident clusters.
- Response Sample:
3. Retrieve Incident Details
- Endpoint:
GET /governance/incidents/{incident_id} - Description: Retrieves incident metadata along with all associated child issues (citizen reports).
- Parameters:
incident_id(str, required): The incident ID.- Response Sample:
{ "id": "inc-uuid-1", "title": "Incident Cluster: Water Main Leak Shivaji Nagar", "category": "Water Supply & Sanitation", "status": "TRIAGED", "reports_count": 2, "reports": [ { "id": "issue-1", "title": "Water Main Leak near Shivaji School", "description": "Large water main leak causing road erosion." }, { "id": "issue-2", "title": "Water leaking", "description": "Pipelake leak on Shivaji Road." } ] }
4. Merge Issue into Incident
- Endpoint:
POST /governance/incidents/{incident_id}/merge - Description: Merges a citizen issue report into an incident cluster.
- Request Body:
- Response Sample:
User Profile & Management (Identity) API Endpoints
The Identity service handles user profile retrieval, self-registration, user CRUD operations, invitations, and administrative approval flows.
1. Citizen Self-Registration
- Endpoint:
POST /identity/register - Description: Register a new Citizen user. Self-registered Citizens are automatically
ACTIVE. - Request Body:
- Response Sample:
2. User Login
- Endpoint:
POST /identity/login - Description: Authenticate user and return a JWT access token.
- Request Body:
- Response Sample:
{ "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...", "token_type": "bearer", "user": { "id": "user-uuid-1", "email": "citizen@example.com", "name": "Citizen John", "role": "CITIZEN", "status": "ACTIVE", "department_id": null, "phone": "+123456789", "bio": "A proud citizen.", "created_at": "2026-07-08T00:00:00Z", "updated_at": "2026-07-08T00:00:00Z" } }
3. Get Current User Profile
- Endpoint:
GET /identity/profile - Description: Retrieve current authenticated user's profile.
- Headers:
Authorization: Bearer <token>- Response Sample:
4. Update Current User Profile
- Endpoint:
PUT /identity/profile - Description: Update current authenticated user's profile information.
- Headers:
Authorization: Bearer <token>- Request Body:
- Response Sample:
5. Create Invitation
- Endpoint:
POST /identity/invitations - Description: Invite an MLA or Officer. Administrators can invite MLAs or Officers. MLAs can only invite Officers.
- Headers:
Authorization: Bearer <token>- Request Body:
- Response Sample:
6. Accept Invitation
- Endpoint:
POST /identity/invitations/accept - Description: Complete registration of an invited user. Upon acceptance, the user's status is set to
PENDING_APPROVAL. - Request Body:
- Response Sample:
7. Approve User Registration
- Endpoint:
POST /identity/users/{user_id}/approve - Description: Approve a user with
PENDING_APPROVALstatus. Administrators can approve anyone. MLAs can only approve Officers. - Headers:
Authorization: Bearer <token>- Response Sample:
8. List Users
- Endpoint:
GET /identity/users - Description: Retrieve a filtered list of users. Accessible to Administrators, MLAs, and Officers.
- Headers:
Authorization: Bearer <token>- Parameters:
role(str, optional): Filter by user role.status(str, optional): Filter by user status.- Response Sample:
Administrative Hierarchy & Jurisdiction API Endpoints
The Identity service now exposes system-admin-controlled administrative hierarchy APIs covering government geography setup, GeoJSON boundary management, and jurisdiction resolution for downstream complaint routing.
1. Country, State, and District Administration
- Endpoints:
POST /identity/countriesGET /identity/countriesGET /identity/countries/{country_id}PUT /identity/countries/{country_id}DELETE /identity/countries/{country_id}- Equivalent CRUD routes exist for
/identity/statesand/identity/districts - Description: Create and maintain the normalized country, state, and district hierarchy, including official codes and soft deactivation.
- Headers:
Authorization: Bearer <system-admin-token>
2. Parliamentary, Assembly, Ward, and Village Boundaries
- Endpoints:
POST /identity/parliamentary-constituenciesPOST /identity/assembly-constituenciesPOST /identity/wardsPOST /identity/villagesPOST /identity/parliamentary-constituencies/{id}/boundaryPOST /identity/assembly-constituencies/{id}/boundaryPOST /identity/wards/{id}/boundaryPOST /identity/villages/{id}/boundary- Description: Configure constituency and local-boundary records, validate uploaded GeoJSON polygons, track boundary versions, and reject malformed or self-intersecting polygons before persistence.
- Headers:
Authorization: Bearer <system-admin-token>
3. Jurisdiction Lookup
- Endpoint:
GET /identity/jurisdiction/lookup - Description: Resolve a latitude/longitude pair into the matching state, district, parliamentary constituency, assembly constituency, ward, and village when boundaries are available.
- Parameters:
latitude(float, required)longitude(float, required)- Response Sample:
{ "state": { "id": "state-uuid-1", "name": "Jurisdiction State", "code": "JS-001" }, "district": { "id": "district-uuid-1", "name": "Jurisdiction District", "code": "JD-001" }, "parliamentary_constituency": { "id": "pc-uuid-1", "name": "Jurisdiction PC", "code": "PC-001", "boundary_version": 1, "area_metadata": "regional", "population_metadata": "100000" }, "assembly_constituency": { "id": "ac-uuid-1", "name": "Jurisdiction AC", "code": "AC-001", "boundary_version": 1, "area_metadata": "local", "population_metadata": "25000" }, "ward": { "id": "ward-uuid-1", "name": "Ward 12", "code": "W-12", "assembly_constituency_id": "ac-uuid-1" }, "village": { "id": "village-uuid-1", "name": "Village North", "code": "V-12", "assembly_constituency_id": "ac-uuid-1" } }