# Shipment

## Shipment - GET

This endpoint allows to manage the creation, the data retrieval and the cancellation of any shipment on Gsped.

## Shipment -GET

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

Retrieves all the information about a shipment, including the labels.

#### Query Parameters

| Name                                 | Type   | Description               |
| ------------------------------------ | ------ | ------------------------- |
| id<mark style="color:red;">\*</mark> | String | Unique ID 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  Shipment information" %}

```javascript
{
    // Response
}
```

{% endtab %}

{% tab title="400: Bad Request Bad request" %}

```javascript
{
    // Response
}
```

{% endtab %}

{% tab title="403: Forbidden Invalid apikey" %}

```javascript
{
    // Response
}
```

{% endtab %}

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

```javascript
{
    // Response
}
```

{% endtab %}
{% endtabs %}

### Example Snippets

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

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.gsped.it/sandbox/Shipment?id=70059765",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_POSTFIELDS => "",
  CURLOPT_HTTPHEADER => [
    "x-api-key: YOUR-API-KEY"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  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/Shipment?id=70059765", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
```

{% endtab %}

{% tab title="GO" %}

```go
package main

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

func main() {

	url := "https://api.gsped.it/sandbox/Shipment?id=70059765"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("x-api-key", "YOUR-API-KEY")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := ioutil.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

{% endtab %}

{% tab title="C#" %}

```csharp
// Some codevar client = new HttpClient();
var request = new HttpRequestMessage
{
    Method = HttpMethod.Get,
    RequestUri = new Uri("https://api.gsped.it/sandbox/Shipment?id=70059765"),
    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" %}

```shell
curl --request GET \
  --url 'https://api.gsped.it/sandbox/Shipment?id=70059765' \
  --header 'x-api-key: YOUR-API-KEY'
```

{% endtab %}
{% endtabs %}

## Shipment - POST

The Shipment Post call allows to create the shipment.

If the operation is successful, it returns the shipment data together with their labels in all the available formats.

{% hint style="info" %}
The shipment creation is not always successful; both Gsped and the courier's systems perform a series of checks on the data received. All the possible errors must be properly managed.
{% endhint %}

To check the outcome of the calls, follow these steps:​ ​

Check the response of the API on the shipment creation POST. There are two possible HTTP responses:

**400**: The data failed to pass the first series of controls. The type of problem is displayed in the field **error** (e.g. a required field is missing).

**200**: the data have been validated and the waybill generation has been started. At this point, the value of the field status must be checked; if it displays the value 0 the waybill has correctly been generated and could be downloaded from the right section. **If the status field displays the value 0.6 the generation of the waybill has failed and the field error shows the occurred type of problem** (eg. inconsistent zip code and city, address not accepted by the courier's systems, service not available for the destination, etc. )

## Shipment POST

<mark style="color:green;">`POST`</mark> `https://api.gsped.it/[INSTANCE]/Shipment`

Shipment creation

#### Headers

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

#### Request Body

| Name                                                                   | Type   | Description                                                                                                                                                                                                                                                      |
| ---------------------------------------------------------------------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| corriere<mark style="color:red;">\*</mark>                             | Int    | <p>Gsped courier ID</p><p><a data-mention href="/pages/t7vgUwLziChc9cICUbid">/pages/t7vgUwLziChc9cICUbid</a></p><p>)</p>                                                                                                                                         |
| servizio<mark style="color:red;">\*</mark>                             | Int    | <p>Gsped service ID</p><p><a data-mention href="/pages/t7vgUwLziChc9cICUbid">/pages/t7vgUwLziChc9cICUbid</a></p><p>)</p>                                                                                                                                         |
| client\_id<mark style="color:red;">\*</mark>                           | Int    | Client ID given by Gsped                                                                                                                                                                                                                                         |
| ddt\_alpha                                                             | String | Alphanumeric reference of the shipment. If not defined, Gsped creates one automatically                                                                                                                                                                          |
| ddt\_num                                                               | String | Numeric reference of the shipment. If not defined, Gsped creates one automatically                                                                                                                                                                               |
| merce<mark style="color:red;">\*</mark>                                | String | Generic description of the shipped goods                                                                                                                                                                                                                         |
| origine<mark style="color:red;">\*</mark>                              | String | Iso 2 char of the Provenience of the goods (nation)                                                                                                                                                                                                              |
| contrassegno                                                           | Float  | COD amount                                                                                                                                                                                                                                                       |
| tipo\_incasso                                                          | Int    | <p>ID type of payment:see - -></p><p><a data-mention href="/pages/EiSA1uhadaw43tB6Noma#tipologia-incassi-contrassegno">/pages/EiSA1uhadaw43tB6Noma#tipologia-incassi-contrassegno</a></p>                                                                        |
| valuta                                                                 |        | Iso 4217 currency symbol                                                                                                                                                                                                                                         |
| valore                                                                 | Float  | Assurance amount                                                                                                                                                                                                                                                 |
| peso<mark style="color:red;">\*</mark>                                 | Float  | Weight of the shipment (KG)                                                                                                                                                                                                                                      |
| volume<mark style="color:red;">\*</mark>                               | Float  | Volume of the shipment (cu m)                                                                                                                                                                                                                                    |
| colli<mark style="color:red;">\*</mark>                                | Int    | Number of parcels                                                                                                                                                                                                                                                |
| daticolli                                                              | Array  | Size of the parcels                                                                                                                                                                                                                                              |
| daticolli.altezza                                                      | Int    | Height of the single parcels in cm                                                                                                                                                                                                                               |
| daticolli.larghezza                                                    | Int    | Width of the single parcels in cm                                                                                                                                                                                                                                |
| daticolli.lunghezza                                                    | Int    | Height of the single parcels in cm                                                                                                                                                                                                                               |
| daticolli.peso                                                         | Float  | Weight of the single parcel (KG)                                                                                                                                                                                                                                 |
| daticolli.volume                                                       | Float  | Volume of the single parcels (cu m)                                                                                                                                                                                                                              |
| sender\_name                                                           | String | Name of the sender                                                                                                                                                                                                                                               |
| sender\_contact                                                        | String | Contact name of the sender                                                                                                                                                                                                                                       |
| sender\_addr                                                           | String | Address of the sender                                                                                                                                                                                                                                            |
| sender\_city                                                           | String | CIty of the sender                                                                                                                                                                                                                                               |
| sender\_cap                                                            | String | Zipcode of the sender                                                                                                                                                                                                                                            |
| sender\_prov                                                           | String | Province/country of the sender (iso 2 char)                                                                                                                                                                                                                      |
| sender\_country\_code                                                  | String | Country of the sender (iso 2 char)                                                                                                                                                                                                                               |
| sender\_phone                                                          | String | Phone number of the sender                                                                                                                                                                                                                                       |
| sender\_email                                                          | String | Email of the sender                                                                                                                                                                                                                                              |
| rcpt\_name<mark style="color:red;">\*</mark>                           | String | Name of the recipient                                                                                                                                                                                                                                            |
| rcpt\_contact<mark style="color:red;">\*</mark>                        | String | Contact name of the recipient                                                                                                                                                                                                                                    |
| rcpt\_addr<mark style="color:red;">\*</mark>                           | String | Address of the recipient                                                                                                                                                                                                                                         |
| rcpt\_city<mark style="color:red;">\*</mark>                           | String | City of the recipient                                                                                                                                                                                                                                            |
| rcpt\_cap<mark style="color:red;">\*</mark>                            | String | Zipcode of the recipient                                                                                                                                                                                                                                         |
| rcpt\_prov<mark style="color:red;">\*</mark>                           | String | Province/country of the recipient (iso 2 char)                                                                                                                                                                                                                   |
| rcpt\_country\_code<mark style="color:red;">\*</mark>                  | String | Country of the recipient (iso 2 char)                                                                                                                                                                                                                            |
| rcpt\_phone<mark style="color:red;">\*</mark>                          | String | Phone number of the recipient                                                                                                                                                                                                                                    |
| rcpt\_email<mark style="color:red;">\*</mark>                          | String | Email of the recipient                                                                                                                                                                                                                                           |
| addebito\_dogana                                                       | Int    | <p>Custom charges.</p><p>Admitted values :</p><ul><li><strong>0 :</strong> Custom charges billed to the recipient</li><li><strong>1 :</strong> Custom charges billed to the sender</li><li><strong>2 :</strong> Custom charges billed to a third party</li></ul> |
| note\_sender                                                           | String | Name of the sender                                                                                                                                                                                                                                               |
| trade\_documents                                                       | Array  | <p>Electronic documents (PLT) for the entitled couriers</p><p><a data-mention href="/pages/duSkFEO35LZOdVM1CsqX">/pages/duSkFEO35LZOdVM1CsqX</a></p>                                                                                                             |
| trade\_documents.nome                                                  | String | Name of the document                                                                                                                                                                                                                                             |
| trade\_documents.contenuto                                             | String | Base 64 string of the document                                                                                                                                                                                                                                   |
| dettagli\_ordine                                                       | Array  | Data of the order                                                                                                                                                                                                                                                |
| dettagli\_ordine.sku                                                   | String | SKU of the single item                                                                                                                                                                                                                                           |
| dettagli\_ordine.descripion                                            | String | Description of the single item                                                                                                                                                                                                                                   |
| dettagli\_ordine.qty                                                   | Int    | Amount of the single item                                                                                                                                                                                                                                        |
| dettagli\_ordine.barcode                                               | String | Barcode string of the single item                                                                                                                                                                                                                                |
| dettagli\_ordine.hs\_code                                              | String | HS/TARIC code of the single item                                                                                                                                                                                                                                 |
| dettagli\_ordine.prezzo\_singolo                                       | String | Price of the single item                                                                                                                                                                                                                                         |
| dettagli\_ordine.peso\_riga                                            | String | Peso singolo item - Weight of the single item                                                                                                                                                                                                                    |
| dettagli\_ordine.country\_of\_origin                                   | String | Provenience of the good                                                                                                                                                                                                                                          |
| date\_req\_ritiro                                                      | String | Pick-up date (YYYY-MM-DD)                                                                                                                                                                                                                                        |
| opening\_time                                                          | String | Opening time for the pickup (HH:MM:SS )                                                                                                                                                                                                                          |
| closing\_time                                                          | String | Closing time for the pickup (HH:MM:SS)                                                                                                                                                                                                                           |
| dropshipping                                                           | String | 0\|1 flag to identify a shipment in dropshipping                                                                                                                                                                                                                 |
| al\_piano                                                              | String | S\|N flag to activate the delivery to the floor (only for enabled couriers)                                                                                                                                                                                      |
| al\_sabato                                                             | String | S\|N flag to activate the saturday delivery service (only for enabled couriers)                                                                                                                                                                                  |
| reso\_contestuale                                                      | String | S\|N flag to activate the EXCHANGE service (only for enabled couriers)                                                                                                                                                                                           |
| fermo\_deposito                                                        | String | S\|N flag to identify a shipment in custody                                                                                                                                                                                                                      |
| generic\_service\_point                                                | String | Service point ID of the couriers                                                                                                                                                                                                                                 |
| documenti                                                              | String | 0\|1 flag to identify a document shipment                                                                                                                                                                                                                        |
| valore\_doganale                                                       | Float  | Customs value                                                                                                                                                                                                                                                    |
| opening\_time2                                                         | String | Second goods ready time (HH:MM:SS) - *only for TNT*                                                                                                                                                                                                              |
| closing\_time2                                                         | String | Second closing time (HH:MM:SS) - *only for TNT*                                                                                                                                                                                                                  |
| invoice\_date                                                          | String | Format YYYY-MM-DD of the invoice date                                                                                                                                                                                                                            |
| invoice\_number                                                        | String | Invoice number                                                                                                                                                                                                                                                   |
| dettagli\_ordine.qty<mark style="color:red;">\*</mark>                 | String | <p>As above but required to:</p><p>-- DHL ICS2</p>                                                                                                                                                                                                               |
| dettagli\_ordine.um                                                    | String | <p>Unit of measurement for the order row:</p><p>-- BOX (boxes)</p><p>-- KG (chilograms)</p><p>-- L (liters)</p><p>-- M (meters)</p><p>-- NO (number)</p><p>-- PCS (pieces)</p>                                                                                   |
| dettagli\_ordine.um<mark style="color:red;">\*</mark>                  | String | <p>As above but required to:</p><p>-- DHL ICS2</p>                                                                                                                                                                                                               |
| dettagli\_ordine.descripion<mark style="color:red;">\*</mark>          | String | <p>As above but required to:</p><p>-- DHL ICS2</p>                                                                                                                                                                                                               |
| dettagli\_ordine.country\_of\_origin<mark style="color:red;">\*</mark> | String | <p>As above but required to:</p><p>-- DHL ICS2</p>                                                                                                                                                                                                               |
| dettagli\_ordine.peso\_riga<mark style="color:red;">\*</mark>          | String | <p>As above but required to:</p><p>-- DHL ICS2</p>                                                                                                                                                                                                               |
| dettagli\_ordine.prezzo\_singolo<mark style="color:red;">\*</mark>     | String | <p>As above but required to:</p><p>-- DHL ICS2</p>                                                                                                                                                                                                               |
| labelType                                                              | Enum   | <p>Possible values are: PDF/ZPL<br><br>Some couriers may have restrinctions</p>                                                                                                                                                                                  |

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

