Packagelytics
Search…
Packagelytics API
Track your fleet, connect with customers and document deliveries, all with a beautifully designed API.
The Packagelytics Application Programming Interface (API) gives you the tools you need to build a full featured delivery management system. It allows you to create routes and dispatch them to the Packagelytics driver app. Built in route optimization, text notifications and photo proof of delivery from within the app guarantees an efficient, timely, customer centric delivery experience.
In this quickstart guide, we will show you how to programmatically create and dispatch routes to drivers. Briefly, the steps involved are:
    1.
    Create a driver (linked with the Packagelytics PID on his device)
    2.
    Create a route belonging to that driver with several initial stops
    3.
    Adding additional stops to the route (optional)
    4.
    Dispatching the route to the driver so he can see it on the Packagelytics app on his phone

Authentication

All authentication in the Packagelytics API is done using an API key. You can retrieve your API key by logging into www.packagelytics.com and clicking the [API Key] link on the top navigation bar.

Add Drivers

The easiest way to add a driver is to do it manually on the admin portal at www.packagelytics.com. Click the [Drivers] link on the top navigation bar and click [New Driver]. Next, get your driver to download the Packagelytics app from the Apple App Store or Google Play Store. Enter the name, PID (the PID can be found on the Packagelytics driver app when the driver runs it for the first time) and phone number of the driver you want to add. Once a driver is added, it will show up on the driver listing page.
Once this is done, you need to retrieve the user_id of the driver (a user) you want to dispatch the route to. You do this by making a GET call on the users endpoint.
get
https://packagelytics.com/api
/v1/users
Get Users

Output

