Tracking

Code Samples for Tracking: Java (.zip) | PHP (.zip) | C# (.zip)

Get Tracking Details – REST

Summary

Name: Get Tracking Details
Reason to Call: To get all tracking events for a single parcel
Input: PIN/DNC Number
Output: Basic parcel information, dates, location and status for each event. Summary parcel information.
Error Examples: no PIN History
Possible Prior Calls: Get Tracking Summary
Possible Next Calls: Get Signature Image, Get Delivery Confirmation Certificate
Version history: Release notes

Request Details

Request – Structure for Get Tracking Details

Endpoint

GET https://XX/vis/track/pin/{pin number}/detail
or
GET https://XX/vis/track/dnc/{dnc number}/detail

Replace... With...

XX (Development)

ct.soa-gw.canadapost.ca

XX (Production)

soa-gw.canadapost.ca

{pin number}

the parcel PIN

{dnc number}

the delivery notice card number

HTTP Headers

HTTP Header Variable

Value

Accept

application/vnd.cpc.track-v2+xml (Note: */* in place of the header value will return an error)

Authorization

Basic {Base64 encoding of userid:password}

Accept-language

en-CA or fr-CA

Body

None

Request – Elements

The following table describes the two possible parameters used to identify the parcel for which information is being requested.

Get Tracking Details – REST – Request Parameters
Parameter Name Description / Size / Format

{pin number}

The PIN (Parcel Identification Number) assigned by Canada Post on creation of the shipping label and used for tracking purposes.

(12, 13 or 16 characters)

When executing a request by PIN, this is mandatory and is the only parameter necessary.

The {pin number} is embedded into the URI as follows:

XX/vis/track/pin/{pin number}/detail

dnc

The Delivery Notice Card (DNC) number – The number on the card left by delivery personnel when no one is home to receive the delivery.

(15 numeric characters)

When executing a request by DNC number, this is mandatory and is the only parameter necessary.

The {dnc number} is embedded into the URI as follows:

XX/vis/track/dnc/{dnc number}/detail

Response Details

Response – Elements

Get Tracking Details – REST – Detailed View of Response Elements
Field Name Description
tracking-detail The top level of the XML structure.

pin

The PIN that can be used for other tracking calls

active-exists

1 | 0

"1" Indicates that the tracking information is contained in the active data repository.

archive-exists

1 | 0

"1" Indicates that the tracking information is contained in the archive data repository.

destination-postal-id

First 3 digits of the destination Postal Code for parcels to be delivered in Canada.

^[ABCEGHJKLMNPRSTVXY]{1}\d{1}[A-Z]{1}

For international parcels this is the Postal Identifier of the destination country (e.g. ZIP code for parcels with U.S. destination) or an identifier of the destination country

expected-delivery-date

yyyy-mm-dd

The date the item is expected to reach the destination address for addresses in Canada.

If the item has been mailed from or to an international location this date may be blank.

changed-expected-date

yyyy-mm-dd

Indicates a new expected delivery date.

changed-expected-delivery-reason

Text description of reason for change to expected delivery date.

mailed-by-customer-number

Customer number of the mailing customer.

mailed-on-behalf-of-customer-number

Customer number of the mailed-on-behalf-of customer if applicable.

original-pin

In the situation where a parcel is being returned and the original parcel was created with an anticipated return, this field will contain the original PIN when the return PIN is queried.

service-name

Canada Post service name in the language specified by the request. (The service-name will default to English if language is not specified).

For inbound international parcels, service type is empty or contains the service name from its shipper of origin if available.

service-name-2

Canada Post service name in the other Canadian official language. For inbound international parcels, service name is empty or contains the service name from its shipper of origin.

customer-ref-1

The value supplied by the shipper as customer-ref-1 when the shipment was first created with Canada Post. French character set is supported through this interface.

customer-ref-2

The value supplied by the shipper as customer reference 2 when the shipment was first created with Canada Post.

Special characters should be avoided when entering customer reference numbers.

return-pin

In the situation where a parcel is being sent with an anticipated return, this field will contain the return PIN when the original PIN is queried.

signature-image-exists

true | false

True indicates that Get Signature Image will return a signature image. If false, there is no need to call Get Signature Image because it will return “not found”.

suppress-signature

true | false

Indicates whether a signature image collected by Canada Post for domestic parcels has been requested to be suppressed for viewing by the recipient of a parcel.

delivery-options

The set of delivery options requested for this parcel.

delivery-option

The string representing the delivery-option.

delivery-option-description

The description of the delivery option.

significant-events

The list of events associated with this parcel.

occurrence

The parent element of one set of significant event details.

event-identifier

Event identifier used to identify event types.

event-date

yyyy-mm-dd - date of a tracking event

event-time

hh:mm:ss - time of a tracking event

event-time-zone

Time zone associated with an event. May not be populated for international tracking events.

event-description

A brief description of the event.

signatory-name

If the event presented is a signature capture event, the text of this field will represent the name of the signature.

Note: For enhanced privacy and security, the signatory name will now always be empty. It may be removed in a future release.

event-site

Site information provided by the parcel handler.

event-province

For domestic events, this contains the province that the event occurred in.

event-retail-location-id

Contains the office-id where a parcel is being/was retained.

event-retail-name

Retail name of the location where a parcel is/was held.

cod-remit-info

Information associating a COD parcel with the remittance tracking event or vice versa.

pin

This instance of the PIN specifies the PIN of the COD remittance or the original parcel depending on the value of type.

type

Has the value COD_PIN or REMIT_PIN and indicates what PIN is contained in the PIN value immediately above.

id

 Code associated with the failure of a query.

description

Text message associated with a code.

Response – Possible Error Responses

A correctly structured request may receive one of the following application error responses:

Code Description

004

No PIN History

002

Duplicate PIN

Response – XML Diagram

Examples

Sample REST XML – PIN Detail Request

GET https://XX/vis/track/pin/7023210039414604/detail

Sample REST XML – PIN Detail Response

<tracking-detail>
<pin>7023210039414604</pin>
<active-exists>1</active-exists>
<archive-exists/>
<changed-expected-date/>
<destination-postal-id>K0J1T0</destination-postal-id>
<duplicate-flag-ind/>
<expected-delivery-date>2011-04-05</expected-delivery-date>
<changed-expected-delivery-reason/>
<mailed-by-customer-number>0007023210</mailed-by-customer-number>
<mailed-on-behalf-of-customer-number>0007023210</mailed-on-behalf-of-customer-number>
<original-pin/>
<service-name>Expedited Parcels</service-type>
<service-name-2>Colis acc&#233;l&#233;r&#233;s</service-name-2>
<customer-ref-1>APRIL1REF1A</customer-ref-1>
<customer-ref-2>APRIL1REF1C</customer-ref-2>
<return-pin/>
<signature-image-exists>false</signature-image-exists>
<suppress-signature>false</suppress-signature>
<delivery-options>
<item>
<delivery-option>CH_HLD_PCK_UP</delivery-option>
<delivery-option-description>Card for Pickup</delivery-option-description>
</item>
<item>
<delivery-option>CH_SGN_OPTION</delivery-option>
<delivery-option-description>Signature Required</delivery-option-description>
</item>
<item>
<delivery-option>CH_SGN_OPTION</delivery-option>
<delivery-option-description>Proof of Age Required</delivery-option-description>
</item>
<item>
<delivery-option>CH_COD_VALUE</delivery-option>
<delivery-option-description>COD Amount</delivery-option-description>
</item>
</delivery-options>
<significant-events>
<item>
<event-identifier>3000</event-identifier>
<event-date>2011-04-04</event-date>
<event-time>13:34:57</event-time>
<event-time-zone>EST</event-time-zone>
<event-description>Order information received by Canada Post</event-description>
<signatory-name/>
<event-site>OTTAWA</event-site>
<event-province>ON</event-province>
<event-retail-location-id/>
<event-retail-name/>
</item>
</significant-events>
</tracking-detail>

Sample REST XML – DNC Detail Request

GET https://XX/vis/track/dnc/315052413796541/detail

Sample REST XML – DNC Detail Response

<tracking-detail>
<pin>1371134583769923</pin>
<active-exists>1</active-exists>
<archive-exists></archive-exists>
<changed-expected-date>2011-02-11</changed-expected-date>
<destination-postal-id>G1K4M7</destination-postal-id>
<expected-delivery-date>2011-02-01</expected-delivery-date>
<changed-expected-delivery-reason>Customer addressing error found; attempting to correct</changed-expected-delivery-reason>
<mailed-by-customer-number>0001234567</mailed-by-customer-number>
<mailed-on-behalf-of-customer-number>0008765432</mailed-on-behalf-of-customer-number>
<original-pin></original-pin>
<service-name>Xpresspost</service-name>
<service-name-2>Xpresspost</service-name-2>
<customer-ref-1>955-0398</customer-ref-1>
<customer-ref-2></customer-ref-2>
<return-pin></return-pin>
<signature-image-exists>true</signature-image-exists>
<suppress-signature>false</suppress-signature>
<delivery-options>
<item>
<delivery-option>CH_SGN_OPTION</delivery-option>
<delivery-option-description>Signature Required</delivery-option-description>
</item>
</delivery-options>
<significant-events>
<occurrence>
<event-identifier>20</event-identifier>
<event-date>2011-02-03</event-date>
<event-time>11:59:59</event-time>
<event-time-zone>EST</event-time-zone>
<event-description>Signature image recorded for Online viewing</event-description>
<signatory-name>HETU</signatory-name>
<event-site>SAINTE-FOY</event-site>
<event-province>QC</event-province>
<event-retail-location-id></event-retail-location-id>
<event-retail-name></event-retail-name>
</occurrence>
<occurrence>
<event-identifier>0174</event-identifier>
<event-date>2011-02-03</event-date>
<event-time>08:27:43</event-time>
<event-time-zone>EST</event-time-zone>
<event-description>Item out for delivery</event-description>
<signatory-name></signatory-name>
<event-site>SAINTE-FOY</event-site>
<event-province>QC</event-province>
<event-retail-location-id></event-retail-location-id>
<event-retail-name></event-retail-name>
</occurrence>
<occurrence>
<event-identifier>0100</event-identifier>
<event-date>2011-02-02</event-date>
<event-time>14:45:48</event-time>
<event-time-zone>EST</event-time-zone>
<event-description>Item processed at postal facility</event-description>
<signatory-name></signatory-name>
<event-site>QUEBEC</event-site>
<event-province>QC</event-province>
<event-retail-location-id></event-retail-location-id>
<event-retail-name></event-retail-name>
</occurrence>
<occurrence>
<event-identifier>0173</event-identifier>
<event-date>2011-02-02</event-date>
<event-time>06:19:57</event-time>
<event-time-zone>EST</event-time-zone>
<event-description>Customer addressing error found; attempting to correct. Possible delay</event-description>
<signatory-name></signatory-name>
<event-site>QUEBEC</event-site>
<event-province>QC</event-province>
<event-retail-location-id></event-retail-location-id>
<event-retail-name></event-retail-name>
</occurrence>
<occurrence>
<event-identifier>1496</event-identifier>
<event-date>2011-02-01</event-date>
<event-time>07:59:52</event-time>
<event-time-zone>EST</event-time-zone>
<event-description>Item successfully delivered</event-description>
<signatory-name></signatory-name>
<event-site>QUEBEC</event-site>
<event-province>QC</event-province>
<event-retail-location-id></event-retail-location-id>
<event-retail-name></event-retail-name>
</occurrence>
<occurrence>
<event-identifier>20</event-identifier>
<event-date>2011-02-01</event-date>
<event-time>07:59:52</event-time>
<event-time-zone>EST</event-time-zone>
<event-description>Signature image recorded for Online viewing</event-description>
<signatory-name>R GREGOIRE</signatory-name>
<event-site>QUEBEC</event-site>
<event-province>QC</event-province>
<event-retail-location-id></event-retail-location-id>
<event-retail-name></event-retail-name>
</occurrence>
</significant-events>
</tracking-detail>