# Descarregar PDF de Pagamentos

### Obter Caminho para Ficheiro

{% hint style="warning" %}
Para um documento ser descarregado, o mesmo deve estar com um estado (status) de finalizado (status = 1) .
{% endhint %}

De modo a descarregar o PDF de um documento, deverá realizar um pedido à seguinte rota:

{% code title="GET" overflow="wrap" %}

```html
https://app.toconline.pt/api/url_for_print/<id do documento de compra>?filter[type]=PurchasesDocument&filter[copies]=1
```

{% endcode %}

{% hint style="info" %}
Para obter o id do Documento de Compra pretendido (document\_id) poderá consultar:

[Documentos de Compra](/apis/compras/documentos-de-compra.md#obter-todos-os-documentos-de-compra-finalizados)
{% endhint %}

Tal como nos restantes pedidos especificados anteriormente, o \<access\_token> corresponde ao token de acesso válido devolvido pelo serviço de OAuth

### Descarregar Ficheiro

Utilizando a resposta recebida, deverá concatenar os atributos: scheme + "://" + host + path, e irá obter o link através do qual a transferência é imediata. Neste caso, seria:

{% code title="GET" %}

```html
https://app.toconline.pt/public-file/path_to_file
```

{% endcode %}


---

# 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://api-docs.toconline.pt/apis/compras/descarregar-pdf-de-pagamentos.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.
