> For the complete documentation index, see [llms.txt](https://docs.api.persat.com.ar/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.api.persat.com.ar/modulos/gestion-de-entregas/obtener-pdf-de-entrega.md).

# Obtener PDF de entrega

Para obtener el PDF de una entrega particular que ya ha sido completada en Persat se debe realizar un GET como el que se muestra a continuación.

<mark style="color:blue;">`GET`</mark> `https://api.persat.com.ar/v1/deliveries/pdf/delivery_id`

{% hint style="danger" %}
Solo se pueden obtener una vez que se hayan realizado. Es decir, una vez que esté en estado FINISHED, FINISHED\_WITH\_DEVIATION o NOT\_FINISHED.
{% endhint %}

#### Path Parameters

| Name                                           | Type   | Description                  |
| ---------------------------------------------- | ------ | ---------------------------- |
| delivery\_id<mark style="color:red;">\*</mark> | String | Identificador de la entrega. |

#### Query Parameters

| Name   | Type   | Description                                                                                                      |
| ------ | ------ | ---------------------------------------------------------------------------------------------------------------- |
| format | String | Si se envía `"base64"`, el PDF se devolverá en base64. Si no se envía, la API responderá con un archivo binario. |

#### Headers

| Name                                            | Type   | Description     |
| ----------------------------------------------- | ------ | --------------- |
| Authorization<mark style="color:red;">\*</mark> | String | Bearer API\_KEY |

### Ejemplo en formato binario

{% hint style="info" %}
Las respuestas en formato binario retornan directamente la descarga del archivo.
{% endhint %}

#### Request con curl

```bash
curl -H "Authorization: Bearer API_KEY" \
     -J -O \
     https://api.persat.com.ar/v1/deliveries/pdf/NEWM23049
```

#### Respuesta

{% tabs %}
{% tab title="200: OK La consulta se ejecutó con éxito" %}
{% code overflow="wrap" fullWidth="true" %}

```json
HTTP/1.1 200 OK
Content-Type: application/pdf
Transfer-Encoding: chunked
Content-Disposition: attachment; filename="NEWM23049.pdf"

<Binary Data>
```

{% endcode %}
{% endtab %}

{% tab title="409: CONFLICT" %}

```json
HTTP/1.1 409 CONFLICT
Content-Type: application/json

{
    "success": false,
    "error": {
        "status": 409,
        "type": "CONFLICT",
        "userMessage": "La entrega 'NEWM23049' debe estar completada para poder generar el PDF"
    }
}
```

{% endtab %}

{% tab title="404: NOT FOUND No se encontró la OT " %}

```json
HTTP/1.1 404 NOT_FOUND
Content-Type: application/json

{
    "success": false,
    "error": {
        "status": 404,
        "type": "NOT_FOUND",
        "userMessage": "No existe una entrega con este nro."
    }
}
```

{% endtab %}
{% endtabs %}

### Analizando la Respuesta en formato base64

{% tabs %}
{% tab title="200: OK La consulta se ejecutó con éxito" %}

```json
{
    "success": true,
    "data": {
        "pdf": "JVBERi0xLjQKJdPr6eEKMSAwIG9iago8PC9DcmVh[...]", // Base64
        "name": "NEWM23049.pdf",
    }
}
```

{% endtab %}

{% tab title="409: CONFLICT" %}

```json
{
    "success": false,
    "error": {
        "status": 409,
        "type": "CONFLICT",
        "userMessage": "La entrega 'NEWM23049' debe estar completada para poder generar el PDF"
    }
}
```

{% endtab %}

{% tab title="404: Not Found No se encontro el formulario requerido" %}

```json
{
    "success": false,
    "error": {
        "status": 404,
        "type": "NOT_FOUND",
        "userMessage": "No existe una entrega con este nro."
    }
}
```

{% endtab %}
{% endtabs %}

**pdf:** Es un string. Representa el pdf en base64.

**name:** Es un string. Nombre sugerido del pdf.

### Ejemplo de PDF descargado

<figure><img src="/files/XensvWgWNIiRdsKrsbHP" alt=""><figcaption><p>Ejemplo de pdf descargado</p></figcaption></figure>
