# Tracking

This endpoint allows you to check the status of a shipment.

It is possible to search for a shipment using one of the following parameters:

* **id :** Shipment ID
* **ddt\_num :** Numeric reference of the shipment
* **ddt\_alpha :** Alphanumeric reference of the shipment

**Please note :** You must indicate at least one of the abovementioned parameters.

If the parameters are not unique and if the ddt\_num and/or the ddt\_alpha are used as parameters, an array with the data of all the shipments corresponding to the used parameters will be shown in the response.

## Shows the shipment status

<mark style="color:blue;">`GET`</mark> `https://api.gsped.it/[INSTANCE]/tracking`

#### Path Parameters

| Name       | Type    | Description                            |
| ---------- | ------- | -------------------------------------- |
| id         | Integer | Shipment ID                            |
| ddt\_num   | String  | Numeric reference of the shipment      |
| ddt\_alpha | String  | Alphanumeric reference of the shipment |

#### Headers

| Name                                        | Type   | Description           |
| ------------------------------------------- | ------ | --------------------- |
| x-api-key<mark style="color:red;">\*</mark> | String | Apikey given by Gsped |

{% tabs %}
{% tab title="200: OK OK" %}

```javascript
{
    "status_code": 19,
    "status": "CONSEGNATO",
    "delivery_date": "2021-03-30 11:00:00",
    "fid_partenza": 2,
    "num_serie": 1,
    "num_spedizione": "0585596",
    "corriere_id": 1,
    "corriere": "BRT",
    "ddt_num": 18795,
    "ddt_alpha": "100027946",
    "client_id": 1,
    "tracking_link": "https://vas.brt.it/vas/sped_det_show.hsm?nspediz=002010585132",
    "id_gsped": 18795
}
```

{% endtab %}

{% tab title="400: Bad Request Parameters not indicated or incorrect field" %}

```javascript
{
    "error": "Riferimento spedizione non indicato"
}
```

{% endtab %}

{% tab title="403: Forbidden Invalid Apikey has been used" %}

```javascript
{
    "status": false,
    "error": "Invalid API key "
}
```

{% endtab %}

{% tab title="404: Not Found Shipment not found" %}

```javascript
{
    "error": "Spedizione non trovata"
}
```

{% endtab %}
{% endtabs %}

## **Example Snippets :**

ID calls examples:

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

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => 'https://api.gsped.it/sandbox/tracking?id=18795',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => '',
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 0,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_HTTPHEADER => array(
        'x-api-key: YOUR-API-KEY'
    ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
```

{% endtab %}

{% tab title="Python" %}

```python
import http.client

conn = http.client.HTTPSConnection("api.gsped.it")
payload = ''
headers = {
  'x-api-key': 'YOUR-API-KEY'
}
conn.request("GET", "/sandbox/tracking?id=jhon", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))ph
```

{% endtab %}

{% tab title="GO" %}

```go
package main

import (
  "fmt"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://api.gsped.it/sandbox/tracking?id=jhon"
  method := "GET"

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, nil)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("x-api-key", "YOUR-API-KEY")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := ioutil.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
var clientHandler = new HttpClientHandler
{
    UseCookies = false,
};
var client = new HttpClient(clientHandler);
var request = new HttpRequestMessage
{
    Method = HttpMethod.Get,
    RequestUri = new Uri("https://api.gsped.it/sandbox/tracking?id=18795"),
    Headers =
    {
        { "x-api-key", "YOUR-API-KEY" },
    },
};
using (var response = await client.SendAsync(request))
{
    response.EnsureSuccessStatusCode();
    var body = await response.Content.ReadAsStringAsync();
    Console.WriteLine(body);
}
```

{% endtab %}

{% tab title="cURL" %}

```bash
curl --location --request GET 'https://api.gsped.it/sandbox/tracking?id=jhon' \
--header 'x-api-key: YOUR-API-KEY'
```

{% endtab %}
{% endtabs %}


---

# 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://apidocs.gsped.com/gsped-api-english-version/spedizioni-e-dintorni/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.
