{"openapi":"3.0.3","info":{"title":"GoMobility IoT Telematics & 2-Wheeler EV Management API","version":"1.0.0","description":"Robust REST APIs for Two-Wheeler EV IoT fleet tracking, remote ECU mobilization/immobilization commands, high-throughput telematics ingestion, and real-time webhook subscriptions.","contact":{"name":"GoMobility Developer Platform","url":"http://localhost:3000/api-docs"}},"servers":[{"url":"http://localhost:3000","description":"Local Development Server"}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"Standard OAuth2 Bearer Token issued via POST /api/v1/auth/token. Also accepts the raw client secret directly."},"apiKeyAuth":{"type":"apiKey","in":"header","name":"X-API-Key","description":"Direct API Key header. Pass clientSecret directly (e.g. gomobility_secret_2026)."}},"schemas":{"ErrorResponse":{"type":"object","properties":{"error":{"type":"string","example":"Unauthorized"},"message":{"type":"string","example":"Invalid or missing credentials"}}},"AuthTokenRequest":{"type":"object","required":["clientId","clientSecret"],"properties":{"clientId":{"type":"string","example":"gomobility_client_iot","description":"Registered API Client Identifier"},"clientSecret":{"type":"string","example":"gomobility_secret_2026","description":"Secret key corresponding to clientId"}}},"AuthTokenResponse":{"type":"object","properties":{"accessToken":{"type":"string","example":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."},"tokenType":{"type":"string","example":"Bearer"},"expiresIn":{"type":"integer","example":86400},"client":{"type":"object","properties":{"id":{"type":"string","example":"c129e924-f37e-405e-8557-0a41d0fc878a"},"name":{"type":"string","example":"Default IoT Client Key"},"clientId":{"type":"string","example":"gomobility_client_iot"}}}}},"Asset":{"type":"object","properties":{"id":{"type":"string","example":"a9829f0c-b26a-4952-b88a-36b12a849767"},"deviceId":{"type":"string","example":"EV-2W-1001"},"vin":{"type":"string","example":"MBH2W450X26A01001"},"model":{"type":"string","example":"Ather 450X Gen 3"},"registrationNumber":{"type":"string","example":"KA-01-EQ-1001"},"lat":{"type":"number","format":"double","example":12.9352},"lng":{"type":"number","format":"double","example":77.6245},"currentOdometerReading":{"type":"number","format":"double","example":12450.6},"status":{"type":"string","enum":["MOBILIZED","IMMOBILIZED"],"example":"MOBILIZED"},"batteryLevel":{"type":"integer","example":88},"batteryHealth":{"type":"integer","example":97},"batteryTemp":{"type":"number","example":31.2},"speed":{"type":"number","example":28.4},"ignition":{"type":"string","enum":["ON","OFF"],"example":"ON"},"chargingStatus":{"type":"string","enum":["CHARGING","DISCHARGING","IDLE"],"example":"DISCHARGING"},"networkStatus":{"type":"string","enum":["ONLINE","OFFLINE"],"example":"ONLINE"},"signalStrength":{"type":"integer","example":-68},"routeIndex":{"type":"integer","example":0},"lastHeartbeat":{"type":"string","format":"date-time","example":"2026-09-11T06:30:00.000Z"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}}},"SendCommandRequest":{"type":"object","required":["deviceId","command"],"properties":{"deviceId":{"type":"string","example":"EV-2W-1001","description":"Target 2W EV Device ID"},"command":{"type":"string","enum":["MOBILIZE","IMMOBILIZE"],"example":"IMMOBILIZE"},"reason":{"type":"string","example":"Payment Default / Geofence Breach"}}},"BulkCommandRequest":{"type":"object","required":["deviceIds","command"],"properties":{"deviceIds":{"type":"array","items":{"type":"string"},"example":["EV-2W-1001","EV-2W-1002","EV-2W-1003"]},"command":{"type":"string","enum":["MOBILIZE","IMMOBILIZE"],"example":"MOBILIZE"},"reason":{"type":"string","example":"Morning fleet unlock batch"}}},"TelemetryIngestRequest":{"type":"object","required":["deviceId"],"properties":{"deviceId":{"type":"string","example":"EV-2W-1001"},"lat":{"type":"number","example":12.9398},"lng":{"type":"number","example":77.6291},"currentOdometerReading":{"type":"number","example":12480.2},"batteryLevel":{"type":"integer","example":84},"speed":{"type":"number","example":36.4},"ignition":{"type":"string","enum":["ON","OFF"],"example":"ON"},"batteryTemp":{"type":"number","example":32.5},"networkStatus":{"type":"string","enum":["ONLINE","OFFLINE"],"example":"ONLINE"}}}}},"security":[{"bearerAuth":[]},{"apiKeyAuth":[]}],"paths":{"/api/v1/auth/token":{"post":{"summary":"Obtain OAuth2 Bearer Access Token","description":"Exchange clientId and clientSecret for a signed JWT access token valid for 24 hours.","security":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthTokenRequest"}}}},"responses":{"200":{"description":"Token issued successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthTokenResponse"}}}},"400":{"description":"Missing clientId or clientSecret","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/auth/credentials":{"get":{"summary":"List API Credentials","description":"Retrieve all configured client IDs and secrets for API access.","security":[{"bearerAuth":[]},{"apiKeyAuth":[]}],"responses":{"200":{"description":"List of registered API credentials"}}},"post":{"summary":"Create New API Key Pair","description":"Generate a new clientId and clientSecret for external application integration.","security":[{"bearerAuth":[]},{"apiKeyAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","example":"Java Production Microservice"},"clientId":{"type":"string","example":"client_custom_java"},"clientSecret":{"type":"string","example":"sec_custom_secret_key"}}}}}},"responses":{"201":{"description":"API Credential generated successfully"}}}},"/api/v1/assets":{"get":{"summary":"List All 2-Wheeler EV Assets","description":"Retrieve real-time telemetry, location, battery, speed, and status for all vehicles in the fleet.","parameters":[{"name":"status","in":"query","schema":{"type":"string","enum":["MOBILIZED","IMMOBILIZED"]},"description":"Filter by vehicle mobilization status"},{"name":"networkStatus","in":"query","schema":{"type":"string","enum":["ONLINE","OFFLINE"]},"description":"Filter by cellular connectivity state"},{"name":"search","in":"query","schema":{"type":"string"},"description":"Search by deviceId, model, registrationNumber, or VIN"}],"responses":{"200":{"description":"Array of EV asset objects","content":{"application/json":{"schema":{"type":"object","properties":{"total":{"type":"integer","example":12},"assets":{"type":"array","items":{"$ref":"#/components/schemas/Asset"}},"meta":{"type":"object"}}}}}},"401":{"description":"Unauthorized access","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/assets/{deviceId}":{"get":{"summary":"Get Single Asset by Device ID","parameters":[{"name":"deviceId","in":"path","required":true,"schema":{"type":"string","example":"EV-2W-1001"}}],"responses":{"200":{"description":"Detailed vehicle diagnostics & recent command log history"},"404":{"description":"Device ID not found"}}},"patch":{"summary":"Update Asset Telemetry & Configuration","parameters":[{"name":"deviceId","in":"path","required":true,"schema":{"type":"string","example":"EV-2W-1001"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","enum":["MOBILIZED","IMMOBILIZED"]},"batteryLevel":{"type":"integer","example":85},"speed":{"type":"number","example":32},"ignition":{"type":"string","enum":["ON","OFF"]}}}}}},"responses":{"200":{"description":"Asset updated successfully"}}}},"/api/v1/commands/send":{"post":{"summary":"Dispatch Remote Power Command (Mobilize / Immobilize)","description":"Transmits an ECU power command to remotely cut or enable the powertrain of a single 2W EV.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SendCommandRequest"}}}},"responses":{"200":{"description":"Command acknowledged by vehicle ECU","content":{"application/json":{"schema":{"type":"object","properties":{"commandId":{"type":"string","example":"cmd_31a48c90b621"},"deviceId":{"type":"string","example":"EV-2W-1001"},"command":{"type":"string","example":"IMMOBILIZE"},"status":{"type":"string","example":"ACKNOWLEDGED"},"message":{"type":"string"},"timestamp":{"type":"string","format":"date-time"},"previousStatus":{"type":"string","example":"MOBILIZED"},"newStatus":{"type":"string","example":"IMMOBILIZED"}}}}}},"404":{"description":"Device ID not found"}}}},"/api/v1/commands/bulk":{"post":{"summary":"Dispatch Bulk Commands Across Fleet","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BulkCommandRequest"}}}},"responses":{"200":{"description":"Batch results summary and per-device statuses"}}}},"/api/v1/commands/history":{"get":{"summary":"Query Command Audit Trail History","parameters":[{"name":"deviceId","in":"query","schema":{"type":"string","example":"EV-2W-1001"},"description":"Filter audit trail by specific vehicle deviceId"},{"name":"limit","in":"query","schema":{"type":"integer","default":50},"description":"Maximum number of records to return"}],"responses":{"200":{"description":"Historical command log entries"}}}},"/api/v1/telemetry/ingest":{"post":{"summary":"Ingest Raw IoT Telematics Packet","description":"Endpoint for IoT Gateway or OBD/CAN hardware to push telemetry packets. Automatically triggers field diff checks and HMAC-signed webhook dispatches.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TelemetryIngestRequest"}}}},"responses":{"200":{"description":"Telemetry ingested and state updated"}}}},"/api/v1/webhooks":{"get":{"summary":"List Registered Webhook Subscriptions","responses":{"200":{"description":"Active webhook subscriptions"}}},"post":{"summary":"Create New Webhook Subscription","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["name","url","trackedFields"],"properties":{"name":{"type":"string","example":"Billing & Fleet Management Hook"},"url":{"type":"string","example":"https://api.mybackend.com/webhooks/gomobility"},"secret":{"type":"string","example":"whsec_my_custom_secret"},"trackedFields":{"type":"array","items":{"type":"string"},"example":["status","currentOdometerReading","batteryLevel"]},"filterDeviceIds":{"type":"array","items":{"type":"string"},"example":[]}}}}}},"responses":{"201":{"description":"Webhook registered"}}}},"/api/v1/webhooks/logs":{"get":{"summary":"Retrieve Webhook Delivery Audit Logs","parameters":[{"name":"webhookId","in":"query","schema":{"type":"string"}},{"name":"limit","in":"query","schema":{"type":"integer","default":50}}],"responses":{"200":{"description":"Delivery attempts, HTTP response codes, and durations"}}}},"/api/v1/webhooks/test":{"post":{"summary":"Trigger Test Webhook Event Ping","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"webhookId":{"type":"string","example":"wh_default_local_test"},"customUrl":{"type":"string"}}}}}},"responses":{"200":{"description":"Test event dispatched"}}}},"/api/v1/simulator":{"get":{"summary":"Get IoT Telemetry Simulator Status","responses":{"200":{"description":"Simulator state (running/stopped, tick count, interval)"}}},"post":{"summary":"Control IoT Telemetry Simulator","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["action"],"properties":{"action":{"type":"string","enum":["START","STOP","TICK"]},"intervalSeconds":{"type":"integer","example":5}}}}}},"responses":{"200":{"description":"Simulator action executed"}}}}}}