The function adds parcel allows adding or remove the parcels in full autonomy, with their corresponding labels.
List of enabled couriers
* see
COURIERS (Gsped ID)
ADDING
REMOVING
Notes about couriersTNT --> Only for the same label creation date and before the withdrawal date/time of the same. If necessary to extend this date, consult the Expected Assignment Date section
How the Add Parcel function works
To successfully use the Add Parcel function 3 endpoints must be used:
Shipment POST - For the shipment creation
Parcels POST or DELETE - To add or remove the parcels
ShipmentConfirm POST - For the final shipment confimation. You will no longer be able to change.
PLEASE NOTE: the removal of a parcel in a single-parcel shipment automatically cancels of the shipment.
Add a single parcel to a shipment
POST
https://api.gsped.it/[INSTANCE]/Parcels
Body in JSON.
\
It works in 2 ways: \
1 - Shipment ID + parcel data
\
2 - Recepient data + parcel data
Request Body
Alphanumerical reference of the shipment
Zip code of the recepient
Province/country of the recepient
Country of the recepient iso code 2 char
200: OK Parcel successfully added 400: Bad Request Wrong payload 404: Not Found Shipment ID not found 404: Not Found Unable to find unique shipment via recepient data
Copy {
"id_collo": 2,
"id_sped": "123456789",
"labels": {
"jpg": "Stringa base64",
"pdf": "Stringa base64",
"zpl": "Stringa ZPL"
},
"tracking_collo": "JJD01111111111"
}
Copy {
"error": "Dati spedizione non presenti o in formato sbagliato"
}
Copy {
"error": "Shipment '1234' doesn't exists!"
}
Copy {
"error": "Unable to find unique shipment by ddt and address"
}
Parcel object
Example of Payload Parcels POST
Shipment ID Recepient data
Copy {
"id_sped":"1234567",
"collo": {
"peso": "5",
"volume": "0.01",
"larghezza": "35",
"altezza": "15",
"lunghezza": "10"
}
}
Copy {
"ddt_alpha":"test_parcel_8",
"rcpt_name":"Rossi Gino",
"rcpt_addr":"Via Milano 8",
"rcpt_cap":"20123",
"rcpt_city":"Milano",
"rcpt_prov":"MI",
"rcpt_country_code" : "IT",
"collo": {
"peso": "5",
"volume": "0.01",
"larghezza": "35",
"altezza": "15",
"lunghezza": "20"
}
}
Example of Snippet Parcel POST
PHP Python GO C# cURL
Copy <?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.gsped.it/sandbox/Parcels",
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 \"id_sped\":\"1\",\n \"collo\": {\n \"peso\": \"5\",\n \"volume\": \"0.01\",\n \"larghezza\": \"35\",\n \"altezza\": \"15\",\n \"lunghezza\": \"10\"\n }\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;
}
Copy import http.client
conn = http.client.HTTPSConnection("api.gsped.it")
payload = "{\n \"id_sped\":\"1\",\n \"collo\": {\n \"peso\": \"5\",\n \"volume\": \"0.01\",\n \"larghezza\": \"35\",\n \"altezza\": \"15\",\n \"lunghezza\": \"10\"\n }\n}"
headers = {
'Content-Type': "application/json",
'x-api-key': "YOUR-API-KEY"
}
conn.request("POST", "/sandbox/Parcels", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Copy package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.gsped.it/sandbox/Parcels"
payload := strings.NewReader("{\n \"id_sped\":\"1\",\n \"collo\": {\n \"peso\": \"5\",\n \"volume\": \"0.01\",\n \"larghezza\": \"35\",\n \"altezza\": \"15\",\n \"lunghezza\": \"10\"\n }\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))
}
Copy var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("https://api.gsped.it/sandbox/Parcels"),
Headers =
{
{ "x-api-key", "YOUR-API-KEY" },
},
Content = new StringContent("{\n \"id_sped\":\"1\",\n \"collo\": {\n \"peso\": \"5\",\n \"volume\": \"0.01\",\n \"larghezza\": \"35\",\n \"altezza\": \"15\",\n \"lunghezza\": \"10\"\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);
}
Copy curl --request POST \
--url https://api.gsped.it/sandbox/Parcels \
--header 'Content-Type: application/json' \
--header 'x-api-key: YOUR-API-KEY' \
--data '{
"id_sped":"1",
"collo": {
"peso": "5",
"volume": "0.01",
"larghezza": "35",
"altezza": "15",
"lunghezza": "10"
}
}'
Parcel removal from shipment
DELETE
https://api.gsped.it/[INSTANCE]/Parcels
Form Url-Encoded Body
It works in 2 ways: \
1 Shipment ID + parcel data
\
2 Recepient data + parcel data
Request Body
Alphanumerical shipment reference
Zip code of the recepient
Province/country of the recipient
Country of the recepient (iso code 2 char)
200: OK Parcel successfully removed 200: OK Last parcel revoval and cancellation of the shipment 403: Forbidden Cancellation of the shipment confirmed 404 Shipment ID not found 404: Not Found Unable to find unique shipment via recepient data
Copy {
"id": "50000723",
"num_spedizione": "7004525883",
"num_collo": 1
}
Copy {
"result": "Shipment deleted"
}
Copy {
"error" : "This shipment is already confirmed"
}
Copy {
"error": "Shipment '1' doesn't exists!"
}
Copy {
"error": "Unable to find unique shipment by ddt and address"
}
Example Snippet Parcels DELETE
PHP Python GO C# cURL
Copy <?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.gsped.it/sandbox/Parcels",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_POSTFIELDS => "id_sped=69562763",
CURLOPT_HTTPHEADER => [
"Content-Type: application/x-www-form-urlencoded",
"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;
}
Copy import http.client
conn = http.client.HTTPSConnection("api.gsped.it")
payload = "id_sped=69562763"
headers = {
'Content-Type': "application/x-www-form-urlencoded",
'x-api-key': "YOUR-API-KEY"
}
conn.request("DELETE", "/sandbox/Parcels", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Copy package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.gsped.it/sandbox/Parcels"
payload := strings.NewReader("id_sped=69562763")
req, _ := http.NewRequest("DELETE", url, payload)
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
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))
}
Copy var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Delete,
RequestUri = new Uri("https://api.gsped.it/sandbox/Parcels"),
Headers =
{
{ "x-api-key", "YOUR-API-KEY" },
},
Content = new FormUrlEncodedContent(new Dictionary<string, string>
{
{ "id_sped", "69562763" },
}),
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}c
Copy curl --request DELETE \
--url https://api.gsped.it/sandbox/Parcels \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'x-api-key: YOUR-API-KEY' \
--data id_sped=69562763
Notes
When the customer makes a shipment with AddParcel, it is possible to trace back to the original creation date from the label creation dates, which are visible in the designated bucket on S3.