Track a shipment in real-time
Last updated
Was this helpful?
Last updated
Was this helpful?
Tracking a shipment in real time on your platform consists of creating an object to track the shipment and setting up an endpoint for webhooks.
Kublau uses this tracking object, called a Tracker, to track and handle all the states of the shipment until it’s delivered.
The tracker will be updated periodically based on when the carrier provides Kublau with new tracking information. This information can be consumed by using our .
To follow along the the steps in this guide we'll provide an interactive environment for Ruby, Python and Node. You can also use GraphQL directly with our .
Here is an example of how to make a tracker object:
The Tracker object contains both the current information about the package as well as previous updates. All of the previous updates are stored in the checkpoints
array. Each Checkpoint object contains the status
, the message
from the carrier and the scan time.
The status
field in Tracker can have several values. Below is a list of these statuses with an explanation.
Sometimes you may want to simulate specific tracking statuses (e.g. OUT_FOR_DELIVERY
) within your application to test how your application responds. Kublau has a set of test tracking codes that, when sent to the API, respond with specific tracking statuses
. The information that are sent by these test trackers will contain canned information.
Tracking Code
Status
K1000000000
UNKNOWN
K1000000001
PENDING
K1000000002
PICKED_UP
K1000000003
OUT_FOR_DELIVERY
K1000000004
IN_TRANSIT
K1000000005
DELIVERED
K1000000006
AVAILABLE_FOR_PICKUP
K1000000007
RETURN_TO_SENDER
K1000000008
ATTEMPT_FAILURE
Trackers are by default created in async mode if the async
argument for trackerCreate
is empty. We list their differences in the following table:
The API returns
A full up-to-date view of the tracker
An empty tracker with UNKNOWN status
API Response time
Varies per carrier. Most carriers will see 15 to 30 seconds.
From a hundred milliseconds to a couple of seconds.
API async value
"async": false
"async": true or leave empty (default value is true).
When to use?
When you care about the value of certain attribute of the tracker in the response right now.
When you don't care about the information of the tracker in the response right now.
When you only want Kublau to start tracking this shipment for you.
When you are okay with waiting for that information on a webhook. (2 mins avg. to first TRACKER_UPDATE webhook after trackerCreate call).
Sends update webhooks?
Yes
Yes
After you create a tracker, we will automatically start sending TRACKER_UPDATED
events. Event Objects are sent to the webhook URLs you’ve configured. Updates will only be sent when there is a status change for the package (e.g. a package changes from "Out for Delivery" to "Delivered").
You’ll know it is a tracking update event because the topic is TRACKER_UPDATED
. The data
value of Event will contain a Tracker object that has the information about the current progress of the package. When building application logic, the status
of Tracker object is most useful and reliable to use.
Add a new endpoint in your application. You can act on certain events by checking the type
field of the event object sent in the request body.
We include example webhook implementations so you can follow along:
You can configure your webhooks using the Kublau dashboard:
From your Kublau dashboard, go to Settings > Developer.
In the Webhooks section, click Create a webhook.
Select the TRACKER_UPATED
topic.
For testing webhooks, you can use:
Run a local server
Localhost
Internal network
Domains like www.example.com
Kublau domains such as kublau.com
and api.kublau.com
To test your webhook from the Kublau dashboard:
Go to the Webhooks section in Settings > Developer.
Click the Test button next to the webhook that you want to test.
Select the TRACKER_UPDATED
topic.
An example webhook is sent to the configured webhook URL.
When you are ready to deploy your webhook endpoint to production there are a couple things you need to do:
Use your live mode API keys and not your test mode keys.
Configure your production webhook endpoint in the Dashboard.
.
.
Input the URL where you want to receive notifications. Which if you're following along is the .
After you've created a webhook, you're presented with a secret to .
Any of the language specific .
Use a publicly available service such as .
If you decide to run a server locally, then you need to make it publicly available using a service such as or . The following URLs do not work as endpoints for webhooks:
That’s it! Your application is ready to accept live updates for a shipment. For more information .