Track()
This method is used to track a previously created label.
Syntax
module.exports = async function Track(request) { // Your code here}
import { TrackingRequest, TrackingResponse } from "@shipengine/connect-carrier-api";export default async function Track( request: TrackingRequest): Promise<TrackingResponse> { // Your code here}
Parameters
TrackingRequest
An object containing information about the label to track.
Name | Type | Nullable? | Description |
---|---|---|---|
authorization | ✔ | The authorization information necessary to fulfill this request. | |
metadata | ✔ | This object should contain all of the necessary properties needed to make authenticated requests with the carrier when an AuthProcess has not been configured. Every property included here will be persisted by ShipEngine Connect and included on each subsequent request from this user. | |
identifiers | ✔ | Array of identifiers describing the label to be tracked. | |
attributes | object[] | ✔ | Extra attributes of a shipment needed in tracking. |
attributes[].type | string | The attribute type. | |
attributes[].value | string | The value associated with that key. |
Return Value
TrackingResponse
This object model represents the response from a successful tracking request.
Name | Type | Required? | Description |
---|---|---|---|
metadata | This object should contain all of the necessary properties needed to make authenticated requests with the carrier. Every property included here will be persisted by ShipEngine Connect and included on each subsequent request from this user. | ||
tracking_info | object | ✔ | This model represents tracking information for a shipment. |
tracking_info
.carrier_name | string | The human readable name of the carrier tracking this shipment. | |
tracking_info
.tracking_number | string | The carrier specific tracking identifier for this shipment. | |
tracking_info
.standardized_status_code | string | ✔ | This represents the ShipEngine supported status codes for a shipment. Valid values include the following:
|
tracking_info
.carrier_status_code | string | The carrier specific status code of this shipment's tracking status. | |
tracking_info
.carrier_status_description | string | The human readable description of this shipment's tracking status. | |
tracking_info
.shipped_datetime | string | When the package(s) in this shipment were turned over to the carrier. Formatted per https://tools.ietf.org/html/rfc3339. Must be in UTC. | |
tracking_info
.estimated_delivery_datetime | string | When the package(s) in this shipment are expected to arrive at their destination. Formatted per https://tools.ietf.org/html/rfc3339. Must be in UTC. | |
tracking_info
.actual_delivery_datetime | string | When the package(s) in this shipment arrived at their destination. Formatted per https://tools.ietf.org/html/rfc3339. Must be in UTC. | |
tracking_info
.shipping_problem_description | string | A human readable description of why the shipment is in an error state. | |
tracking_info.weight | number | The weight measured by the carrier of the package(s) in this shipment. | |
tracking_info.dimensions | The dimensions measured by the carrier of the package(s). | ||
tracking_info.service | object | A shipping provider specific service. | |
tracking_info
.service
.code | string | The code specific to a shipping provider service. | |
tracking_info
.service
.name | string | The name of this shipping provider service. | |
tracking_info.packaging | string | The carrier observed type of packages in this shipment. | |
tracking_info
.package_count | number | The carrier observed count of packages in this shipment. | |
tracking_info.events | The list of events that happened throughout the shipment's lifetime. | ||
tracking_info
.shipping_problem | boolean | Whether or not this shipment has entered an error state. | |
tracking_info
.shipping_problem_code | string | The unique identifying code for the type of error encountered by this shipment. | |
tracking_info
.error_description | string | The human readable explanation of the error encountered by this shipment. |
Example
module.exports = async function Track(request) { // STEP 1: Validation // STEP 2: Create the data that the carrier's API expects let data = { operation: "track", session_id: request.metadata.id, tracking_number: request.identifiers.filter((identifier) => identifier.type === 'tracking_number').value, }; // STEP 3: Call the carrier's API const response = await apiClient.request({ data }); // STEP 4: Create the output data that ShipEngine expects return formatTrack(response.data);}
import { TrackingRequest, TrackingResponse} from "@shipengine/connect-carrier-api";export default async function Track(request: TrackingRequest): Promise<TrackingResponse> { // STEP 1: Validation // STEP 2: Create the data that the carrier's API expects let data = { operation: "track", session_id: request.metadata.id, tracking_number: request.identifiers.filter((identifier) => identifier.type === 'tracking_number').value, }; // STEP 3: Call the carrier's API const response = await apiClient.request<TrackAPIResponse>({ data }); // STEP 4: Create the output data that ShipEngine expects return formatTrack(response.data);}