> 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/spedizioni-e-dintorni/shipment/corrieri/dhl/resi-in-franchigia-rgr.md).

# Resi in franchigia - RGR

Il reso in franchigia o Returned Goods Relief (RGR) è un servizio offerto da DHL per esonerare dei dazi doganali il proprietario del contratto per prodotti resi dall'estero (SOLO per flussi di andata e ritorno).

Gsped mette a disposizione l'endpoint **RGR** per la generazione del file SPED per la sola spedizione di andata oppure la generazione del file RGR per la spedizione di reso.

## Endpoint RGR

<mark style="color:green;">`POST`</mark> `/https://api.gsped.it/{istanza}/dhl/rgr`

**Headers**

| Name         | Value              |
| ------------ | ------------------ |
| Content-Type | `application/json` |
| x-api-key    | `YOUR API KEY`     |

**Body**

| Name                                                                              | Type   | Description                                                                                                                                                           |
| --------------------------------------------------------------------------------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| flag\_reso<mark style="color:red;">\*</mark>                                      | number | <p>Indicazione se si tratta di una spedizione di reso o meno.<br><br><strong>Valori possibili :</strong> <br>0 -> Spedizione di andata<br>1 -> Spedizione di reso</p> |
| client\_id<mark style="color:red;">\*</mark>                                      | number | Valore comunicato da Gsped                                                                                                                                            |
| num\_spedizione<mark style="color:red;">\*</mark>                                 | string | Numero di spedizione (tracking number)                                                                                                                                |
| colli<mark style="color:green;">\*</mark>                                         | number | Numero di colli                                                                                                                                                       |
| addebito\_dogana<mark style="color:green;">\*</mark>                              | number | <p>Valore numerico che indica a chi spettano gli oneri doganali.<br><br><strong>Valori possibili :</strong> <br>0 -> Destinatario<br>1 -> Mittente</p>                |
| valuta<mark style="color:green;">\*</mark>                                        | string | Codice a tre caratteri che indica la valuta di riferimento (Esempio EUR)                                                                                              |
| rcpt\_email<mark style="color:green;">\*</mark>                                   | string | Indirizzo email del destinatario                                                                                                                                      |
| rcpt\_name<mark style="color:green;">\*</mark>                                    | string | Nome del destinatario                                                                                                                                                 |
| rcpt\_addr<mark style="color:green;">\*</mark>                                    | string | Indirizzo del destinatario                                                                                                                                            |
| rcpt\_city<mark style="color:green;">\*</mark>                                    | string | Cità del destinatario                                                                                                                                                 |
| rcpt\_country\_code<mark style="color:green;">\*</mark>                           | string | Nazione del destinatario in formato ISO code a 2 caratteri                                                                                                            |
| sender\_eori<mark style="color:green;">\*</mark>                                  | string | Codice eori del mittente                                                                                                                                              |
| ordersData<mark style="color:red;">\*</mark>                                      | object | Contiene i dettagli detagli del ordine e/o merce spedita                                                                                                              |
| ordersData.totale\_lordo<mark style="color:green;">\*</mark>                      | number | Valore complessivo della merce spedita                                                                                                                                |
| ordersData.invoice\_number<mark style="color:green;">\*</mark>                    | string | Numero fattura e/o riferimento ordine                                                                                                                                 |
| ordersData.invoice\_date<mark style="color:green;">\*</mark>                      | string | Data della fattura in formato YYYY-MM-DD                                                                                                                              |
| ordersData.detailsData<mark style="color:red;">\*</mark>                          | array  | Array che contiene i dettagli dei prodotti spediti                                                                                                                    |
| ordersData.detailsData.\*.sku<mark style="color:red;">\*</mark>                   | string | SKU del prodotto                                                                                                                                                      |
| ordersData.detailsData.\*.description<mark style="color:green;">\*</mark>         | string | Descrizione del prodotto                                                                                                                                              |
| ordersData.detailsData.\*.hs\_code<mark style="color:green;">\*</mark>            | string | HS Code del prodotto                                                                                                                                                  |
| ordersData.detailsData.\*.country\_of\_origin<mark style="color:green;">\*</mark> | string | Nazione di provenienza del prodotto                                                                                                                                   |
| ordersData.detailsData.\*.prezzo\_singolo<mark style="color:green;">\*</mark>     | number | Prezzo del singolo prodotto                                                                                                                                           |
| ordersData.detailsData.\*.qty<mark style="color:green;">\*</mark>                 | number | Numero di pezzi spediti                                                                                                                                               |
| ordersData.detailsData.\*.peso\_riga<mark style="color:green;">\*</mark>          | number | Peso del prodotto                                                                                                                                                     |
| originalAwbData                                                                   | object | <p>Contiene i dati relativi alla spedizione di andata.<br><br><strong>Nota bene :</strong> Solo in caso si tratti di un reso (flag\_reso = 1)</p>                     |
| originalAwbData.num\_spedizione                                                   | string | Numero di tracking della spedizione di andata                                                                                                                         |
| originalAwbData.detailsData                                                       | array  | Array che contiene i dettagli dei prodotto spediti nella spedizione di anadata                                                                                        |
| originalAwbData.detailsData.\*.sku                                                | string | SKU del prodotto                                                                                                                                                      |

**Legenda :**&#x20;

<mark style="color:red;">\*</mark> -> Dato obbligatorio

<mark style="color:green;">\*</mark> -> Dato obbligatorio **SOLO** in caso si tratti di una spedizione di andata

**Response**

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

```json
{
    "status": "ok"
}
```

{% endtab %}

{% tab title="400" %}

```json
{
    "errors": [
        "The field colli must be numeric.",
        "The field colli must be greater than 0."
    ]
}
```

{% endtab %}
{% endtabs %}

## Esempi

### Payload generazione file SPED per le spedizioni di andata :&#x20;

```json
{
    "flag_reso": "0",
    "client_id": YOUR_CLIENT_ID,
    "num_spedizione": "123456789",
    "colli": "1",
    "addebito_dogana": "1",
    "valuta": "EUR",
    "rcpt_email": "test@gsped.com",
    "rcpt_name": "test destinatario",
    "rcpt_addr": "via palma 12",
    "rcpt_city": "Alessandria",
    "rcpt_country_code": "IT",
    "sender_eori": "codiceEori",
    "ordersData": {
        "totale_lordo": "55",
        "invoice_number": "fatt123",
        "invoice_date": "2024-07-08",
        "detailsData": [
            {
                "sku": "sku123",
                "description": "prodotto 123",
                "hs_code": "hsc123",
                "country_of_origin": "CO",
                "prezzo_singolo": "20",
                "qty": "1",
                "peso_riga": "2"
            },
            {
                "sku": "sku124",
                "description": "prodotto 124",
                "hs_code": "hsc124",
                "country_of_origin": "IT",
                "prezzo_singolo": "35",
                "qty": "1",
                "peso_riga": "1"
            }
        ]
    }
}
```

### Payload generazione file RGR per le spedizioni di reso :

```json
{
    "flag_reso": "1",
    "client_id": YOUR_CLIENT_ID,
    "num_spedizione": "123456789",
    "ordersData": {
        "detailsData": [
            {
                "sku": "sku123"
            },
            {
                "sku": "sku124"
            }
        ]
    },
    "originalAwbData": {
        "num_spedizione": "987654321"
    }
}
```

## Log

I file inviati vengono salvati su bucket gsped-etds su S3.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://apidocs.gsped.com/spedizioni-e-dintorni/shipment/corrieri/dhl/resi-in-franchigia-rgr.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
