> Index of every page: https://docs.merchantservicedepot.com/llms.txt

# Download invoice PDF


`GET /v1/invoices/{invoice_id}/pdf`

The invoice as a PDF (`application/pdf`), fronted by your business name. The same address is on every invoice as `pdfUrl`. Any key that can retrieve the invoice can download it.

Auth: a secret key with the `invoices.retrieve` permission. Returns `200` with Invoice PDF.

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `invoiceId` | path | string | Yes | The invoice id in the request path. |

## Request

**curl**

```curl
curl -X GET "https://payments-api-sandbox.merchantservicedepot.com/v1/invoices/{invoice_id}/pdf" \
  -H "Authorization: Bearer $MYELA_API_KEY"
```

**Node**

```node
import { writeFile } from "node:fs/promises";

const res = await fetch("https://payments-api-sandbox.merchantservicedepot.com/v1/invoices/{invoice_id}/pdf", {
  method: "GET",
  headers: {
    Authorization: `Bearer ${process.env.MYELA_API_KEY}`,
  },
});

if (!res.ok) {
  const { error } = await res.json();
  // Branch on error.code — never on error.message.
  throw new Error(error.code);
}
await writeFile("invoice.pdf", Buffer.from(await res.arrayBuffer()));
```

**Python**

```python
import os
import requests

res = requests.get(
    "https://payments-api-sandbox.merchantservicedepot.com/v1/invoices/{invoice_id}/pdf",
    headers={
        "Authorization": f"Bearer {os.environ['MYELA_API_KEY']}",
    },
)

if not res.ok:
    # Branch on error["code"] — never on error["message"].
    raise RuntimeError(res.json()["error"]["code"])
open("invoice.pdf", "wb").write(res.content)
```

## Response

| Field | Type | Description |
| --- | --- | --- |
| `(body)` | application/pdf | The invoice document itself, not JSON. Save the bytes as a .pdf file. |

```json
null
```

Source: https://docs.merchantservicedepot.com/api-reference/download-invoice-pdf/
