# Pickup (richieste di ritiro)

## Pickup - GET

Restituisce informazioni sullo stato di una richiesta di ritiro.

## Recupero informazioni ritiro.

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

#### Query Parameters

| Name                                 | Type    | Description   |
| ------------------------------------ | ------- | ------------- |
| id<mark style="color:red;">\*</mark> | Integer | ID del ritiro |

#### Headers

| Name                                        | Type   | Description              |
| ------------------------------------------- | ------ | ------------------------ |
| x-api-key<mark style="color:red;">\*</mark> | String | Api Key fornita da Gsped |

{% tabs %}
{% tab title="200: OK Operazione eseguita correttamente" %}

```javascript
{
    "status": 2,
    "num_spedizione": "",
    "error": "",
    "id": 70058437,
    "note": "",
    "note_orm": "",
    "num_orm": "CBJ180121002626"
}
```

{% endtab %}

{% tab title="400: Bad Request Richiesta mal formata" %}

```javascript
{
    "error": "ID richiesta di ritiro non indicato"
}
```

{% endtab %}

{% tab title="403: Forbidden Api Key non valida" %}

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

{% endtab %}

{% tab title="404: Not Found Spedizione non trovata" %}

```javascript
{
    "error": "Richiesta di ritiro non trovata"
}
```

{% endtab %}
{% endtabs %}

