Prerequisites: Creating Your Application

Before implementing preventive maintenance capabilities ensure you have:

  • Created a Smartcar account and registered your application to obtain your client_id and client_secret.
  • Set up the Smartcar Connect flow to authenticate and authorize users.

For more details, refer to the Getting Started Guide.

Smartcar API Endpoints for Preventive Maintenance

Use the following endpoints to build your preventive maintenance solution:

1. Track Odometer Readings

Retrieve odometer data to schedule maintenance services such as tire rotations or oil changes based on mileage.

Odometer
curl "https://api.smartcar.com/v2.0/vehicles/{id}/odometer" \
    -H "Authorization: Bearer {token}" \
    -X "GET"
Example Response
    {
        "distance": 104.32
    }

Use Case Send a notification when a vehicle’s odometer reading reaches maintenance intervals, such as every 5,000 miles.

2. Monitor Engine Oil Life

Retrieve oil life data to prompt users when an oil change is due.

Engine Oil Life
curl "https://api.smartcar.com/v2.0/vehicles/{id}/engine/oil" \
    -H "Authorization: Bearer {token}" \
    -X "GET"
Example Response
{
  "lifeRemaining": 0.35
}

Use Case Trigger a service reminder when oil life falls below 20% to prevent engine damage.

3. Retrieve Diagnostic Trouble Codes (DTCs)

DTCs help you identify and diagnose specific vehicle issues, allowing for quick and accurate repairs.

DTCs
curl "https://api.smartcar.com/v2.0/vehicles/{vehicleId}/diagnostics/dtcs" \
    -H "Authorization: Bearer {token}" \
    -X "GET"
Example Response
{
    "activeCodes": [
      {
        "code": "P302D",
        "timestamp": "2024-09-05T14:48:00.000Z"
      }
    ]
}

Use Case Notify a driver immediately if a new trouble code is detected, enabling faster response times.

4. Monitor Vehicle System Status

Retrieve a snapshot of key systems like the engine and battery to assess health and detect anomalies.

System Status
curl "https://api.smartcar.com/v2.0/vehicles/{vehicleId}/system-status" \
    -H "Authorization: Bearer {token}" \
    -X "GET"
Example Response
{
      "systems": [
          {
              "systemId": "SYSTEM_TPMS",
              "status": "ALERT",
              "description": "Left rear tire sensor battery low"
          },
          {
              "systemId": "SYSTEM_AIRBAG",
              "status": "OK",
              "description": null
          },
          {
              "systemId": "SYSTEM_MIL",
              "status": "OK",
              "description": null
          },
      ]
}

Use Case Notify users or fleet operators if the engine status changes to warning or the battery health declines.

Webhooks for Preventive Maintenance

Webhooks enable real-time notifications for certain vehicle events, reducing the need for polling. Examples include:

  • DTC Updates: Receive a webhook when a new trouble code is logged.
  • System Changes: Get updates for changes in engine or battery status.

Setting Up Webhooks

To receive real-time notifications (e.g., when new DTCs appear), consider setting up webhooks:

  1. Create a Webhook: Configure a secure endpoint on your server to handle POST requests from Smartcar.
  2. Register the Webhook: Specify which events (such as DTC) you want to subscribe to.
  3. Instant Alerts: When an event triggers, Smartcar sends a payload to your endpoint, enabling immediate responses (like sending notifications or scheduling service).

See the Smartcar Webhooks Documentation for more information.

Example Workflow

  1. Authorization: The user logs in via Smartcar Connect to grant access to vehicle data.
  2. Monitoring: Your backend polls GET endpoints (e.g., odometer, oil, system status) or listens for webhook events.
  3. Threshold Detection: Evaluate data (e.g., oil life < 20%, mileage > 5,000 miles) and identify DTCs or system warnings.
  4. Notifications: Send push notifications, emails, or SMS to users with maintenance reminders or alerts.
  5. Ongoing Updates: Combine periodic polling and webhooks to ensure vehicles stay road-ready.

FAQs