insuranceUserStats API Endpoint v2

Zendrive’s insuranceUserStats v2 API retrieves the insurance score for users of the Zendrive White Label App (WLA).

The insuranceUserStats v2 API Endpoint allows the user to input variables such as user_id and end_date and select the model_id (the model could be Score, Pricing or Risk).

Based on this input, the API returns an array of insurance scores and optional parameter fields based on model_id for the 30-day window requested. The user can use this API to generate the output for time periods of 7 days, 14 days, 21 days and 30 days.

POST https://insurance-api.zendrive.com//v2/insurance/driver_id/<driver_id>/score?fields=info,driving_behaviour

Headers

Name
Type
Description

Authorization*

String

APIKEY

Request Payload Schema

{
        "$schema": "http://json-schema.org/draft-07/schema#",
        "type": "object",
        "properties": {
          "models": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "model_id": {
                  "type": "string"
                },
                "end_date": {
                  "type": "string",
                  "format": "date"
                },
                "scoring_days":{"enum":[7,14,21,30]}
              },
              "required": [
                "model_id",
                "end_date",
                "scoring_days"
              ],
              "additionalProperties": false
            }
          }
        },
        "required": [
          "models"
        ],
        "additionalProperties": false
}

Response Schema

{
        "$schema": "http://json-schema.org/draft-07/schema#",
        "type": "object",
        "properties": {
          "driver_id": {
            "type": "string"
          },
          "scores": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "model_id": {
                  "type": "string"
                },
                "start_date": {
                  "type": "string",
                  "format": "date"
                },
                "end_date": {
                  "type": "string",
                  "format": "date"
                },
                "score": {
                  "type": "number"
                },
                "driving_behaviour": {
                  "type": "object",
                  "properties": {
                    "event_grades": {
                      "type": ["object", "null"],
                      "properties": {
                        "hard_brake": {
                          "type": "integer",
                          "minimum": 1,
                          "maximum": 5
                        },
                        "hard_turn": {
                          "type": "integer",
                          "minimum": 1,
                          "maximum": 5
                        },
                        "over_speeding": {
                          "type": "integer",
                          "minimum": 1,
                          "maximum": 5
                        },
                        "phone_use": {
                          "type": "integer",
                          "minimum": 1,
                          "maximum": 5
                        },
                        "rapid_acceleration": {
                          "type": "integer",
                          "minimum": 1,
                          "maximum": 5
                        }
                      },
                      "additionalProperties": false
                    },
                    "event_scores": {
                      "type": ["object", "null"],
                      "properties": {
                        "hard_brake": {
                          "type": "number",
                          "minimum": 0,
                          "maximum": 100
                        },
                        "hard_turn": {
                          "type": "number",
                          "minimum": 0,
                          "maximum": 100
                        },
                        "over_speeding": {
                          "type": "number",
                          "minimum": 0,
                          "maximum": 100
                        },
                        "phone_use": {
                          "type": "number",
                          "minimum": 0,
                          "maximum": 100
                        },
                        "rapid_acceleration": {
                          "type": "number",
                          "minimum": 0,
                          "maximum": 100
                        }
                      },
                      "additionalProperties": false
                    },
                    "insurance_grade": {
                      "type": ["integer", "null"],
                      "minimum": 0,
                      "maximum": 100
                    }
                  },
                  "additionalProperties": false
                },
                "info": {
                  "type": "object",
                  "properties": {
                    "nighttime_driving_hours": {
                      "type": ["number", "null"]
                    },
                    "total_driving_hours": {
                      "type": ["number", "null"]
                    },
                    "total_trips": {
                      "type": ["integer", "null"]
                    },
                    "total_miles": {
                      "type": ["number", "null"]
                    }
                  },
                  "additionalProperties": false
                },
                "error": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "message",
                    "code"
                  ],
                  "additionalProperties": false
                }
              },
              "additionalProperties": false,
              "required": [
                "model_id",
                "start_date",
                "end_date"
              ],
              "oneOf": [
                {
                  "required": [
                    "score"
                  ]
                },
                {
                  "required": [
                    "error"
                  ]
                }
              ]
            }
          }
        },
        "required": [
          "driver_id",
          "scores"
        ],
        "additionalProperties": false
}

Sample Request

{
  "models": [
    {
      "model_id": "pl_model_20",
      "end_date": "2021-01-01",
      "scoring_days":7
    },
    {
      "model_id": "pl_model_20",
      "end_date": "2020-12-31",
      "scoring_days": 30
    }
  ]
}

Sample Response

{
        "driver_id": "CPX67",
        "scores": [
          {
             "model_id": "pl_model_20",
             "start_date": "2021-01-25",
             "end_date": "2021-01-31",
             "score": 23.9,
             "driving_behaviour": {
               "event_grades": {
                 "hard_brake": 2,
                 "hard_turn": 4,
                 "over_speeding": 3,
                 "phone_use": 5,
                 "rapid_acceleration": 1
               },
               "event_scores": {
                 "hard_brake": 70.0,
                 "hard_turn": 20.0,
                 "over_speeding": 50.0,
                 "phone_use": 10.0,
                 "rapid_acceleration": 90.0
               },
               "insurance_grade": 88
             },
            "info": {
              "nighttime_driving_hours": 600,
              "total_driving_hours": 6000,
              "total_trips": 10,
              "total_miles": 100
            }
          },
          {
            "model_id": "pl_model_20",
            "start_date": "2020-12-01",
            "end_date": "2020-12-30",
            "error": {
              "message": "Found not enough scoring trips of driver",
              "code": "NO_SCORE_FOUND"
            }
          }
       ]
}

Error Codes

We have defined specific values for scoring_days in the Request Schema_._ If the user enters a value not present in the Request Schema, one of the error codes, as listed in the following table, will be displayed:

Scenario
Error Codes

INVALID PAYLOAD FORMAT

INVALID_DATA

INVALID END DATE

INVALID_DATE

INVALID APPLICATION MODEL

INVALID_MODEL

INVALID JSON

INVALID_DATA

APPLICATION MODEL EXPIRED

INVALID_DATE

MODEL NOT STARTED

INVALID_DATE

NO SCORE FOUND

NO_SCORE_FOUND

Was this helpful?