# Shipment Confirm By Ddt Num

Just as shipmentConfirm, this enpoint confirms the shipments without using its ID (a Gsped internal reference) but, instead, using the numeric reference given at the time of shipping.

{% hint style="info" %}
**IMPORTANTE - PLEASE NOTE :**\
\*\*\*\*The numeric reference **must** be unique (there must not ne a shipment with the same reference)
{% endhint %}

## Confirm the shipment using the numeric reference

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

#### 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 - Apikey given by Gsped |
| ddt\_num                                       | Array Integet | Numeric references of the shipments to confirm   |

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

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

{% endtab %}

{% tab title="400: Bad Request Format error in the transmitted data" %}

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

{% endtab %}

{% tab title="403: Forbidden Invalid Apikey" %}

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

{% endtab %}
{% endtabs %}

#### \*\* Example 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 %}


---

# 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/gsped-api-english-version/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.
