LocateOne DocsBrowse docs →

Using the Predict API

This document explains the API endpoint "Predict" and how it calculates the RTO risk score for orders. It outlines the necessary parameters for using the API and provides a sample request and response with a generated RTO score of 0.28. Gain insights into

API Endpoint

The primary function of the Predict endpoint is to generate an RTO risk score based on order details. Refer to the table below for the list of parameters.

ParameterData TypeDescriptionExample
cl*****stringThe registered client name with Delhivery.ABC SURFACE
order_idstringUnique identifier of the order being placed or already placed.abc-126-fba
order_date*****stringDate of when the order was already placed or is being placed.12-05-2023
order_value*****number($float)Total value if the order in rs including discount.1024
total_discount*****number($float)Discount given on the purchase.200
total_line_item_quantity*****number($float)Quantity of all line items in the order.2
line_items*****listAll line items in an list.
line_items.item_id*****stringThe id of the item.ajio-smh-smj
line_items.product_description*****stringThe product description of the line item.green_tshirt
line_items.item_colourstringThe colour of the item.green
line_items.item_quantity*****integerQuantity of a particular line_item in the order.1
line_items.item_discountnumber($float)Discount of the item.0
line_items.item_pricenumber($float)Price of the item.524
seller_origin_citystringPickup city of the order.bhiwandi
seller_origin_pincodestringPickup pincode of the seller.410889
seller_pickup_locationstringThe pickup_location of the order.
promised_delivery_datestringPromised delivery date by Logistics partner.22-08-2023
shipping_address*****dictionaryThe dictionary of details for the shipping address.
first_namestringFirst name of the consignee.First Name
last_namestringLast name of the consignee.Last Name
address1*****stringAddress line 1 of the consignee.plt4 sec44
address2stringAddress line 2 of the consignee.
citystringCity of the consignee.ggn
statestringState of the consignee.Haryana
pincode*****stringPincode of the consignee.122003
billing_addressDictionaryThe dictionary of details for the billing address.
first_namestringFirst name of the consignee.First Name
last_namestringLast name of the consignee.Last Name
address1stringAddress line 1 of the consignee.plt4 sec44
address2stringAddress line 2 of the consignee.
citystringCity of the consignee.ggn
statestringState of the consignee.Haryana
pincodestringPincode of the consignee.122003
ph_no*****stringPhone number of the consignee.9999999999
customerDictionaryThe dictionary of details for the customer.
customer_ipstringIp of the customer.192.168.0.1
customer_browserstringBrowser used by the customer.Chrome
new_customerstringWhether the order is from a new customer or an existing customer.1
device_typestringWhether the order has been placed via a mobile, tab or laptop.laptop
genderstringGender of the customer.f

Please refer to the table below while inferring the API Response.

FieldTypeDescription
status_codenumberStatus code of the request.
request_id StringThe unique id for the request.
message StringInformation about the processed request.
dataObjectThe object that contains the Predict API results. 
data.rto_scoreFloatRisk score which indicates the likelihood of RTO. 
data.additional_infodictAdditional info which will help in contextualizing the RTO score. This would include relative RTO risk, probable reason for RTO. This will be populated in later versions of the API.
errorObjectWill include the error details in case of unsuccessful response. 
error.typeString Type of error encountered.
error.message StringMessage detailing the error.

The following example request returns an RTO score of 0.43.

::::CodeDrawer{title="POST /predict" codeEditorData="[object Object]" responsesEditorData="[object Object]" isResponseExpanded="true"} :::CodeblockTabsExamples

{
   "order": {
      "cl":"ABC SURFACE",
      "order_id": "abc-126-fba",
      "order_date": "10-09-2023",
      "order_value": 1,
      "total_discount": 1,
      "total_line_item_quantity": 2
   },
   "line_items": [
      {
         "item_id": "12",
         "product_description": "green_tshirt",
         "item_colour": "green",
         "item_quantity": 1,
         "item_discount": 0,
         "item_price": 524
      },
      {
         "item_id": "",
         "product_description": "jeans",
         "item_colour": "blue",
         "item_quantity": 1,
         "item_discount": 100,
         "item_price": 800
      }
   ],
   "seller_origin_city": "1234",
   "seller_origin_pincode": "410889",
   "seller_pickup_location": "",
   "promised_delivery_date": "23-10-2023",
   "shipping_address": {
      "first_name": "First Name",
      "last_name": "Last Name",
      "address1": "Plt 4 sec44",
      "address2": "",
      "city": "ggn",
      "state": "Haryana",
      "pincode": "122017"
   },
   "billing_address": {
      "first_name": "First Name",
      "last_name": "Last Name",
      "address1": "sd",
      "address2": "",
      "city": "ggn",
      "state": "Haryana",
      "pincode": "122000"
   },
   "customer": {
      "customer_ip": "",
      "customer_browser": "",
      "new_customer": "1",
      "device_type": "laptop",
      "ph_no": "9999999999",
      "gender": "f"
   }
}

:::

:::CodeblockTabsResponses

{
    "status_code": 200,
    "request_id": "rto_pred|a45cce4f-6baa-476c-9975-46748cec3f21",
    "message": "Success",
    "data": {
        "rto_score": 0.43,
        "additional_info": {}
    },
    "error": null
}

::: ::::