# Tracking

## Get Shipment Tracking

<mark style="color:red;">`GET`</mark> `https://api-sandbox.shiplemon.com/public/v1/shipments/:id/tracking`

This endpoint allows you to retrieve the shipment tracking information for a given `shipmentId`.&#x20;

#### Update interval:

Call this endpoint every hour at **:05** and **:35**.

{% tabs %}
{% tab title="200 tracking info retrieved" %}

```json
{
    "status": "ok",
    "data": {
        "partner_id": "partner_id",
        "driver": "elta",
        "carrier": {
            "code": "elta",
            "name": "ELTA Courier",
            "image": "https://static.shiplemon.com/providers/eltacourier.svg"
        },
        "service": {
            "code": "elta_courier_porta_porta",
            "name": "Porta-Porta",
            "estimated_delivery_in_days": 6
        },
        "tracking_status": "DELIVERED",
        "tracking_history": [
            {
                "status": "DELIVERED",
                "status_exact": null,
                "status_date": "2024-07-15T10:02:00.000Z",
                "status_details": "ΠΑΡΑΛΑΒΗ ΑΠΟ ΣΤΑΘΜΟ ΜΕ ΔΗΛΩΣΗ ΠΑΡΑΛΗΠΤΗ"
            },
            {
                "status": "TRANSIT",
                "status_exact": "WITH_COURIER",
                "status_date": "2024-07-15T09:45:00.000Z",
                "status_details": "ΠΡΟΣ ΠΑΡΑΔΟΣΗ"
            },
            {
                "status": "PRE_TRANSIT",
                "status_exact": null,
                "status_date": "2024-07-12T14:17:00.000Z",
                "status_details": "ΔΗΜΙΟΥΡΓΙΑ ΣΥ.ΔΕ.ΤΑ. ΑΠΟ ΠΕΛΑΤΗ"
            }
        ],
        "tracking_ref": "tracking_ref",
        "tracking_url": "tracking_url",
        "country_from": "GR",
        "country_to": "GR"
    }
}
```

{% endtab %}
{% endtabs %}

## Update Shipment Tracking

<mark style="color:red;">`PUT`</mark> `https://api-sandbox.shiplemon.com/v1/shipments/:id/tracking`

This endpoint allows you to update the shipment tracking with the given `shipmentId`

#### Path Parameters

<table><thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td>id</td><td>string</td><td>The `id` of the shipment that needs to be updated.</td></tr><tr><td>tracking_history</td><td>array</td><td><p>The payload should always include the entire tracking history.</p><pre class="language-typescript"><code class="lang-typescript">  status: string;
  status_date: string;
  status_details: string;
  status_exact: string | null;
</code></pre></td></tr></tbody></table>

#### Accepted values

The `status` and `status_date` have specific format as shown below:

`status`: DELIVERED, TRANSIT, PRE\_TRANSIT, EXCEPTION (case sensitive)\
`status_date`: must be in ISO 8601 format (YYYY-MM-DDTHH:MM:SS.sssZ)

{% tabs %}
{% tab title="200 shipment successfully updated." %}