### **Snippets codice di esempio**

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

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.gsped.it/sandbox/pickup?id_sped=12345',
  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/pickup?id_sped=12345", 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/pickup?id_sped=12345"
  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 client = new RestClient("https://api.gsped.it/sandbox/pickup?id_sped=12345");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("x-api-key", "YOUR-API-KEY");
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
```

{% endtab %}

{% tab title="cURL" %}

```shell
curl --location --request GET 'https://api.gsped.it/sandbox/pickup?id_sped=12345' \
--header 'x-api-key: YOUR-API-KEY'
```

{% endtab %}
{% endtabs %}

## Pickup - POST

Invia al corriere una richiesta di ritiro.

{% hint style="info" %}
**Attenzione :**&#x20;

Questo endpoint, a meno di errori nei nomi dei campi e/o dati errati risponderà sempre con status code **200,** anche nel caso in cui la richiesta di ritiro non sia andata a buon fine.

Verificare sempre il campo **status** nella risposta della pickup.

Se il valore di questo campo è **0.6** oppure **10** significa che il ritiro non è stato prenotato (nella maggior parte dei casi per orari e date non accettate dal corriere perché non gestibili dal punto di vista operativo).

Infine si tenga conto che non tutti i corrieri rendono disponibile immediatamente l'informazione se il ritiro richiesto è fattibile, verificare con i tecnici di Gsped per i corrieri per cui si vuole usare questo endpoint.
{% endhint %}

## Invia richiesta di ritiro

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

#### Headers

| Name                                           | Type   | Description              |
| ---------------------------------------------- | ------ | ------------------------ |
| Content-Type<mark style="color:red;">\*</mark> | String | application/json         |
| x-api-key<mark style="color:red;">\*</mark>    | String | Api Key fornita da Gsped |

#### Request Body

| Name                                                | Type    | Description                                                                         |
| --------------------------------------------------- | ------- | ----------------------------------------------------------------------------------- |
| client\_id<mark style="color:red;">\*</mark>        | Integer | ID dell'anagrafica con la quale si vuole generare la spedizione (valore comunicato) |
| corriere<mark style="color:red;">\*</mark>          | Integer | Codice corriere                                                                     |
| servizio<mark style="color:red;">\*</mark>          | Integer | Codice servizio                                                                     |
| colli<mark style="color:red;">\*</mark>             | Integer | Numero di colli di cui sarà composta la spedizione                                  |
| peso<mark style="color:red;">\*</mark>              | Float   | Peso complessivo in KG                                                              |
| date\_req\_ritiro<mark style="color:red;">\*</mark> | String  | Data di ritiro (YYYY-MM-DD)                                                         |
| opening\_time<mark style="color:red;">\*</mark>     | String  | Ora pronta merce (HH:MM:SS)                                                         |
| closing\_time<mark style="color:red;">\*</mark>     | String  | Ora chiusura (HH:MM:SS)                                                             |
| opening\_time2                                      | String  | Seconda ora pronta merce (HH:MM:SS) - *solo corriere TNT*                           |
| closing\_time2                                      | String  | Seconda ora chiusura (HH:MM:SS) - *solo corriere TNT*                               |
| ddt\_alpha                                          | String  | Riferimento cliente alfanumerico                                                    |
| ddt\_num                                            | Integer | Riferimento cliente numerico                                                        |
| sender\_name                                        | String  | Nome/denominazione/ragione sociale del mittente                                     |
| sender\_addr                                        | String  | Indirizzo mittente (via + numero civico)                                            |
| sender\_cap                                         | String  | CAP mittente                                                                        |
| sender\_city                                        | String  | Località mittente                                                                   |
| sender\_contact                                     | String  | Persona di riferimento presso il mittente                                           |
| sender\_email                                       | String  | Email del mittente                                                                  |
| sender\_prov                                        | String  | Provincia del mittente (sigla 2 caratteri)                                          |
| sender\_country\_code                               | String  | Paese del mittente (sigla ISO 3166-1 alpha-2)                                       |
| sender\_phone                                       | String  | Telefono del mittente                                                               |
| rcpt\_name                                          | String  | Nome/denominazione/ragione sociale del destinatario                                 |
| note\_sender                                        | String  | Note mittente                                                                       |
| rcpt\_addr                                          | String  | Indirizzo destinatario (via + numero civico)                                        |
| rcpt\_cap                                           | String  | CAP destinatario                                                                    |
| rcpt\_city                                          | String  | Località destinatario                                                               |
| rcpt\_prov                                          | String  | Provincia del destinatario (sigla 2 caratteri)                                      |
| rcpt\_country\_code                                 | String  | Paese del destinatario (sigla ISO 3166-1 alpha- 2)                                  |
| rcpt\_contact                                       | String  | Persona di riferimento presso il destinatario                                       |
| rcpt\_phone                                         | String  | Telefono del destinatario                                                           |
| rcpt\_email                                         | String  | Email del destinatario                                                              |
| merce                                               | String  | Descrizione merce                                                                   |
| daticolli                                           | Array   | Dettaglio dimensione colli (se disponibili):                                        |
| daticolli.n\_collo                                  | Integer | Numero progressivo                                                                  |
| daticolli.altezza                                   | Integer | Altezza in CM                                                                       |
| daticolli.larghezza                                 | Integer | Larghezza in CM                                                                     |
| daticolli.lunghezza                                 | Integer | Lunghezza in CM                                                                     |
| daticolli.peso                                      | Float   | Peso in KG                                                                          |
| daticolli.volume                                    | Float   | Volume in metri cubi                                                                |

{% tabs %}
{% tab title="200: OK Richiesta eseguita correttamente" %}

```javascript
{
    "status": 2,
    "num_spedizione": "",
    "error": "",
    "id": 70061546,
    "note": "",
    "note_orm": "",
    "num_orm": "CBJ180121002626"
}
```

{% endtab %}

{% tab title="400: Bad Request Dati mal formati" %}

```javascript
{
    "error": "client_id: valore non valido"
}
```

{% endtab %}
{% endtabs %}

### **Snippets codice di esempio**

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

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.gsped.it/sandbox/pickup',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
  "client_id": 390,
  "corriere": 1,
  "servizio": 0,
  "colli": 1,
  "peso": 5,
  "date_req_ritiro": "2022-01-14",
  "opening_time": "09:00",
  "closing_time": "17:30",
  "ddt_alpha": "2001504697",
  "ddt_num": 2001504697,
  "sender_name": "Test mittente",
  "sender_addr": "VIA PRINCIPESSA CLOTILDE, 70",
  "sender_cap": "10134",
  "sender_city": "Torino",
  "sender_contact": "contatto mittente",
  "sender_prov": "TO",
  "sender_country_code": "IT",
  "sender_email": "test@gsped.com",
  "sender_phone": "3208281234",
  "note_sender": "",
  "rcpt_addr": "Via Pier Santi Mattarella, 1",
  "rcpt_cap": "92100",
  "rcpt_city": "AGRIGENTO",
  "rcpt_contact": "contatto destinatario",
  "rcpt_country_code": "IT",
  "rcpt_email": "test@gsped.com",
  "rcpt_name": "test destinatario",
  "rcpt_phone": "0922601234",
  "rcpt_prov": "AG",
  "merce": "Articoli arredamento",
  "daticolli": [
    {
      "n_collo": 1,
      "altezza": 50,
      "larghezza": 35,
      "lunghezza": 25,
      "peso": 10,
      "volume": 0.014
    }
  ]
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'x-api-key: YOUR-API-KEY'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}

{% tab title="PYTHON" %}

```python
import http.client
import json

