View Deliveries

6. VIEW DELIVERIES

URL: https://app.detrack.com/api/v1/deliveries/view.json
Limit: 100 deliveries per request (send separate requests if you are viewing more than 100 deliveries)
HTTP POST REQUEST

Note: the request structure below is for Method #1: Name/Value Pair (NVP) + JSON String. For Method #2: Custom Header + JSON Body, please refer to the json parameter only.

Parameter Description
key Your API key. You can obtain this from your dashboard.
json The JSON string containing the deliveries you wish to view. It should contain an array with the following fields:

Field Description
date The delivery date. Format: YYYY-MM-DD e.g. 2014-02-28. Required field.
do The D.O. #. The D.O. # of the delivery to view. Required field.
HTTP POST RESPONSE (JSON)
Field Description
info Contains information on the status of the request.

Field Description
status The status of the request. The value will be “ok” if request is processed successfully or “failed” if the key or json parameter is missing.
failed The number of deliveries that are not retrieved due to error.
error Contains the error details if the request failed. Note: this field is set only if the request failed.

Field Description
code The error code. Please refer to Delivery Error Codes
message The corresponding error message.
results Contains an array of statuses with the following fields:

Field Description
date The date of the delivery. Format: YYYY-MM-DD e.g. 2014-02-28
do The D.O. # of the delivery.
status The status of the delivery view request. The value will be “ok” if the delivery is successfully retrieved or “failed” if the delivery is not retrieved.
delivery The retrieved delivery with the following fields:

Field Description
date The delivery date. Format: YYYY-MM-DD e.g. 2014-02-28.
do The D.O. #. This field is unique for the date.
address The delivery address.
delivery_time The delivery time window.
deliver_to The name of the recipient to deliver to.
phone The phone number of the recipient.
notify_email The email address to send customer-facing delivery updates to.
notify_url The URL to post delivery updates to. Please refer to Delivery Push Notification
assign_to The name of the vehicle to assign this delivery to.
instructions Delivery instructions for the driver.
zone The zone that this delivery falls under.
reason The reason of non-delivery if the delivery is not delivered.
note Any note recorded by the driver regarding this delivery.
received_by The name of the recipient who signed for the delivery.
image If the POD contains an image (signature / photo), the value will be 1. Otherwise, it will be 0Please refer to Download Delivery POD Image File
view_image_url If the POD contains an image (signature / photo), this field will contain an access-controlled link (user must be logged in to Detrack) to the image. Otherwise, it will be empty.
time The time the POD is received. ISO 8601 format: YYYYMMDDTHH:MM:SS+HH:MM e.g. 2014-02-13T09:30:45+08:00
pod_lat The latitude of the driver’s last known location when submitting POD for this delivery.
pod_lng The longitude of the driver’s last known location when submitting POD for this delivery.
pod_address The address of the driver’s last known location when submitting POD for this delivery.
items This field may or may not be empty. If not empty, it should contain an array of items with the following fields:

Field Description
sku Stock keeping unit or item #.
desc The item description.
qty Quantity of the item to be delivered.
reject Quantity of the item rejected by recipient.
reason Reason of item rejection.
errors Contains an array of error messages if the delivery view request failed. Note: this field is set only if the delivery view request failed.

Field Description
code The error code. Please refer to Delivery Error Codes
message The corresponding error message.

For additional fields, please refer to Additional Delivery Fields.

SAMPLE REQUEST JSON
[
   {
      "date":"2014-02-13",
      "do":"DO140213001"
   },
   {
      "date":"2014-02-13",
      "do":"DO140213003"
   }
]
SAMPLE RESPONSE JSON
{
   "info":{
      "status":"ok",
      "failed":1
   },
   "results":[
      {
         "date":"2014-02-13",
         "do":"DO140213001",
         "status":"ok",
         "delivery":{
            "date":"2014-02-13",
            "address":"63 Ubi Avenue 1 Singapore 408937",
            "delivery_time":"09:00 AM - 12:00 PM",
            "deliver_to":"John Tan",
            "phone":"+6591234567",
            "notify_email":"john.tan@example.com",
            "notify_url":"http://www.example.com/notify.php",
            "assign_to":"GT1234H",
            "instructions":"Call customer upon arrival.",
            "zone":"East",
            "reason":"",
            "note":"",
            "received_by":"",
            "image":0,
            "view_image_url":"",
            "do":"DO140213001",
            "status":"In Progress",
            "time":"",
            "pod_lat":"",
            "pod_lng":"",
            "pod_address":"",
            "items":[
               {
                  "sku":"T0201",
                  "desc":"Test Item #01",
                  "qty":1,
                  "reject":0,
                  "reason":""
               },
               {
                  "sku":"T0202",
                  "desc":"Test Item #02",
                  "qty":5,
                  "reject":0,
                  "reason":""
               },
               {
                  "sku":"T0203",
                  "desc":"Test Item #03",
                  "qty":10,
                  "reject":0,
                  "reason":""
               }
            ]
         }
      },
      {
         "date":"2014-02-13",
         "do":"DO140213003",
         "status":"failed",
         "errors":[
            {
               "code":1003,
               "message":"Delivery with D.O. # DO140213003 not found on 2014-02-13."
            }
         ]
      }
   ]
}