```json
{
    "status": "ok",
    "data": {
        "id": "60476d7500e47cb69693a202",
        "driver": "dhl",
        "pickup_ref": "CBJ180121002626",
        "tracking_ref": "1190953890",
        "tracking_url": "http://www.dhl-usa.com/content/us/en/express/tracking.shtml?brand=DHL&AWB=1190953890",
        "tracking_status": "PRE_TRANSIT",
        "tracking_history": [
            {
              "status": "DELIVERED",
              "status_date": "2023-11-20T00:00:01.992Z",
              "status_details": "ΠΑΡΑΔΟΣΗ ΑΠΟ ΔΙΑΝΟΜΕΑ"
            },
            {
              "status": "EXCEPTION",
              "status_date": "2023-11-20T00:00:02.195Z",
              "status_details": "ΑΚΥΡΩΣΗ ΑΠΟ ΔΙΑΝΟΜΕΑ"
            },
            {
              "status": "TRANSIT",
              "status_date": "2023-11-20T00:00:02.075Z",
              "status_details": "ΕΚΦΟΡΤΩΣΗ ΑΠΟ ΜΕΤΑΦΟΡΙΚΟ ΜΕΣΟ"
            },
            {
              "status": "PRE_TRANSIT",
              "status_date": "2023-11-20T00:00:02.064Z",
              "status_details": "ΔΗΜΙΟΥΡΓΙΑ ΣΥ.ΔΕ.ΤΑ. ΑΠΟ ΠΕΛΑΤΗ"
            }
          ],
  "tracking_history_last_updated_at": "2022-08-08T09:15:00.947Z", 
  "label_url": "https://static.shiplemon.com/sandbox/labels/ups/1ZXXXXXXXXXXXXXXXX.pdf",
  "child_vouchers": [
    {
      "tracking_ref": "2338891501",
      "tracking_url": "",
      "label_url": "https://static.shiplemon.com/sandbox/labels/boxnow/2338891501.pdf"
    }
   ],
        "label_url": "https://deliver.goshippo.com/2519d201e88b4be8a3500a84c1608374.pdf?Expires=1646829812&Signature=qjByvemk0FAA7fnKPpCtd~Almiz96cFGmKyGseVNSBD~sYu4b4Q5EdG~WEhjFRefknu5HQnA76P3YTEh2NGRYL~fRGeueyjPEEpqW~V1E5WIHkJBnpVDJFKutwevlryOPBDy0x3Px-KY7iFUgagDdofg4lPIoD-PZnWffPapgT1xZUZS~9esQOEcAqdrBPuSO1i3ufdBCJLRIoM7XALD2-VmWcQWi2qS5YokKDEcEuRj88lcBIxiY9V9Wp~cNukLidrJlEVmvsFPhBzY6Y5M5xwIrTKFZSyeTs-B7rZQUgE5jSvA7YNcm0raw-N2t72om47BXKp0uVKEtinQ6TUnOQ__&Key-Pair-Id=APKAJRICFXQ2S4YUQRSQ",
        "invoice_url": null,
        "address_from": {
            "country": "GR",
            "zip": "14451",
            "name": "SG1",
            "state": "I",
            "city": "Athens",
            "address": "Ermou 3",
            "email": "example@gmail.com",
            "phone": "+306933000000",
            "notes": ""
        },
        "address_to": {
            "name": "SG2",
            "country": "GR",
            "state": "I",
            "city": "Athens",
            "zip": "14451",
            "address": "Dimosthenous 45",
            "email": "example@gmail.com",
            "phone": "+306933000000"
        },
        "items": [
            {
                "weight": 2000,
                "height": 10,
                "width": 30,
                "length": 20,
                "notes": "Nike air max",
                "value": 10,
                "currency": "EUR"
            },
            {
                "weight": 2000,
                "height": 10,
                "width": 30,
                "length": 20,
                "notes": "Nike air max",
                "value": 10,
                "currency": "EUR"
            }
        ],
        "pickup": {
            "date": "2021-03-12",
            "time": "09:00-18:00"
        },
        "rate": {
            "id": "dhl_dhlexpress-domesticexpressdoc_20531b76ce4943bb95c51509fc6e945d",
            "driver": "dhl",
            "provider": {
                "name": "DHL Express",
                "image": "https://shippo-static.s3.amazonaws.com/providers/200/DHL.png"
            },
            "service": {
                "name": "DOMESTIC EXPRESS DOC",
                "estimated_delivery_in_days": 1
            },
            "total_amount": 26.34,
            "currency": "EUR",
            "printing_required": true,
            "transportation": "road",
            "metadata": {
                "items": [
                    {
                        "weight": 2000,
                        "height": 10,
                        "width": 30,
                        "length": 20,
                        "notes": "Nike air max",
                        "value": 10,
                        "currency": "EUR"
                    },
                    {
                        "weight": 2000,
                        "height": 10,
                        "width": 30,
                        "length": 20,
                        "notes": "Nike air max",
                        "value": 10,
                        "currency": "EUR"
                    }
                ],
                "address_from": {
                    "country": "GR",
                    "zip": "14451"
                },
                "address_to": {
                    "country": "GR",
                    "zip": "14121"
                }
            }
        }
    }
}
```

{% endtab %}
{% endtabs %}

## Example Request

{% tabs %}
{% tab title="cURL" %}

```
curl --location --request PUT 'https://api-sandbox.shiplemon.com/v1/shipments/<shipment_id>/tracking' \
--header 'x-api-key: <YOUR_API_KEY>' \
--header 'Content-Type: application/json'
```

{% endtab %}
{% endtabs %}

## Example response

