Add Collections

2. ADD COLLECTIONS

URL: https://app.detrack.com/api/v1/collections/create.json
Limit: 100 collections per request (send separate requests if you are adding more than 100 collections)
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 collections you wish to add. It should contain an array of collections with the following fields:

Field Description
date The collection date. Format: YYYY-MM-DD e.g. 2014-02-28. Required field.
do The D.O. #. This field must be unique for the date. Required field.
address The collection address. Always include country name for accurate geocoding results. Required field.
collection_time The collection time window. This will be displayed in the delivery list view and the delivery detail view.
collect_from The name of the sender to collect from. This can be a person’s name e.g. John Tan, a company’s name e.g. ABC Inc., or both e.g. John Tan (ABC Inc.)
phone The phone number of the sender. If specified, the driver can call the sender directly from the app.
notify_email The email address to send customer-facing delivery updates to. If specified, a collection notification will be sent to this email address upon successful collection.
notify_url The URL to post collection updates to. Please refer to Collection Push Notification
assign_to The name of the vehicle to assign this collection to. This must be spelled exactly the same as your vehicle’s name in your dashboard.
instructions Any special collection instruction for the driver. This will be displayed in the collection detail view.
zone If you divide your collections into zones, then specifying this will help you to easily filter out the collections by zones in your dashboard.
items This field is optional. If specified, it should contain an array of items with the following fields:

Field Description
sku Stock keeping unit or item #. Required for item only.
desc The item description. Required for item only.
qty Quantity of the item to be collected. Required for item only.

For additional fields, please refer to Additional Collection Fields.

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 collections that are not added 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 Collection Error Codes
message The corresponding error message.
results Contains an array of statuses with the following fields:

Field Description
date The date of the collection. Format: YYYY-MM-DD e.g. 2014-02-28
do The D.O. # of the collection.
status The status of the collection add request. The value will be “ok” if the delivery is successfully added or “failed” if the delivery is not added.
errors Contains an array of error messages if the collection add request failed. Note: this field is set only if the collection add request failed.

Field Description
code The error code. Please refer to Collection Error Codes
message The corresponding error message.
SAMPLE REQUEST JSON
[
{
"date":"2014-02-11",
"do":"DO140211001",
"address":"63 Ubi Avenue 1 Singapore 408937",
"collection_time":"09:00 AM - 12:00 PM",
"collect_from":"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",
"items":[
{
"sku":"T0201",
"desc":"Test Item #01",
"qty":1
},
{
"sku":"T0202",
"desc":"Test Item #02",
"qty":5
},
{
"sku":"T0203",
"desc":"Test Item #03",
"qty":10
}
]
},
{
"date":"2014-02-11",
"do":"DO140211002",
"address":"59 Ubi Avenue 1 Singapore 408938",
"collection_time":"02:00 PM - 05:30 PM",
"collect_from":"Jane Lim",
"phone":"+6581234567",
"notify_email":"jane.lim@example.com",
"notify_url":"http://www.example.com/notify.php",
"assign_to":"GT1234H",
"instructions":"Change pass at security counter before proceeding to level 3.",
"zone":"East",
"items":[
{
"sku":"T0211",
"desc":"Test Item #11",
"qty":1
},
{
"sku":"T0212",
"desc":"Test Item #12",
"qty":5
},
{
"sku":"T0213",
"desc":"Test Item #13",
"qty":10
}
]
}
]
SAMPLE RESPONSE JSON #1
{
"info":{
"status":"ok",
"failed":0
},
"results":[
{
"date":"2014-02-13",
"do":"DO140213001",
"status":"ok"
},
{
"date":"2014-02-13",
"do":"DO140213002",
"status":"ok"
}
]
}
SAMPLE RESPONSE JSON #2
{
"info":{
"status":"ok",
"failed":2
},
"results":[
{
"date":"2014-02-13",
"do":"DO140213001",
"status":"failed",
"errors":[
{
"code":1002,
"message":"Collection with D.O. # DO140213001 already exists on 2014-02-13."
}
]
},
{
"date":"2014-02-13",
"do":"DO140213002",
"status":"failed",
"errors":[
{
"code":1002,
"message":"Collection with D.O. # DO140213002 already exists on 2014-02-13."
}
]
}
]
}