```javascript
{
  "client_id": 390,
  "cod_destinatario": "",
  "colli": 1,
  "contrassegno": 0,
  "corriere": 104,
  "date_req_cons": "0000-00-00 00:00:00",
  "ddt_alpha": "TEST_GSPED",
  "ddt_num": 12346,
  "merce": "",
  "note_sender": "",
  "origine": "IT",
  "peso": 1.8,
  "preavviso_telefonico": "",
  "rcpt_addr": "115 E Endfield Rd",
  "rcpt_cap": 19053,
  "rcpt_city": "Feasterville Trevose",
  "rcpt_contact": "Tester",
  "rcpt_country_code": "US",
  "rcpt_email": "test@test.edu",
  "rcpt_name": "TEST MITTENTE",
  "rcpt_phone": "123456789",
  "rcpt_prov": "PA",
  "servizio": 9,
  "tipo_incasso": 0,
  "valore": 0,
  "valore_doganale": 37.5,
  "volume": 0.029,
  "status": 0,
  "fid_partenza": "",
  "num_serie": 0,
  "num_spedizione": "1253863656",
  "date_upd": "0000-00-00 00:00:00",
  "error": "",
  "sender_name": "test mittente",
  "sender_addr": "p.za Ambrosoli 13",
  "sender_cap": 15121,
  "sender_city": "Alessandria",
  "sender_contact": "Rossi Pino",
  "sender_prov": "AL",
  "sender_country_code": "IT",
  "sender_email": "test@test.it",
  "label_jpg": [
    "base64 encoded label string"
  ],
  "label_pdf": [
    "base64 encoded label string"
  ],
  "label_zpl": [
    "ZPL label string"
  ],
  "id": 50003621,
  "tnt_options": [],
  "tracking_link": "",
  "valuta": "EUR",
  "dropshipping": 0,
  "sender_phone": 12345562,
  "al_piano": "",
  "al_sabato": "",
  "reso_contestuale": "",
  "fermo_deposito": 0,
  "note": "",
  "centro_costo": "",
  "sda_servizio": "",
  "user_id": 0,
  "opening_time": "00:00:00",
  "closing_time": "00:00:00",
  "date_req_ritiro": "0000-00-00 00:00:00",
  "ups_uap_id": "",
  "sda_id_fermoposta": "",
  "note_2": "",
  "confermato": 0,
  "ups_signature_required": 0,
  "id_pickup": null,
  "documenti": 0,
  "sda_accessori": 0,
  "packaging": "",
  "dropoff_type": "",
  "vat_seller": "",
  "vat_buyer": "",
  "generic_service_point": "",
  "tipo_transazione": "supSoglia",
  "rcpt_language": "",
  "sender_eori": "",
  "rcpt_eori": "",
  "link_pickup_booking": ""
}
```