1
{
2
"data": [
3
{
4
"phone": "+17789188954",
5
"deleted": false,
6
"disabled": false,
7
"tokenApi": "jbLDQ3lmvOSI86xLSeHu2DsTA7nW9yqL8ZpzGLdDPvOj9rdErw1HN9E0jWNd",
8
"pid": "PID015250",
9
"_id": "5ea3ee5f8aca520017861df3",
10
"name": "Jason iPhone",
11
"email": "[email protected]",
12
"role": "driver",
13
"createdAt": "2020-04-25T08:01:35.688Z",
14
"updatedAt": "2020-04-25T08:03:25.616Z",
15
"__v": 0,
16
"company": {
17
"phone": "+16041238954",
18
"address": null,
19
"disabled": false,
20
"_id": "5ea3eb794061d354ab779c3d",
21
"name": "Hernandez",
22
"createdAt": "2020-04-25T07:49:13.091Z",
23
"updatedAt": "2020-04-25T07:49:13.091Z",
24
"__v": 0
25
},
26
"device": {
27
"model": "iPhone",
28
"localizedModel": "iPhone",
29
"systemName": "iOS",
30
"systemVersion": "11.2.1",
31
"uuid": "58CB55F1-50BA-45D5-A621-B7E9D174AEF0",
32
"pid": "PID015250",
33
"lat": 49.27698107168895,
34
"lng": -123.10862596592139,
35
"registrationTokens": "dt7iy0dzg0o:APA91bHHCEMfglgZJpjyLC6VMbIJd285me8-FvJIBNdW4yJxE0sDF6JB1DhAD2iSzYn3CAt3S2RX08clDLRRiXzfXcX5H7baz1I5WsfIg_R-20LJDNF58ShrvRy5FZHVho2jvIGQooyX",
36
"buildVersion": "1.0.1(18)",
37
"sendSlack": true,
38
"_id": "5ea3ee5f8aca520017861df2",
39
"name": "iPhone",
40
"createdAt": "2020-04-25T08:01:35.571Z",
41
"updatedAt": "2020-04-25T08:04:47.355Z",
42
"__v": 0,
43
"user": "5ea3ee5f8aca520017861df3"
44
}
45
},
46
{
47
"phone": "+1601238954",
48
"deleted": false,
49
"disabled": false,
50
"tokenApi": "hWbgqiTcGcUvOD51ScCxWviW0W509vC5dkxhBWQgrXvloWWgafmnJdRBWhL2",
51
"pid": null,
52
"_id": "5ea3eb794061d354ab779c3e",
53
"name": "Jason",
54
"email": "[email protected]",
55
"role": "company_admin",
56
"company": {
57
"phone": "+17789188954",
58
"address": null,
59
"disabled": false,
60
"_id": "5ea3eb794061d354ab779c3d",
61
"name": "Hernandez",
62
"createdAt": "2020-04-25T07:49:13.091Z",
63
"updatedAt": "2020-04-25T07:49:13.091Z",
64
"__v": 0
65
},
66
"createdAt": "2020-04-25T07:49:13.335Z",
67
"updatedAt": "2020-04-25T07:49:13.335Z",
68
"__v": 0
69
}
70
],
71
"total": 2,
72
"pages": 1
73
}
Copied!
In this example, I want to dispatch a route to the driver "Jason iPhone" with the PID PID015250, so I'm going to note down his user_id 5ea3ee5f8aca520017861df3 and use it when creating and assigning a route to him.
post
https://packagelytics.com/api
/v1/routes
Create Route
Input
1
{
2
"date": "2020-04-25",
3
"time": "08:00",
4
"user": "5ea2ee908aca520017861dec",
5
"stops": [{
6
"name": "Postmark Brewing",
7
"phone": "+16046991988",
8
"address": "55 Dunlevy Ave, Vancouver, BC V6A 1G7, Canada",
9
"lat": 49.284319,
10
"lng": -123.095659
11
},
12
{
13
"name": "Parallel 49 Brewing Co",
14
"phone": "+16045582739",
15
"address": "1950 Triumph St, Vancouver, BC V5L 1K5, Canada",
16
"lat": 49.2838375,
17
"lng": -123.0665549
18
},
19
{
20
"name": "Andina Brewing Co",
21
"phone": "+16042532400",
22
"address": "1507 Powell St, Vancouver, BC V5L 5C3",
23
"lat": 49.2836146,
24
"lng": -123.0760829
25
}
26
]
27
}
Copied!
Output
1
{
2
"message": "Route has been created successfully",
3
"data": {
4
"startDate": "2020-04-25",
5
"startTime": "08:00",
6
"status": "new",
7
"pendingDispatched": false,
8
"timezone": null,
9
"jobId": null,
10
"polylines": null,
11
"totalDistance": 0,
12
"totalTime": 0,
13
"companyName": "Hernandez",
14
"stops": [
15
"5ea47ad5e9ab5d7953b4e031",
16
"5ea47ad5e9ab5d7953b4e032",
17
"5ea47ad5e9ab5d7953b4e033"
18
],
19
"_id": "5ea47ad5e9ab5d7953b4e030",
20
"name": "20200425-1",
21
"user": "5ea3eb794061d354ab779c3e",
22
"company": "5ea3eb794061d354ab779c3d",
23
"createdAt": "2020-04-25T18:00:53.656Z",
24
"updatedAt": "2020-04-25T18:00:53.656Z",
25
"optimizedAt": "2020-04-25T18:00:53.656Z",
26
"__v": 0
27
}
28
}
Copied!
If the route was created successfully, the API will return a route_id (in the example above, the route_id is 5ea47ad5e9ab5d7953b4e030. You can then view the route on your dashboard at https://packagelytics.com/dashboard/routes/5ea47ad5e9ab5d7953b4e030. Note that the route has not been dispatched to the driver yet, and is not in optimized order (this will be done by the driver using the Packagelytics app).
Now, suppose you want to add more stops to the initial route that you created. All you need to do is call the Create Stops API one at a time and specify a route_id to assign the stop to.
post
https://packagelytics.com/api
/v1/routes
Create Stop
1
{
2
"name": "Yellow Dog Brewing Co",
3
"phone": "+16044920191",
4
"address": "2817 Murray St #1, Port Moody, BC V3H 1X3, Canada",
5
"lat": 49.278657,
6
"lng": -122.8488629,
7
"route": "5ea47ad5e9ab5d7953b4e030"
8
}
Copied!
Output
1
{
2
"message": "Stop has been created successfully",
3
"data": {
4
"phone": "+16044920191",
5
"address": "2817 Murray St #1, Port Moody, BC V3H 1X3, Canada",
6
"email": null,
7
"lat": 49.278657,
8
"lng": -122.8488629,
9
"notes": null,
10
"notes2": null,
11
"orderId": null,
12
"status": "draft",
13
"reason": null,
14
"pods": [],
15
"signature": null,
16
"package": null,
17
"payment": null,
18
"driverNotes": null,
19
"order": 99,
20
"arrivalTime": null,
21
"finishTime": null,
22
"goingAt": null,
23
"goingLat": null,
24
"goingLng": null,
25
"arrivedAt": null,
26
"arrivedLat": null,
27
"arrivedLng": null,
28
"skippedAt": null,
29
"skippedLat": null,
30
"skippedLng": null,
31
"completedAt": null,
32
"completedLat": null,
33
"completedLng": null,
34
"failedAt": null,
35
"failedLat": null,
36
"failedLng": null,
37
"_id": "5ea49053e9ab5d7953b4e034",
38
"name": "Yellow Dog Brewing Co",
39
"route": "5ea47ad5e9ab5d7953b4e030",
40
"createdAt": "2020-04-25T19:32:35.055Z",
41
"updatedAt": "2020-04-25T19:32:35.055Z",
42
"__v": 0
43
}
44
}
Copied!
You can now see the new stop (Yellow Dog Brewing Co) added to the end of route.
The last step is to dispatch this route to your driver so it shows up on the Packagelytics app on his phone.
post
https://packagelytics.com/api
/v1/routes/5ea47ad5e9ab5d7953b4e030/dispatch
Dispatch Route
Output
1
{
2
"message": "Route has been updated successfully"
3
}
Copied!
If the route was dispatched correctly, you would see a dispatch message and timestamp on the top right hand corner of the route detail page.
The driver will get a push notification and can now view the new route on his phone.
Last modified 1yr ago