Orders

Caricamento ordini su Gsped

Questo endpoint serve a caricare ordini e relativi dettagli su Gsped per permetterne l'evasione via API o via interfaccia web con conseguente generazione delle etichette di spedizione.

Molto utile quando ci si trova a dover gestire diversi punti di evasione ordini che utilizzano l'interfaccia web di Gsped ma per cui non è possibile attivare un connettore per lo scarico automatico degli ordini.

Recupera listato ordini

GET https://api.gsped.it/[ISTANZA]/Orders

Headers

Name
Type
Description

x-api-key*

String

APIKEY fornita da Gsped

Query Parameters

Name
Type
Description

id

int[]

seleziona se id IN [id, id, ...]

client_id

int[]

seleziona se client_id IN [client_id, client_id, ...] Eventuali client_id errati o non permessi verranno ignorati

order_ref

string[]

seleziona se order_ref IN [order_ref, order_ref, ...] Ogni stringa max 50 char

email

string

seleziona se email = email Max 50 char

data_ordine_da

Y-m-d

Seleziona se data_ordine ≥ data_ordine_da

data_ordine_a

Y-m-d

Seleziona se data_ordine <= data_ordine_a

status

string[]

seleziona se status IN [status, status, ...] Max 3 char

exclude_status

string[]

seleziona se status NOT IN [status, status, ...] Max 3 char

corriere

int[]

seleziona se corriere IN [corriere, corriere, ...]

exclude_corriere

int[]

seleziona se corriere NOT IN [corriere, corriere, ...]

invoice_number

string[]

seleziona se invoice_number IN [invoice_number, invoice_number, ...]

invoice_date_da

Y-m-d

Seleziona se invoice_date ≥ invoice_date_da

invoice_date_a

Y-m-d

Seleziona se invoice_date <= invoice_date_a

withDetails

1 | 0

Se 1 ritorna anche i dettagli dell'ordine

perPage

1...100

numero di risultati per pagina richiesti

page

int

numero di pagina richiesta

orderBy

id | client_id | order_ref | email | data_ordine | status | corriere | invoice_number | invoice_date

nome del campo su cui ordinare (default id)

order

ASC | DESC

verso dell'ordinamento (default DESC)

{
    "status": 200,
    "errors": [],
    "response": {
        "gType": "list",
        "resource": "ordini",
        "page": "1",
        "totPages": 440,
        "totEntries": 879,
        "entries": 2,
        "ordini": [
            {
                "address": "1 Central Park S, Apartment 507",
                "city": "New York",
                "client_id": "390",
                "contrassegno": "0.00",
                "country_code": "US",
                "corriere": "0",
                "valuta": "EUR",
                "valore_doganale": "150.000",
                "email": "[email protected]",
                "id": "879",
                "assicurazione": "0.00",
                "generic1": null,
                "generic2": null,
                "generic3": null,
                "generic4": null,
                "generic5": null,
                "generic6": null,
                "generic7": null,
                "generic8": null,
                "generic9": null,
                "generic10": null,
                "invoice_date": null,
                "invoice_number": null,
                "name": "Markus Schmid",
                "note": "",
                "order_ref": "TEST_NUOVO_FEDEX",
                "phone": "1123521455",
                "prov": "NY",
                "servizio": "0",
                "tag1": "gsped",
                "totale_lordo": "150.00",
                "vat_code": null,
                "cap": "10019",
                "data_ordine": "2025-02-03 00:00:00",
                "status": "1.0"
            },
            {
                "address": "Rosenweg 6",
                "city": "Feusisberg",
                "client_id": "390",
                "contrassegno": "0.00",
                "country_code": "CH",
                "corriere": "0",
                "valuta": "EUR",
                "valore_doganale": "150.000",
                "email": "[email protected]",
                "id": "878",
                "assicurazione": "0.00",
                "generic1": null,
                "generic2": null,
                "generic3": null,
                "generic4": null,
                "generic5": null,
                "generic6": null,
                "generic7": null,
                "generic8": null,
                "generic9": null,
                "generic10": null,
                "invoice_date": null,
                "invoice_number": null,
                "name": "Markus Schmid",
                "note": "",
                "order_ref": "TEST_NUOVO_FEDEX",
                "phone": "123123123",
                "prov": "FA",
                "servizio": "0",
                "tag1": "gsped",
                "totale_lordo": "150.00",
                "vat_code": null,
                "cap": "8835",
                "data_ordine": "2025-01-31 00:00:00",
                "status": "1.0"
            }
        ],
        "previousPageUrl": null,
        "nextPageUrl": "https://api.gsped.it/testbed/orders?perPage=2&page=2&totEntries=879"
    }
}

Codici di esempio

<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.gsped.it/sandbox/orders",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  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;
}

Recupera un ordine e dettagli

GET https://api.gsped.it/[ISTANZA]/Orders/[ID_ORDINE]

Recupera un ordine e i relativi dettagli da Gsped

Headers

Name
Type
Description

x-api-key*

String

APIKEY fornita da Gsped

{
    "address": "piazza ambrosoli 13",
    "city": "alessandria",
    "client_id": 390,
    "cod": 123.45,
    "country": "IT",
    "currency": "EUR",
    "customs_value": 123.45,
    "email": "[email protected]",
    "id": 1,
    "insurance": 123.45,
    "invoice_date": "2023-06-05",
    "invoice_number": 12345678,
    "name": "mario rossi",
    "notes": "testo delle note",
    "order_ref": "ordrif56780",
    "phone": 1311750253,
    "province": "AL",
    "rows": [
        {
            "country_of_origin": "DE",
            "description": "Descrizione riga ordine",
            "qty": 1,
            "sku": "art3",
        }
    ],
    "total": 0,
    "warehouse": "",
    "zip": 15121
}