```json
{
    "status":"ok",
    "data":{
        "id":"be96511d-ba23-4268-bd8b-48c9cf930222",
        "partner_id":"partner_id",
        "invoice_id":null,
        "partner_credentials_used":true,
        "related_order_id":null,
        "payment_ref":null,
        "payment_amount":null,
        "state":"created",
        "driver":"elta",
        "pickup_ref":null,
        "tracking_ref":"tracking_ref",
        "tracking_url":"https://www.elta-courier.gr/search?br=ZU500011420GR",
        "tracking_status":"PRE_TRANSIT",
        "tracking_history":[
            {
              "status": "DELIVERED",
              "status_date": "2023-11-20T00:00:01.992Z",
              "status_details": "ΠΑΡΑΔΟΣΗ ΑΠΟ ΔΙΑΝΟΜΕΑ"
            },
            {
              "status": "EXCEPTION",
              "status_date": "2023-11-20T00:00:02.195Z",
              "status_details": "ΑΚΥΡΩΣΗ ΑΠΟ ΔΙΑΝΟΜΕΑ"
            },
            {
              "status": "TRANSIT",
              "status_date": "2023-11-20T00:00:02.075Z",
              "status_details": "ΕΚΦΟΡΤΩΣΗ ΑΠΟ ΜΕΤΑΦΟΡΙΚΟ ΜΕΣΟ"
            },
            {
              "status": "PRE_TRANSIT",
              "status_date": "2023-11-20T00:00:02.064Z",
              "status_details": "ΔΗΜΙΟΥΡΓΙΑ ΣΥ.ΔΕ.ΤΑ. ΑΠΟ ΠΕΛΑΤΗ"
            }
          ],
  "tracking_history_last_updated_at": "2022-08-08T09:15:00.947Z", 
  "label_url": "https://static.shiplemon.com/sandbox/labels/ups/1ZXXXXXXXXXXXXXXXX.pdf",
  "child_vouchers": [
    {
      "tracking_ref": "tracking_ref",
      "tracking_url": "",
      "label_url": "https://static.shiplemon.com/sandbox/labels/boxnow/2338891501.pdf"
    }
  ],
        "label_url":"https://static.shiplemon.com/labels/elta/ZU500011420GR.pdf",
        "address_from":{
            "_id":"61a15f9cfb38f514bd732222",
            "country":"GR",
            "company":"",
            "name":"John Doe",
            "phone":"+306912345678",
            "email":"john@mail.com",
            "address":"Jane Street 1",
            "state":"I",
            "city":"Athens",
            "zip":"11111",
        },
        "address_to":{
            "country":"GR",
            "country_code":"GR",
            "dial_code":"+30",
            "name":"Mary Doe",
            "zip":"11111",
            "city":"Athns",
            "address":"Jane Street 2",
            "phone":"+306912345678"
        },
        "items":[{
            "width":1,
            "height":1,
            "length":1,
            "weight":5000,
            "label":"Box",
            "notes":"Box",
            "invoice_lines":[]
        }],
        "pickup":null,
        "pickup_at":null,
        "delivered_at":null,
        "rate":{
            "id":"elta_1_790db74a-2b6f-4eaa-8918-60de9f192222",
            "driver":"elta",
            "provider":{
                "name":"ELTA Courier",
                "image":"https://static.shiplemon.com/providers/eltacourier.svg"
            },
            "service":{
                "code":"elta_courier_porta_porta",
                "name":"Porta-Porta",
                "estimated_delivery_in_days":3
            },
            "total_amount":0,
            "total_without_tax_amount":0,
            "tax_amount":0,
            "currency":"EUR",
            "printing_required":true,
            "has_cash_on_delivery":true,
            "has_custom_credentials":true,
            "has_shipment_pickup_combined":false,
            "has_tracking_code_on_pickup":false,
            "has_pickup":false,
            "transportation":"road",
            "metadata":{
                "address_from":{
                    "_id":"61a15f9cfb38f514bd732222",
                    "country":"GR",
                    "company":"",
                    "name":"John Doe",
                    "phone":"+306912345678",
                    "email":"john@mail.com",
                    "address":"Jane Street 1",
                    "state":"I",
                    "city":"Athens",
                    "zip":"11111",
                },
                "address_to":{
                    "country":"GR",
                    "country_code":"GR",
                    "dial_code":"+30",
                    "name":"Mary Doe",
                    "zip":"11111",
                    "city":"Athns",
                    "address":"Jane Street 2",
                    "phone":"+306912345678"
                },
                "items":[{
                    "width":1,
                    "height":1,
                    "length":1,
                    "weight":5000,
                    "label":"Box",
                    "notes":"Box",
                    "invoice_lines":[]
                }]
            },
            "cash_on_delivery":0,
            "logs":[],
            "tags":[],
            "notifications":[],
            "created_at":"2022-01-03T08:30:23.065Z",
            "updated_at":"2022-01-03T08:30:23.081Z"
        }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.shiplemon.com/endpoints/shipments/tracking.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
