# Shipment Confirm By Ddt Num

Come la shipmentConfirm, questo endpoint è dedicato per confermare le spedizioni senza utilizzare l'id della spedizione (riferimento interno Gsped) ma utilizzando il riferimento numerico dato alla spedizione.

{% hint style="info" %}
**IMPORTANTE :** \
Il riferimento numerico **deve** essere univoco (non deve esserci più di una spedizione con lo stesso riferimento).
{% endhint %}

## Conferma spedizione utilizzando riferimento numerico

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

#### 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\*                                                                                                              | Integer       | Valore comunicato da Gsped (In alternativa al parametro ddt\_num) |
| ddt\_num\*                                                                                                                | Array Integer | Riferimenti numerici delle spedizioni da confermare               |
| create\_manifest                                                                                                          | String        | <p>Valori ammissibili Y o N.                                      |
| <br>Se Y nella risposta verrà incluso il campo manifest che conterrà il PDF del manifest delle spedizioni confermate.</p> |               |                                                                   |

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

```javascript
{
    "status": "1 spedizioni confermate, 0 errori",
    "errors": []
}
```

{% endtab %}

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

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

{% endtab %}

{% tab title="400: Bad Request Errore di formattazione dei dati trasmessi" %}

```javascript
{
    "error": "ddt_num non indicati o indicati in formato errato"
}
```

{% 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/ShipmentConfirmByDdtnum',
  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 =>'{
  "ddt_num": [
      "123",
      "124"
  ]
}',
  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({
  "ddt_num": [
    "123",
    "124"
  ]
})
headers = {
  'Content-Type': 'application/json',
  'x-api-key': 'YOUR-API-KEY'
}
conn.request("POST", "/sandbox/ShipmentConfirmByDdtnum", 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/ShipmentConfirmByDdtnum"
  method := "POST"

  payload := strings.NewReader(`{
  "ddt_num": [
      "123",
      "124"
  ]
}`)

  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/ShipmentConfirmByDdtnum");
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" +
@"  ""ddt_num"": [" + "\n" +
@"      ""123""," + "\n" +
@"      ""124""" + "\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/ShipmentConfirmByDdtnum' \
--header 'Content-Type: application/json' \
--header 'x-api-key: YOUR-API-KEY' \
--data-raw '{
  "ddt_num": [
      "123",
      "124"
  ]
}'
```

{% 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/shipment-confirm-by-ddt-num.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.