Snippets codice di esempio

<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.gsped.it/sandbox/orders/1",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  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;
}

Caricamento ordini e dettagli

POST https://api.gsped.it/[ISTANZA]/Orders

Permette di caricare gli ordini ed i relativi dettagli su Gsped

Headers

Name
Type
Description

x-api-key*

String

APIKEY fornita da Gsped

Request Body

Name
Type
Description

client_id*

Int

Client ID Gsped

zip*

String

Zipcode Destinatario

city*

String

Città Destinatario

address*

String

Indirizzo Destinatario

name*

String

Nome Destinatario

order_ref*

String

Riferimento ordine

email*

String

Indirizzo email Destinatario

country*

String

Country code iso 2 char

province*

String

Sigla Provincia o Stato

insurance

Float

Valore assicurazione

cod

Float

Valore del contrasssegno

phone*

String

Numero di telefono

rows.description

String

Descrizione dettaglio ordine

warehouse

String

Magazzino

notes

String

Note ordine

rows.qty

Int

Quantità dettaglio

rows.sku

String

SKU dettaglio

rows.country_of_origin

String

Country code iso 2 char di origine della merce

invoice_date

String

Data della fattura dell'ordine

invoice_number

String

Numero della fattura dell'ordine

rows.hs_code

String

HS code dettaglio

rows.barcode_riga

String

Stringa barcode singolo item

rows.prezzo_singolo

String

Prezzo singolo item

rows.peso_riga

String

Peso singolo item

{
  "status": "OK",
  "order_id": 572602
}

Snippets codice di esempio

<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.gsped.it/sandbox/orders",
  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\": 638,\n  \"order_ref\": \"test-gsped-3\",\n  \"name\": \"mario rossi\",\n  \"address\": \"piazza ambrosoli 13\",\n  \"city\": \"alessandria\",\n  \"zip\": \"15121\",\n  \"province\": \"AL\",\n  \"country\": \"IT\",\n  \"email\": \"[email protected]\",\n  \"phone\": \"01311750253\",\n  \"cod\": 10,\n  \"insurance\": 0,\n  \"notes\": \"testo delle note\",\n  \"customs_value\": 123.45,\n  \"currency\": \"EUR\",\n  \"warehouse\": \"\",\n  \"tag\" : \"pippo1\",\n  \"rows\": [\n    {\n    \t\"description\" : \"Cosa rossa 1\",\n      \"sku\": \"art3\",\n      \"qty\": 1\n    },\n    {\n    \t\"description\" : \"Cosa rossa 2\",\n      \"sku\": \"art4\",\n      \"qty\": 2\n    }\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;
}

Modifica ordini e dettagli di ordine esistente

PATCH https://api.gsped.it/[ISTANZA]/Orders/[ID_ORDINE]

Permette di modificare un ordine ed i relativi dettagli su Gsped

Headers

Name
Type
Description

x-api-key*

String

APIKEY fornita da Gsped

Request Body

Name
Type
Description

client_id*

Int

Client ID Gsped

name*

String

Nome Destinatario

order_ref*

String

Riferimento ordine

address*

String

Indirizzo Destinatario

cod

Float

Valore del contrasssegno

phone*

String

Numero di telefono

email*

String

Indirizzo email Destinatario

country*

String

Country code iso 2 char

province*

String

Sigla Provincia o Stato

zip*

String

Zipcode Destinatario

city*

String

Città Destinatario

rows.description

String

Descrizione dettaglio ordine

warehouse

String

Magazzino

notes

String

Note ordine

invoice_number

String

Numero della fattura dell'ordine

invoice_date

String

Data della fattura dell'ordine

insurance

Float

Valore assicurazione

rows.hs_code

String

HS code dettaglio

rows.qty

Int

Quantità dettaglio

rows.sku

String

SKU dettaglio

rows.country_of_origin

String

Country code iso 2 char di origine della merce

{
  "status": "OK",
  "order_id": 572602
}

Snippets codice di esempio

<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.gsped.it/sandbox/orders/1",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "PATCH",
  CURLOPT_POSTFIELDS => "{\n  \"client_id\": 638,\n  \"order_ref\": \"test-gsped-3\",\n  \"name\": \"mario rossi\",\n  \"address\": \"piazza ambrosoli 13\",\n  \"city\": \"alessandria\",\n  \"zip\": \"15121\",\n  \"province\": \"AL\",\n  \"country\": \"IT\",\n  \"email\": \"[email protected]\",\n  \"phone\": \"01311750253\",\n  \"cod\": 10,\n  \"insurance\": 0,\n  \"notes\": \"testo delle note\",\n  \"customs_value\": 123.45,\n  \"currency\": \"EUR\",\n  \"warehouse\": \"\",\n  \"tag\" : \"pippo1\",\n  \"rows\": [\n    {\n    \t\"description\" : \"Cosa rossa 1\",\n      \"sku\": \"art3\",\n      \"qty\": 1\n    },\n    {\n    \t\"description\" : \"Cosa rossa 2\",\n      \"sku\": \"art4\",\n      \"qty\": 2\n    }\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;
}

Comportamento in caso l'ordine sia collegato ad una spedizione da confermare: se la spedizione è extraUE e il corriere supporta i CIN se il corriere supporta la shipmentPatch dei dati CIN si esegue l'aggiornamento sul corriere, altrimenti la spedizione verrà messa in errore in quanto dovrà essere rigenerata con i nuovi dati ordine.

Last updated

Was this helpful?