> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nevatal.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Download Invoice PDF

> Download the PDF of a single issued invoice

Returns the PDF for one invoice, generated or fetched on demand. Nothing is
persisted — every download is produced fresh. **Payer accounts (cuentas a
convenio) are invoices too**: this same endpoint serves their PDF using their
own `id`.

## Which PDF each invoice gets

| Invoice kind                                        | PDF                                                                                                                                               |
| --------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| Electronic (Alegra)                                 | The provider's **official graphical representation**, fetched on demand from Alegra and returned unmodified.                                      |
| Electronic — external provider (FEV with CUFE only) | A Nevatal-generated PDF marked as an **internal support copy**, showing the CUFE. The official representation is issued by the external provider. |
| Manual                                              | A Nevatal-generated PDF marked **"Manual invoice — not an electronic sales invoice before DIAN"**.                                                |
| Payer account                                       | Whichever of the above applies to its issuing provider.                                                                                           |

A voided invoice (`status: "voided"`) gets a **"VOIDED"** stamp on Nevatal-generated
PDFs (the official Alegra PDF is delivered untouched) and a `-VOIDED` suffix on
the file name in both cases.

## Path Parameters

<ParamField path="id" type="string" required>The invoice ID (also used for payer accounts)</ParamField>

## Response

`200` returns the PDF as `application/pdf`, with `Content-Disposition: attachment`
(file name derived from the invoice's DIAN number when available, otherwise its
internal number) and `Content-Length`.

**Every non-2xx response is the standard JSON error envelope, never binary.**

<ResponseField name="success" type="boolean">Always `false` on error</ResponseField>
<ResponseField name="error" type="string">Pre-localized message — display as-is</ResponseField>
<ResponseField name="code" type="string">Machine-readable error code</ResponseField>
<ResponseField name="correlationId" type="string">Include when reporting an issue</ResponseField>

<ResponseField name="details.reason" type="string">
  Present on `INVOICE_PDF_NOT_AVAILABLE`: one of `not_accepted`,
  `missing_provider_document`, `provider_file_not_available`
</ResponseField>

## Errors

| Status | Code                        | When                                                                           |
| :----: | --------------------------- | ------------------------------------------------------------------------------ |
|  `401` | —                           | Missing or invalid token                                                       |
|  `403` | —                           | Caller lacks `BILLING:read`                                                    |
|  `404` | `NOT_FOUND_ERROR`           | Invoice doesn't exist, is deleted, or belongs to another clinic                |
|  `409` | `INVOICE_PDF_DRAFT`         | The invoice is a draft — issue it first                                        |
|  `409` | `INVOICE_PDF_NOT_AVAILABLE` | No representation is available; see `details.reason` above                     |
|  `503` | `PROVIDER_UNAVAILABLE`      | Alegra did not respond (outage, timeout, or rejected credential) — retry later |

<RequestExample>
  ```bash cURL theme={null}
  curl -X GET "https://api.nevatal.com/api/v1/billing/invoices/6a4e954f3913cb6295ca98b6/pdf" \
    -H "Authorization: Bearer nvtl_your_api_key" \
    -o invoice.pdf
  ```
</RequestExample>

<ResponseExample>
  ```text 200 theme={null}
  HTTP/1.1 200 OK
  Content-Type: application/pdf
  Content-Disposition: attachment; filename="SETP990000123.pdf"
  Content-Length: 87562

  %PDF-1.4 ...
  ```

  ```json 409 theme={null}
  {
    "success": false,
    "error": "DIAN rejected this electronic invoice: it has no official graphical representation.",
    "code": "INVOICE_PDF_NOT_AVAILABLE",
    "correlationId": "req-2f1c",
    "details": { "reason": "not_accepted" }
  }
  ```

  ```json 503 theme={null}
  {
    "success": false,
    "error": "We could not get the official PDF from Alegra. Try again in a few minutes.",
    "code": "PROVIDER_UNAVAILABLE",
    "correlationId": "req-9a0b"
  }
  ```
</ResponseExample>
