# ShipmentFromCourier

## Introduzione

Questo endpoint nasce come punto di ingresso per flussi informativi che risiedono su altri sistemi o integrazioni.

Si tratta di un endpoint chiamato in POST con payload in JSON.

## Specifiche chiamata

### Esempio payload

```json
{
	"client_id" : 2,
	"instance" : "testbed",
	"courier" : 104,
	"shipment_number" : "123456789",
	"reference_1" : 11223,
	"reference_2": "11223",
	"parcels" : 1,
	"status" : "PU",
	"weight": 2.5,
	"volume": 0.005,
	"service": "N",
	"insurance": 0.0,
	"cod": 0.0,
	"parcel_details": [
		{
			"barcode": "12345",
			"weight": 2.5,
			"volume": 0.005,
			"height": 10,
			"length": 10,
			"width": 10,
			"type": "crt"
		}
	],
	"sender_info": {
		"name": "test",
		"address": "via delle Glorie 5",
		"city": "Alessandria",
		"zipcode": "15121",
		"state": "AL",
		"country": "IT",
		"phone": "1231212123",
		"mail": "test@test.it"
	},
	"recipient_info": {
		"name": "test",
		"address": "via delle rose 14",
		"city": "Milano",
		"zipcode": "20121",
		"state": "MI",
		"country": "IT",
		"phone": "1231212123",
		"mail": "test@test.it"
	},
	"date_cons": "2025-05-08 00:00:00",
	"order_id": 4743,
  "date_req_cons": "2026-03-10 00:00:00"
}
```

### Definizione campi

#### Headers

| Name                                            | Type   | Description                |
| ----------------------------------------------- | ------ | -------------------------- |
| x-api-key<mark style="color:$danger;">\*</mark> | String | Apikey rilasciata da Gsped |

#### Request Body