{% endtab %}

{% tab title="400: Bad Request Bad request" %}

```javascript
{
  "error": "client_id: deve essere lungo al massimo 7 caratteri"
}
```

{% endtab %}

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

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

{% endtab %}
{% endtabs %}

### Example Snippets

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

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.gsped.it/sandbox/shipment",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "{\n  \"client_id\": 390,\n  \"colli\": 2,\n  \"contrassegno\": 0,\n  \"corriere\": 104,\n  \"ddt_alpha\": \"TEST_GSPED\",\n  \"ddt_num\": 12346,\n  \"origine\": \"IT\",\n\t\"dropshipping\" : 0,\n  \"peso\": 2.4,\n  \"rcpt_addr\": \"115 E Endfield Rd\",\n  \"rcpt_cap\": \"19053\",\n  \"rcpt_city\": \"Feasterville Trevose\",\n  \"rcpt_contact\": \"Tester\",\n  \"rcpt_country_code\": \"US\",\n  \"rcpt_email\": \"test@test.it\",\n  \"rcpt_name\": \"TEST DESTINATARIO\",\n  \"rcpt_phone\": \"2159005458\",\n  \"rcpt_prov\": \"PA\",\n  \"servizio\": 9,\n  \"valore\": 0,\n  \"valore_doganale\": 37.50,\n  \"valuta\": \"EUR\",\n  \"volume\": 0.0972,\n\t\"daticolli\": [\n    {\n      \"altezza\": 39,\n      \"larghezza\": 29,\n      \"lunghezza\": 43,\n      \"volume\": 0.048633,\n      \"peso\": 1.2\n    },\n\t\t{\n      \"altezza\": 39,\n      \"larghezza\": 29,\n      \"lunghezza\": 43,\n      \"volume\": 0.048633,\n      \"peso\": 1.2\n    }\n  ],\n  \"dettagli_ordine\" : [\n    {\n      \"sku\" : \"PBK1\",\n      \"description\": \"Cosa blu\",\n      \"qty\": \"1\",\n      \"barcode_riga\": \"12345464\",\n      \"hs_code\": \"123456454\",\n      \"prezzo_singolo\": \"12.50\",\n      \"peso_riga\": \"1\"\n    },{\n      \"sku\" : \"PBK12\",\n      \"description\": \"Cosa blu e rossa\",\n      \"qty\": \"1\",\n      \"barcode_riga\": \"12345465\",\n      \"hs_code\": \"123456454\",\n      \"prezzo_singolo\": \"25.00\",\n      \"peso_riga\": \"1\"\n    }\n  ]\n}",
  CURLOPT_HTTPHEADER => [
    "x-api-key: YOUR-API-KEY"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
```

{% endtab %}

{% tab title="PYTHON" %}

```python
import http.client

conn = http.client.HTTPSConnection("api.gsped.it")

payload = json.dumps({
  "client_id": 390,
  "colli": 2,
  "contrassegno": 0,
  "corriere": 104,
  "ddt_alpha": "TEST_GSPED",
  "ddt_num": 12346,
  "origine": "IT",
  "dropshipping": 0,
  "peso": 2.4,
  "rcpt_addr": "115 E Endfield Rd",
  "rcpt_cap": "19053",
  "rcpt_city": "Feasterville Trevose",
  "rcpt_contact": "Tester",
  "rcpt_country_code": "US",
  "rcpt_email": "test@test.it",
  "rcpt_name": "TEST DESTINATARIO",
  "rcpt_phone": "2159005458",
  "rcpt_prov": "PA",
  "servizio": 9,
  "valore": 0,
  "valore_doganale": 37.50,
  "valuta": "EUR",
  "volume": 0.0972,
  "daticolli": [
    {
      "altezza": 39,
      "larghezza": 29,
      "lunghezza": 43,
      "volume": 0.048633,
      "peso": 1.2
    },
    {
      "altezza": 39,
      "larghezza": 29,
      "lunghezza": 43,
      "volume": 0.048633,
      "peso": 1.2
    }
  ],
  "dettagli_ordine": [
    {
      "sku": "PBK1",
      "description": "Cosa blu",
      "qty": "1",
      "barcode_riga": "12345464",
      "hs_code": "123456454",
      "prezzo_singolo": "12.50",
      "peso_riga": "1"
    },
    {
      "sku": "PBK12",
      "description": "Cosa blu e rossa",
      "qty": "1",
      "barcode_riga": "12345465",
      "hs_code": "123456454",
      "prezzo_singolo": "25.00",
      "peso_riga": "1"
    }
  ]
})

headers = { 'x-api-key': "YOUR-API-KEY" }

conn.request("POST", "/sandbox/shipment", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
```

{% endtab %}

{% tab title="GO" %}

```go
package main

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

func main() {

	url := "https://api.gsped.it/sandbox/shipment"

	payload := strings.NewReader("{\n  \"client_id\": 390,\n  \"colli\": 2,\n  \"contrassegno\": 0,\n  \"corriere\": 104,\n  \"ddt_alpha\": \"TEST_GSPED\",\n  \"ddt_num\": 12346,\n  \"origine\": \"IT\",\n\t\"dropshipping\" : 0,\n  \"peso\": 2.4,\n  \"rcpt_addr\": \"115 E Endfield Rd\",\n  \"rcpt_cap\": \"19053\",\n  \"rcpt_city\": \"Feasterville Trevose\",\n  \"rcpt_contact\": \"Tester\",\n  \"rcpt_country_code\": \"US\",\n  \"rcpt_email\": \"test@test.it\",\n  \"rcpt_name\": \"TEST DESTINATARIO\",\n  \"rcpt_phone\": \"2159005458\",\n  \"rcpt_prov\": \"PA\",\n  \"servizio\": 9,\n  \"valore\": 0,\n  \"valore_doganale\": 37.50,\n  \"valuta\": \"EUR\",\n  \"volume\": 0.0972,\n\t\"daticolli\": [\n    {\n      \"altezza\": 39,\n      \"larghezza\": 29,\n      \"lunghezza\": 43,\n      \"volume\": 0.048633,\n      \"peso\": 1.2\n    },\n\t\t{\n      \"altezza\": 39,\n      \"larghezza\": 29,\n      \"lunghezza\": 43,\n      \"volume\": 0.048633,\n      \"peso\": 1.2\n    }\n  ],\n  \"dettagli_ordine\" : [\n    {\n      \"sku\" : \"PBK1\",\n      \"description\": \"Cosa blu\",\n      \"qty\": \"1\",\n      \"barcode_riga\": \"12345464\",\n      \"hs_code\": \"123456454\",\n      \"prezzo_singolo\": \"12.50\",\n      \"peso_riga\": \"1\"\n    },{\n      \"sku\" : \"PBK12\",\n      \"description\": \"Cosa blu e rossa\",\n      \"qty\": \"1\",\n      \"barcode_riga\": \"12345465\",\n      \"hs_code\": \"123456454\",\n      \"prezzo_singolo\": \"25.00\",\n      \"peso_riga\": \"1\"\n    }\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("x-api-key", "YOUR-API-KEY")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := ioutil.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

{% endtab %}

{% tab title="C#" %}

```csharp
var client = new HttpClient();
var request = new HttpRequestMessage
{
    Method = HttpMethod.Post,
    RequestUri = new Uri("https://api.gsped.it/sandbox/shipment"),
    Headers =
    {
        { "x-api-key", "YOUR-API-KEY" },
    },
    Content = new StringContent("{\n  \"client_id\": 390,\n  \"colli\": 2,\n  \"contrassegno\": 0,\n  \"corriere\": 104,\n  \"ddt_alpha\": \"TEST_GSPED\",\n  \"ddt_num\": 12346,\n  \"origine\": \"IT\",\n\t\"dropshipping\" : 0,\n  \"peso\": 2.4,\n  \"rcpt_addr\": \"115 E Endfield Rd\",\n  \"rcpt_cap\": \"19053\",\n  \"rcpt_city\": \"Feasterville Trevose\",\n  \"rcpt_contact\": \"Tester\",\n  \"rcpt_country_code\": \"US\",\n  \"rcpt_email\": \"test@test.it\",\n  \"rcpt_name\": \"TEST DESTINATARIO\",\n  \"rcpt_phone\": \"2159005458\",\n  \"rcpt_prov\": \"PA\",\n  \"servizio\": 9,\n  \"valore\": 0,\n  \"valore_doganale\": 37.50,\n  \"valuta\": \"EUR\",\n  \"volume\": 0.0972,\n\t\"daticolli\": [\n    {\n      \"altezza\": 39,\n      \"larghezza\": 29,\n      \"lunghezza\": 43,\n      \"volume\": 0.048633,\n      \"peso\": 1.2\n    },\n\t\t{\n      \"altezza\": 39,\n      \"larghezza\": 29,\n      \"lunghezza\": 43,\n      \"volume\": 0.048633,\n      \"peso\": 1.2\n    }\n  ],\n  \"dettagli_ordine\" : [\n    {\n      \"sku\" : \"PBK1\",\n      \"description\": \"Cosa blu\",\n      \"qty\": \"1\",\n      \"barcode_riga\": \"12345464\",\n      \"hs_code\": \"123456454\",\n      \"prezzo_singolo\": \"12.50\",\n      \"peso_riga\": \"1\"\n    },{\n      \"sku\" : \"PBK12\",\n      \"description\": \"Cosa blu e rossa\",\n      \"qty\": \"1\",\n      \"barcode_riga\": \"12345465\",\n      \"hs_code\": \"123456454\",\n      \"prezzo_singolo\": \"25.00\",\n      \"peso_riga\": \"1\"\n    }\n  ]\n}")
    {
        Headers =
        {
            ContentType = new MediaTypeHeaderValue("application/json")
        }
    }
};
using (var response = await client.SendAsync(request))
{
    response.EnsureSuccessStatusCode();
    var body = await response.Content.ReadAsStringAsync();
    Console.WriteLine(body);
}
```

{% endtab %}

{% tab title="cURL" %}

```shell
curl --request POST \
  --url https://api.gsped.it/sandbox/shipment \
  --header 'x-api-key: YOUR-API-KEY' \
  --data '{
  "client_id": 390,
  "colli": 2,
  "contrassegno": 0,
  "corriere": 104,
  "ddt_alpha": "TEST_GSPED",
  "ddt_num": 12346,
  "origine": "IT",
	"dropshipping" : 0,
  "peso": 2.4,
  "rcpt_addr": "115 E Endfield Rd",
  "rcpt_cap": "19053",
  "rcpt_city": "Feasterville Trevose",
  "rcpt_contact": "Tester",
  "rcpt_country_code": "US",
  "rcpt_email": "test@test.it",
  "rcpt_name": "TEST DESTINATARIO",
  "rcpt_phone": "2159005458",
  "rcpt_prov": "PA",
  "servizio": 9,
  "valore": 0,
  "valore_doganale": 37.50,
  "valuta": "EUR",
  "volume": 0.0972,
	"daticolli": [
    {
      "altezza": 39,
      "larghezza": 29,
      "lunghezza": 43,
      "volume": 0.048633,
      "peso": 1.2
    },
		{
      "altezza": 39,
      "larghezza": 29,
      "lunghezza": 43,
      "volume": 0.048633,
      "peso": 1.2
    }
  ],
  "dettagli_ordine" : [
    {
      "sku" : "PBK1",
      "description": "Cosa blu",
      "qty": "1",
      "barcode_riga": "12345464",
      "hs_code": "123456454",
      "prezzo_singolo": "12.50",
      "peso_riga": "1"
    },{
      "sku" : "PBK12",
      "description": "Cosa blu e rossa",
      "qty": "1",
      "barcode_riga": "12345465",
      "hs_code": "123456454",
      "prezzo_singolo": "25.00",
      "peso_riga": "1"
    }
  ]
}'
```

{% endtab %}
{% endtabs %}

## Shipment - DELETE

This endpoint allows to delete the shipments **just in case they have not already been confirmed**

{% hint style="info" %}
When a shipment is cancelled the labels returned by the POST are no longer valid and must be deleted.
{% endhint %}

## Shipment DELETE

<mark style="color:red;">`DELETE`</mark> `https://api.gsped.it/[INSTANCE]/Shipment`

Cancellation of a shipment from the systems of Gsped and of the couriers

#### Query Parameters

| Name                                 | Type   | Description               |
| ------------------------------------ | ------ | ------------------------- |
| id<mark style="color:red;">\*</mark> | String | Unique ID 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 Successfully deleted" %}

```javascript
{
  "error": ""
}
```

{% endtab %}

{% tab title="400: Bad Request Bad request" %}

```javascript
{
  "error": "ID spedizione non indicata"
}
```

{% endtab %}

{% tab title="403: Forbidden Invalid apikey" %}

```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

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

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "http://api.gsped.it/sandbox/Shipment?id=53",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "DELETE",
  CURLOPT_POSTFIELDS => "",
  CURLOPT_HTTPHEADER => [
    "x-api-key: YOUR-API-KEY"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
```

{% endtab %}

{% tab title="PYTHON" %}

```python
import http.client

conn = http.client.HTTPConnection("api.gsped.it")

payload = ""

headers = {
    'x-api-key': "YOUR-API-KEY"
    }

conn.request("DELETE", "/sandbox/Shipment?id=53", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
```

{% endtab %}

{% tab title="GO" %}

```go
package main

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

func main() {

	url := "http://api.gsped.it/sandbox/Shipment?id=53"

	req, _ := http.NewRequest("DELETE", url, nil)
	
	req.Header.Add("x-api-key", "YOUR-API-KEY")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := ioutil.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

{% endtab %}

{% tab title="C#" %}

```csharp
// Some codevar clientHandler = new HttpClientHandler
{
    UseCookies = false,
};
var client = new HttpClient(clientHandler);
var request = new HttpRequestMessage
{
    Method = HttpMethod.Delete,
    RequestUri = new Uri("http://api.gsped.it/sandbox/Shipment?id=53"),
    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" %}

```shell
curl --request DELETE \
  --url 'http://api.gsped.it/sandbox/Shipment?id=53' \
  --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/shipment.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.
