> For the complete documentation index, see [llms.txt](https://apidocs.gsped.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://apidocs.gsped.com/gsped-api-english-version/spedizioni-e-dintorni/shipment-confirm-by-ddt-num.md).

# Shipment Confirm By Ddt Num

Like shipmentConfirm, this endpoint is used to confirm shipments without using the shipment id (Gsped internal reference), but using the numeric reference given to the shipment.

{% hint style="info" %}
**IMPORTANT:**\
The numeric reference **must** be unique (there must not be more than one shipment with the same reference).
{% endhint %}

## Confirm a shipment using the numeric reference

<mark style="color:green;">`POST`</mark> `https://api.gsped.it/[INSTANCE]/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 provided by Gsped |

#### Request Body

| Name             | Type          | Description                                                                                                                              |
| ---------------- | ------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| client\_id\*     | Integer       | Value provided by Gsped (alternative to the ddt\_num parameter)                                                                          |
| ddt\_num\*       | Array Integer | Numeric references of the shipments to confirm                                                                                           |
| create\_manifest | String        | <p>Allowed values: Y or N.<br>If Y, the response includes the manifest field containing the PDF manifest of the confirmed shipments.</p> |

{% tabs %}
{% tab title="200: OK Operation completed successfully" %}

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

{% endtab %}

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

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

{% endtab %}

{% tab title="400: Bad Request Formatting error in the data sent" %}

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

{% endtab %}
{% endtabs %}

#### **Example code snippets:**

{% 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 %}
