Check on Tracking

After your job has been processed you can check on the shipment tracking by doing a GET call on /jobs//Tracking endpoint using the ID returned from the /jobs call that created the job. This is an optional call that you can also check through the website as well even if you submitted your job via API.

Important The tracking information is only provided back to Click2Mail once per day so calling it once per day is sufficient to get the most up to date information.
Note In the staging environment the API will never return tracking details as the items are never actually sent.

The one required parameter is trackingType, which we will set to 'IMB' for this tutorial. Acceptable values are 'IMB' meaning Intelligent Mail Barcode, and 'IMPB' meaning Intelligent Mail Package Barcode.

An optional parameter is to specify the desire for tracking details. By default this value is set to false.

The following code sample demonstrates submitting a job.

# Load the HTTP requests module
import requests

# Note the ID of the previously-created job
jobId = '8675309'

# Define the endpoint to use, including the jobId
url = "https://stage-rest.click2mail.com/molpro/jobs/" + jobId + "/tracking"

# Define credentials
myusername = 'awesomeuser'
mypassword = 'gReAt/PaSsWoRd123'

headers = {'user-agent': 'my-app/0.0.1'}

# Set the tracking for the job
values = {'trackingType': 'IMB'}

# Make the POST call
r = requests.post(url, data=values, headers=headers, auth=(myusername, mypassword))

# Display the result - a success should return status_code 201
print(r.status_code)

# Display the full XML returned.
print(r.text)