| Name                                                   | Type   | Description                                                                                      |
| ------------------------------------------------------ | ------ | ------------------------------------------------------------------------------------------------ |
| instance<mark style="color:$danger;">\*</mark>         | String | Istanza Gsped                                                                                    |
| courier<mark style="color:$danger;">\*</mark>          | Int    | ID corriere Gsped ( [corrieri e serviz](https://apidocs.gsped.com/overview/corrieri-e-servizi)i) |
| parcels<mark style="color:$danger;">\*</mark>          | Int    | Numero colli della spedizione                                                                    |
| volume<mark style="color:$danger;">\*</mark>           | Float  | Volume spedizione in Metri Cubi                                                                  |
| weight<mark style="color:$danger;">\*</mark>           | Float  | Peso spedizione espresso in KG                                                                   |
| shipment\_number<mark style="color:$danger;">\*</mark> | String | Numero di spedizione                                                                             |
| status<mark style="color:$danger;">\*</mark>           | String | Codice stato spedizione in formato corriere                                                      |
| reference\_1<mark style="color:$danger;">\*</mark>     | String | Riferimento numerico della spedizione                                                            |
| reference\_2<mark style="color:$danger;">\*</mark>     | String | Riferimento alfanumerico della spedizione                                                        |
| client\_id<mark style="color:$danger;">\*</mark>       | Int    | ID cliente fornito da Gsped                                                                      |
| service<mark style="color:$danger;">\*</mark>          | String | Codice servizio in formato corriere                                                              |
| sender\_info<mark style="color:$danger;">\*</mark>     | Object | [Address object](#address-object)                                                                |
| recipient\_info<mark style="color:$danger;">\*</mark>  | Object | [Address object](#address-object)                                                                |
| parcel\_details<mark style="color:$danger;">\*</mark>  | Array  | Array di oggetti [parcel\_data](#parcel_data-object)                                             |
| date\_cons                                             | String | Data consegna                                                                                    |
| order\_id                                              | Int    | ID Gsped dell'ordine associato alla spedizione                                                   |
| date\_req\_cons                                        | String | Data consegna tassativa                                                                          |

#### **Address Object**

| Name                                          | Type   | Description                   |
| --------------------------------------------- | ------ | ----------------------------- |
| name<mark style="color:$danger;">\*</mark>    | String | Nome                          |
| address<mark style="color:$danger;">\*</mark> | String | Indirizzo                     |
| city<mark style="color:$danger;">\*</mark>    | String | Nome della località           |
| zipcode<mark style="color:$danger;">\*</mark> | String | Codice postale                |
| state<mark style="color:$danger;">\*</mark>   | String | Nome provincia/stato          |
| country<mark style="color:$danger;">\*</mark> | String | Iso code 2 char della nazione |
| phone<mark style="color:$danger;">\*</mark>   | String | Numero di telefono            |
| mail<mark style="color:$danger;">\*</mark>    | String | Indirizzo email               |

#### **Parcel\_data Object**

| Name                                          | Type   | Description        |
| --------------------------------------------- | ------ | ------------------ |
| barcode<mark style="color:$danger;">\*</mark> | String | Codice barcode     |
| weight<mark style="color:$danger;">\*</mark>  | Float  | Peso in KG         |
| volume<mark style="color:$danger;">\*</mark>  | Float  | Volume in Mc       |
| height<mark style="color:$danger;">\*</mark>  | Int    | Altezza in CM      |
| length<mark style="color:$danger;">\*</mark>  | Int    | Lunghezza in CM    |
| width<mark style="color:$danger;">\*</mark>   | Int    | Profondità in CM   |
| type                                          | String | Tipologia di collo |

### Esempi di codice

#### PHP

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.gsped.it/testbed/ShipmentFromCourier",
  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\t\"client_id\" : 2,\n\t\"instance\" : \"testbed\",\n\t\"courier\" : 104,\n\t\"shipment_number\" : \"123456789\",\n\t\"reference_1\" : 11223,\n\t\"reference_2\": \"11223\",\n\t\"parcels\" : 1,\n\t\"status\" : \"PU\",\n\t\"weight\": 2.5,\n\t\"volume\": 0.005,\n\t\"service\": \"N\",\n\t\"insurance\": 0.0,\n\t\"cod\": 0.0,\n\t\"parcel_details\": [\n\t\t{\n\t\t\t\"barcode\": \"12345\",\n\t\t\t\"weight\": 2.5,\n\t\t\t\"volume\": 0.005,\n\t\t\t\"height\": 10,\n\t\t\t\"length\": 10,\n\t\t\t\"width\": 10,\n\t\t\t\"type\": \"crt\"\n\t\t}\n\t],\n\t\"sender_info\": {\n\t\t\"name\": \"test\",\n\t\t\"address\": \"via delle Glorie 5\",\n\t\t\"city\": \"Alessandria\",\n\t\t\"zipcode\": \"15121\",\n\t\t\"state\": \"AL\",\n\t\t\"country\": \"IT\",\n\t\t\"phone\": \"1231212123\",\n\t\t\"mail\": \"test@test.it\"\n\t},\n\t\"recipient_info\": {\n\t\t\"name\": \"test\",\n\t\t\"address\": \"via delle rose 14\",\n\t\t\"city\": \"Milano\",\n\t\t\"zipcode\": \"20121\",\n\t\t\"state\": \"MI\",\n\t\t\"country\": \"IT\",\n\t\t\"phone\": \"1231212123\",\n\t\t\"mail\": \"test@test.it\"\n\t},\n\t\"order_id\": 4743\n}",
  CURLOPT_HTTPHEADER => [
    "Content-Type: application/json",
    "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;
}
```

#### Python

```python
import http.client

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

payload = "{\n\t\"client_id\" : 2,\n\t\"instance\" : \"testbed\",\n\t\"courier\" : 104,\n\t\"shipment_number\" : \"123456789\",\n\t\"reference_1\" : 11223,\n\t\"reference_2\": \"11223\",\n\t\"parcels\" : 1,\n\t\"status\" : \"PU\",\n\t\"weight\": 2.5,\n\t\"volume\": 0.005,\n\t\"service\": \"N\",\n\t\"insurance\": 0.0,\n\t\"cod\": 0.0,\n\t\"parcel_details\": [\n\t\t{\n\t\t\t\"barcode\": \"12345\",\n\t\t\t\"weight\": 2.5,\n\t\t\t\"volume\": 0.005,\n\t\t\t\"height\": 10,\n\t\t\t\"length\": 10,\n\t\t\t\"width\": 10,\n\t\t\t\"type\": \"crt\"\n\t\t}\n\t],\n\t\"sender_info\": {\n\t\t\"name\": \"test\",\n\t\t\"address\": \"via delle Glorie 5\",\n\t\t\"city\": \"Alessandria\",\n\t\t\"zipcode\": \"15121\",\n\t\t\"state\": \"AL\",\n\t\t\"country\": \"IT\",\n\t\t\"phone\": \"1231212123\",\n\t\t\"mail\": \"test@test.it\"\n\t},\n\t\"recipient_info\": {\n\t\t\"name\": \"test\",\n\t\t\"address\": \"via delle rose 14\",\n\t\t\"city\": \"Milano\",\n\t\t\"zipcode\": \"20121\",\n\t\t\"state\": \"MI\",\n\t\t\"country\": \"IT\",\n\t\t\"phone\": \"1231212123\",\n\t\t\"mail\": \"test@test.it\"\n\t},\n\t\"order_id\": 4743\n}"

headers = {
    'Content-Type': "application/json",
    'x-api-key': "YOUR-API-KEY"
    }

conn.request("POST", "/testbed/ShipmentFromCourier", payload, headers)

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

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

```

**GO**

```go
package main

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

func main() {

	url := "https://api.gsped.it/testbed/ShipmentFromCourier"

	payload := strings.NewReader("{\n\t\"client_id\" : 2,\n\t\"instance\" : \"testbed\",\n\t\"courier\" : 104,\n\t\"shipment_number\" : \"123456789\",\n\t\"reference_1\" : 11223,\n\t\"reference_2\": \"11223\",\n\t\"parcels\" : 1,\n\t\"status\" : \"PU\",\n\t\"weight\": 2.5,\n\t\"volume\": 0.005,\n\t\"service\": \"N\",\n\t\"insurance\": 0.0,\n\t\"cod\": 0.0,\n\t\"parcel_details\": [\n\t\t{\n\t\t\t\"barcode\": \"12345\",\n\t\t\t\"weight\": 2.5,\n\t\t\t\"volume\": 0.005,\n\t\t\t\"height\": 10,\n\t\t\t\"length\": 10,\n\t\t\t\"width\": 10,\n\t\t\t\"type\": \"crt\"\n\t\t}\n\t],\n\t\"sender_info\": {\n\t\t\"name\": \"test\",\n\t\t\"address\": \"via delle Glorie 5\",\n\t\t\"city\": \"Alessandria\",\n\t\t\"zipcode\": \"15121\",\n\t\t\"state\": \"AL\",\n\t\t\"country\": \"IT\",\n\t\t\"phone\": \"1231212123\",\n\t\t\"mail\": \"test@test.it\"\n\t},\n\t\"recipient_info\": {\n\t\t\"name\": \"test\",\n\t\t\"address\": \"via delle rose 14\",\n\t\t\"city\": \"Milano\",\n\t\t\"zipcode\": \"20121\",\n\t\t\"state\": \"MI\",\n\t\t\"country\": \"IT\",\n\t\t\"phone\": \"1231212123\",\n\t\t\"mail\": \"test@test.it\"\n\t},\n\t\"order_id\": 4743\n}")

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

	req.Header.Add("Content-Type", "application/json")
	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))

}
```

#### C\#

```csharp
var client = new RestClient("https://api.gsped.it/testbed/ShipmentFromCourier");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("x-api-key", "YOUR-API-KEY");
request.AddParameter("application/json", "{\n\t\"client_id\" : 2,\n\t\"instance\" : \"testbed\",\n\t\"courier\" : 104,\n\t\"shipment_number\" : \"123456789\",\n\t\"reference_1\" : 11223,\n\t\"reference_2\": \"11223\",\n\t\"parcels\" : 1,\n\t\"status\" : \"PU\",\n\t\"weight\": 2.5,\n\t\"volume\": 0.005,\n\t\"service\": \"N\",\n\t\"insurance\": 0.0,\n\t\"cod\": 0.0,\n\t\"parcel_details\": [\n\t\t{\n\t\t\t\"barcode\": \"12345\",\n\t\t\t\"weight\": 2.5,\n\t\t\t\"volume\": 0.005,\n\t\t\t\"height\": 10,\n\t\t\t\"length\": 10,\n\t\t\t\"width\": 10,\n\t\t\t\"type\": \"crt\"\n\t\t}\n\t],\n\t\"sender_info\": {\n\t\t\"name\": \"test\",\n\t\t\"address\": \"via delle Glorie 5\",\n\t\t\"city\": \"Alessandria\",\n\t\t\"zipcode\": \"15121\",\n\t\t\"state\": \"AL\",\n\t\t\"country\": \"IT\",\n\t\t\"phone\": \"1231212123\",\n\t\t\"mail\": \"test@test.it\"\n\t},\n\t\"recipient_info\": {\n\t\t\"name\": \"test\",\n\t\t\"address\": \"via delle rose 14\",\n\t\t\"city\": \"Milano\",\n\t\t\"zipcode\": \"20121\",\n\t\t\"state\": \"MI\",\n\t\t\"country\": \"IT\",\n\t\t\"phone\": \"1231212123\",\n\t\t\"mail\": \"test@test.it\"\n\t},\n\t\"order_id\": 4743\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

#### Curl

```shell
curl --request POST \
  --url https://api.gsped.it/testbed/ShipmentFromCourier \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: YOUR-API-KEY' \
  --data '{
	"client_id" : 2,
	"instance" : "testbed",
	"courier" : 104,
	"shipment_number" : "123456789",
	"reference_1" : 11223,
	"reference_2": "11223",
	"parcels" : 1,
	"status" : "PU",
	"weight": 2.5,
	"volume": 0.005,
	"service": "N",
	"insurance": 0.0,
	"cod": 0.0,
	"parcel_details": [
		{
			"barcode": "12345",
			"weight": 2.5,
			"volume": 0.005,
			"height": 10,
			"length": 10,
			"width": 10,
			"type": "crt"
		}
	],
	"sender_info": {
		"name": "test",
		"address": "via delle Glorie 5",
		"city": "Alessandria",
		"zipcode": "15121",
		"state": "AL",
		"country": "IT",
		"phone": "1231212123",
		"mail": "test@test.it"
	},
	"recipient_info": {
		"name": "test",
		"address": "via delle rose 14",
		"city": "Milano",
		"zipcode": "20121",
		"state": "MI",
		"country": "IT",
		"phone": "1231212123",
		"mail": "test@test.it"
	},
	"order_id": 4743,
	"date_req_cons": "2026-03-10"
}'
```

### Limitazioni

Al momento questo endpoint è disponibile per i corrieri:

<table><thead><tr><th width="120">ID</th><th>Corriere</th></tr></thead><tbody><tr><td>37</td><td>Pitagorando</td></tr><tr><td>70</td><td>Dummy1</td></tr><tr><td>71</td><td>Dummy2</td></tr><tr><td>72</td><td>Dummy3</td></tr><tr><td>73</td><td>Dummy4</td></tr><tr><td>74</td><td>Dummy5</td></tr><tr><td>75</td><td>Dummy6</td></tr><tr><td>76</td><td>Dummy7</td></tr><tr><td>77</td><td>Dummy8</td></tr><tr><td>78</td><td>Dummy9</td></tr><tr><td>79</td><td>Dummy10</td></tr><tr><td>90</td><td>Italsempione</td></tr><tr><td>91</td><td>Logisticando</td></tr><tr><td>92</td><td>CsiLogistica</td></tr><tr><td>93</td><td>Ribosped</td></tr><tr><td>94</td><td>Zust-Tiesse</td></tr><tr><td>95</td><td>Lynx</td></tr><tr><td>98</td><td>SVL</td></tr><tr><td>101</td><td>GLS</td></tr><tr><td>104</td><td>DHL</td></tr></tbody></table>

In futuro verrà espanso, visitate la documentazione ad intervalli regolari per essere aggiornati.
