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 Users

GET https://packagelytics.com/api/v1/users

Retrieve all users in your Packagelytics account.

Headers

Output

{
    "data": [
        {
            "phone": "+17789188954",
            "deleted": false,
            "disabled": false,
            "tokenApi": "jbLDQ3lmvOSI86xLSeHu2DsTA7nW9yqL8ZpzGLdDPvOj9rdErw1HN9E0jWNd",
            "pid": "PID015250",
            "_id": "5ea3ee5f8aca520017861df3",
            "name": "Jason iPhone",
            "email": "PID015250@packagelytics.com",
            "role": "driver",
            "createdAt": "2020-04-25T08:01:35.688Z",
            "updatedAt": "2020-04-25T08:03:25.616Z",
            "__v": 0,
            "company": {
                "phone": "+16041238954",
                "address": null,
                "disabled": false,
                "_id": "5ea3eb794061d354ab779c3d",
                "name": "Hernandez",
                "createdAt": "2020-04-25T07:49:13.091Z",
                "updatedAt": "2020-04-25T07:49:13.091Z",
                "__v": 0
            },
            "device": {
                "model": "iPhone",
                "localizedModel": "iPhone",
                "systemName": "iOS",
                "systemVersion": "11.2.1",
                "uuid": "58CB55F1-50BA-45D5-A621-B7E9D174AEF0",
                "pid": "PID015250",
                "lat": 49.27698107168895,
                "lng": -123.10862596592139,
                "registrationTokens": "dt7iy0dzg0o:APA91bHHCEMfglgZJpjyLC6VMbIJd285me8-FvJIBNdW4yJxE0sDF6JB1DhAD2iSzYn3CAt3S2RX08clDLRRiXzfXcX5H7baz1I5WsfIg_R-20LJDNF58ShrvRy5FZHVho2jvIGQooyX",
                "buildVersion": "1.0.1(18)",
                "sendSlack": true,
                "_id": "5ea3ee5f8aca520017861df2",
                "name": "iPhone",
                "createdAt": "2020-04-25T08:01:35.571Z",
                "updatedAt": "2020-04-25T08:04:47.355Z",
                "__v": 0,
                "user": "5ea3ee5f8aca520017861df3"
            }
        },
        {
            "phone": "+1601238954",
            "deleted": false,
            "disabled": false,
            "tokenApi": "hWbgqiTcGcUvOD51ScCxWviW0W509vC5dkxhBWQgrXvloWWgafmnJdRBWhL2",
            "pid": null,
            "_id": "5ea3eb794061d354ab779c3e",
            "name": "Jason",
            "email": "jason@packagelytics.com",
            "role": "company_admin",
            "company": {
                "phone": "+17789188954",
                "address": null,
                "disabled": false,
                "_id": "5ea3eb794061d354ab779c3d",
                "name": "Hernandez",
                "createdAt": "2020-04-25T07:49:13.091Z",
                "updatedAt": "2020-04-25T07:49:13.091Z",
                "__v": 0
            },
            "createdAt": "2020-04-25T07:49:13.335Z",
            "updatedAt": "2020-04-25T07:49:13.335Z",
            "__v": 0
        }
    ],
    "total": 2,
    "pages": 1
}

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.

Create Route

POST https://packagelytics.com/api/v1/routes

Create a route with stops and assign it to a driver.

Headers

Input

{
	"date": "2020-04-25",
	"time": "08:00",
	"user": "5ea2ee908aca520017861dec",
	"stops": [{
			"name": "Postmark Brewing",
			"phone": "+16046991988",
			"address": "55 Dunlevy Ave, Vancouver, BC V6A 1G7, Canada",
			"lat": 49.284319,
			"lng": -123.095659
		},
		{
			"name": "Parallel 49 Brewing Co",
			"phone": "+16045582739",
			"address": "1950 Triumph St, Vancouver, BC V5L 1K5, Canada",
			"lat": 49.2838375,
			"lng": -123.0665549
		},
		{
			"name": "Andina Brewing Co",
			"phone": "+16042532400",
			"address": "1507 Powell St, Vancouver, BC V5L 5C3",
			"lat": 49.2836146,
			"lng": -123.0760829
		}
	]
}

Output

{
    "message": "Route has been created successfully",
    "data": {
        "startDate": "2020-04-25",
        "startTime": "08:00",
        "status": "new",
        "pendingDispatched": false,
        "timezone": null,
        "jobId": null,
        "polylines": null,
        "totalDistance": 0,
        "totalTime": 0,
        "companyName": "Hernandez",
        "stops": [
            "5ea47ad5e9ab5d7953b4e031",
            "5ea47ad5e9ab5d7953b4e032",
            "5ea47ad5e9ab5d7953b4e033"
        ],
        "_id": "5ea47ad5e9ab5d7953b4e030",
        "name": "20200425-1",
        "user": "5ea3eb794061d354ab779c3e",
        "company": "5ea3eb794061d354ab779c3d",
        "createdAt": "2020-04-25T18:00:53.656Z",
        "updatedAt": "2020-04-25T18:00:53.656Z",
        "optimizedAt": "2020-04-25T18:00:53.656Z",
        "__v": 0
    }
}

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.

Create Stop

POST https://packagelytics.com/api/v1/routes

Create a route with stops and assign it to a driver.

Headers

{
	"name": "Yellow Dog Brewing Co",
	"phone": "+16044920191",
	"address": "2817 Murray St #1, Port Moody, BC V3H 1X3, Canada",
	"lat": 49.278657,
	"lng": -122.8488629,
	"route": "5ea47ad5e9ab5d7953b4e030"
}

Output

{
    "message": "Stop has been created successfully",
    "data": {
        "phone": "+16044920191",
        "address": "2817 Murray St #1, Port Moody, BC V3H 1X3, Canada",
        "email": null,
        "lat": 49.278657,
        "lng": -122.8488629,
        "notes": null,
        "notes2": null,
        "orderId": null,
        "status": "draft",
        "reason": null,
        "pods": [],
        "signature": null,
        "package": null,
        "payment": null,
        "driverNotes": null,
        "order": 99,
        "arrivalTime": null,
        "finishTime": null,
        "goingAt": null,
        "goingLat": null,
        "goingLng": null,
        "arrivedAt": null,
        "arrivedLat": null,
        "arrivedLng": null,
        "skippedAt": null,
        "skippedLat": null,
        "skippedLng": null,
        "completedAt": null,
        "completedLat": null,
        "completedLng": null,
        "failedAt": null,
        "failedLat": null,
        "failedLng": null,
        "_id": "5ea49053e9ab5d7953b4e034",
        "name": "Yellow Dog Brewing Co",
        "route": "5ea47ad5e9ab5d7953b4e030",
        "createdAt": "2020-04-25T19:32:35.055Z",
        "updatedAt": "2020-04-25T19:32:35.055Z",
        "__v": 0
    }
}

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.

Dispatch Route

POST https://packagelytics.com/api/v1/routes/5ea47ad5e9ab5d7953b4e030/dispatch

Dispatch a route to its driver.

Headers

Output

{
    "message": "Route has been updated successfully"
}

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 updated