conn = http.client.HTTPSConnection("api.gsped.it")
payload = json.dumps({
  "client_id": 390,
  "corriere": 1,
  "servizio": 0,
  "colli": 1,
  "peso": 5,
  "date_req_ritiro": "2022-01-14",
  "opening_time": "09:00",
  "closing_time": "17:30",
  "ddt_alpha": "2001504697",
  "ddt_num": 2001504697,
  "sender_name": "Test mittente",
  "sender_addr": "VIA PRINCIPESSA CLOTILDE, 70",
  "sender_cap": "10134",
  "sender_city": "Torino",
  "sender_contact": "contatto mittente",
  "sender_prov": "TO",
  "sender_country_code": "IT",
  "sender_email": "test@gsped.com",
  "sender_phone": "3208281234",
  "note_sender": "",
  "rcpt_addr": "Via Pier Santi Mattarella, 1",
  "rcpt_cap": "92100",
  "rcpt_city": "AGRIGENTO",
  "rcpt_contact": "contatto destinatario",
  "rcpt_country_code": "IT",
  "rcpt_email": "test@gsped.com",
  "rcpt_name": "test destinatario",
  "rcpt_phone": "0922601234",
  "rcpt_prov": "AG",
  "merce": "Articoli arredamento",
  "daticolli": [
    {
      "n_collo": 1,
      "altezza": 50,
      "larghezza": 35,
      "lunghezza": 25,
      "peso": 10,
      "volume": 0.014
    }
  ]
})
headers = {
  'Content-Type': 'application/json',
  'x-api-key': 'YOUR-API-KEY'
}
conn.request("POST", "/sandbox/pickup", 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/pickup"
  method := "POST"

  payload := strings.NewReader(`{`+"
"+`
  "client_id": 390,`+"
"+`
  "corriere": 1,`+"
"+`
  "servizio": 0,`+"
"+`
  "colli": 1,`+"
"+`
  "peso": 5,`+"
"+`
  "date_req_ritiro": "2022-01-14",`+"
"+`
  "opening_time": "09:00",`+"
"+`
  "closing_time": "17:30",`+"
"+`
  "ddt_alpha": "2001504697",`+"
"+`
  "ddt_num": 2001504697,`+"
"+`
  "sender_name": "Test mittente",`+"
"+`
  "sender_addr": "VIA PRINCIPESSA CLOTILDE, 70",`+"
"+`
  "sender_cap": "10134",`+"
"+`
  "sender_city": "Torino",`+"
"+`
  "sender_contact": "contatto mittente",`+"
"+`
  "sender_prov": "TO",`+"
"+`
  "sender_country_code": "IT",`+"
"+`
  "sender_email": "test@gsped.com",`+"
"+`
  "sender_phone": "3208281234",`+"
"+`
  "note_sender": "",`+"
"+`
  "rcpt_addr": "Via Pier Santi Mattarella, 1",`+"
"+`
  "rcpt_cap": "92100",`+"
"+`
  "rcpt_city": "AGRIGENTO",`+"
"+`
  "rcpt_contact": "contatto destinatario",`+"
"+`
  "rcpt_country_code": "IT",`+"
"+`
  "rcpt_email": "test@gsped.com",`+"
"+`
  "rcpt_name": "test destinatario",`+"
"+`
  "rcpt_phone": "0922601234",`+"
"+`
  "rcpt_prov": "AG",`+"
"+`
  "merce": "Articoli arredamento",`+"
"+`
  "daticolli": [`+"
"+`
    {`+"
"+`
      "n_collo": 1,`+"
"+`
      "altezza": 50,`+"
"+`
      "larghezza": 35,`+"
"+`
      "lunghezza": 25,`+"
"+`
      "peso": 10,`+"
"+`
      "volume": 0.014`+"
"+`
    }`+"
"+`
  ]`+"
"+`
}`)

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

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("Content-Type", "application/json")
  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 client = new RestClient("https://api.gsped.it/sandbox/pickup");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("x-api-key", "YOUR-API-KEY");
var body = @"{
" + "\n" +
@"  ""client_id"": 390,
" + "\n" +
@"  ""corriere"": 1,
" + "\n" +
@"  ""servizio"": 0,
" + "\n" +
@"  ""colli"": 1,
" + "\n" +
@"  ""peso"": 5,
" + "\n" +
@"  ""date_req_ritiro"": ""2022-01-14"",
" + "\n" +
@"  ""opening_time"": ""09:00"",
" + "\n" +
@"  ""closing_time"": ""17:30"",
" + "\n" +
@"  ""ddt_alpha"": ""2001504697"",
" + "\n" +
@"  ""ddt_num"": 2001504697,
" + "\n" +
@"  ""sender_name"": ""Test mittente"",
" + "\n" +
@"  ""sender_addr"": ""VIA PRINCIPESSA CLOTILDE, 70"",
" + "\n" +
@"  ""sender_cap"": ""10134"",
" + "\n" +
@"  ""sender_city"": ""Torino"",
" + "\n" +
@"  ""sender_contact"": ""contatto mittente"",
" + "\n" +
@"  ""sender_prov"": ""TO"",
" + "\n" +
@"  ""sender_country_code"": ""IT"",
" + "\n" +
@"  ""sender_email"": ""test@gsped.com"",
" + "\n" +
@"  ""sender_phone"": ""3208281234"",
" + "\n" +
@"  ""note_sender"": """",
" + "\n" +
@"  ""rcpt_addr"": ""Via Pier Santi Mattarella, 1"",
" + "\n" +
@"  ""rcpt_cap"": ""92100"",
" + "\n" +
@"  ""rcpt_city"": ""AGRIGENTO"",
" + "\n" +
@"  ""rcpt_contact"": ""contatto destinatario"",
" + "\n" +
@"  ""rcpt_country_code"": ""IT"",
" + "\n" +
@"  ""rcpt_email"": ""test@gsped.com"",
" + "\n" +
@"  ""rcpt_name"": ""test destinatario"",
" + "\n" +
@"  ""rcpt_phone"": ""0922601234"",
" + "\n" +
@"  ""rcpt_prov"": ""AG"",
" + "\n" +
@"  ""merce"": ""Articoli arredamento"",
" + "\n" +
@"  ""daticolli"": [
" + "\n" +
@"    {
" + "\n" +
@"      ""n_collo"": 1,
" + "\n" +
@"      ""altezza"": 50,
" + "\n" +
@"      ""larghezza"": 35,
" + "\n" +
@"      ""lunghezza"": 25,
" + "\n" +
@"      ""peso"": 10,
" + "\n" +
@"      ""volume"": 0.014
" + "\n" +
@"    }
" + "\n" +
@"  ]
" + "\n" +
@"}";
request.AddParameter("application/json", body,  ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
```

{% endtab %}

{% tab title="cURL" %}

```shell
curl --location --request POST 'https://api.gsped.it/sandbox/pickup' \
--header 'Content-Type: application/json' \
--header 'x-api-key: YOUR-API-KEY' \
--data-raw '{
  "client_id": 390,
  "corriere": 1,
  "servizio": 0,
  "colli": 1,
  "peso": 5,
  "date_req_ritiro": "2022-01-14",
  "opening_time": "09:00",
  "closing_time": "17:30",
  "ddt_alpha": "2001504697",
  "ddt_num": 2001504697,
  "sender_name": "Test mittente",
  "sender_addr": "VIA PRINCIPESSA CLOTILDE, 70",
  "sender_cap": "10134",
  "sender_city": "Torino",
  "sender_contact": "contatto mittente",
  "sender_prov": "TO",
  "sender_country_code": "IT",
  "sender_email": "test@gsped.com",
  "sender_phone": "3208281234",
  "note_sender": "",
  "rcpt_addr": "Via Pier Santi Mattarella, 1",
  "rcpt_cap": "92100",
  "rcpt_city": "AGRIGENTO",
  "rcpt_contact": "contatto destinatario",
  "rcpt_country_code": "IT",
  "rcpt_email": "test@gsped.com",
  "rcpt_name": "test destinatario",
  "rcpt_phone": "0922601234",
  "rcpt_prov": "AG",
  "merce": "Articoli arredamento",
  "daticolli": [
    {
      "n_collo": 1,
      "altezza": 50,
      "larghezza": 35,
      "lunghezza": 25,
      "peso": 10,
      "volume": 0.014
    }
  ]
}'
```

{% 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/spedizioni-e-dintorni/pickup-richieste-di-ritiro.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.
